Blockify and Cylindrify features from Python?

How can this be done?

Can’t find anything in the Help File.

 

Br William

Hi,

Okay let’s try something!

In your program files folder browse to:

Visual Components Professional 4.1\Python\Commands\vcHelpers\Geometry.py

On line 285 and on line 328 are two functions defined with the name that looks like something that we need.

Okay so let’s dig deeper: both need a triangle set. So you know it will only work with Geometry features and not with default blocks and cylinders.

Now the Python part.

from vcScript import *
from vcHelpers import Geometry

comp = getComponent()
app = getApplication()

a = comp.findFeature("YourGeometryFeature")

for x in a.Geometry.GeometrySets: 
  Geometry.createCylinderOnTriangleset(x) # or createBlockOnTriangleset
  a.Geometry.deleteGeometrySet(x) # the functions returns a new set so delete the old one, also better to do afterwards to not edit the list you're looping through
  
comp.rebuild()
a.rebuild()
app.render()

and if you execute this code, your geometry will by cylindrified.

Regards,

@JobW works like a charm! Very helpful, thank you.

If it doesn’t work on default blocks and cylinders doesn’t matter, since then they are already in the shape I want them!

Br William

Good to hear that the provided solution works for you!

Good luck!