ozan
May 12, 2020, 2:13pm
1
Hello
How can i create this geometry with python?
If someone would share an example. Would be appreciated.
I tried this following code. It creates a geometry but nothing visible.
from vcScript import *
import vcVector
import vcMatrix
app = getApplication()
comp = getComponent()
feat = comp.RootFeature.createFeature(VC_GEOMETRY,'Geometry')
tset = feat.Geometry.createGeometrySet(VC_TRIANGLESET)
tset.addPoint( 0, 0, 0 )
tset.addPoint( 100, 0, 0 )
tset.addPoint( 150, 100, 0 )
tset.addPoint( 0, 100, 0 )
tset.update()
feat.rebuild()
comp.rebuild()
app.render()
TSy
May 12, 2020, 5:56pm
2
Adding points (vertices) is not enough, you also need to define how the triangles are formed from those points. This is done with e.g. the addTriangle method.
You can reuse points for multiple triangles.
ozan
May 12, 2020, 9:15pm
3
Got it.
Here is the updated code for who needs it later:
from vcScript import *
comp = getComponent()
feat = comp.RootFeature.createFeature(VC_GEOMETRY,'Geometry')
tset = feat.Geometry.createGeometrySet(VC_TRIANGLESET)
tset.addPoint( 0, 0, 0 )
tset.addPoint( 100, 0, 0 )
tset.addPoint( 150, 100, 0 )
tset.addPoint( 0, 100, 0 )
tset.addTriangle ( 0, 1, 3 ) # 0,1,3 is the index of the point added
tset.addTriangle ( 0, 2, 3 )
tset.update()
feat.rebuild()
comp.rebuild()
app.render()
1 Like