Is there any way to create a hole geometry through the Vortex editor without having to go through C++ as described in the documentation? Alternatively, is there any way to accomplish the same using python scripting? It seems that VxSim.py lacks the hole classes for the collision geometry.
Unfortunately hole geometry types have not yet been added to VxDynamics and are thus not available for immediate creation in the Vortex Studio Editor. However, they are part of the core physics engine (VxCore) and can be created either through C++ or via python through the pyvx module. The pyvx module exposes a large portion of the core physics capabilities to python. This makes it possible to create hole geometries and add them to the universe via a python script extension that is added to a mechanism or scene in the Vortex Studio Editor.
Attached is a Vortex Studio 2017a mechanism (box hole in pyvx - 2017a.zip) which demonstrates this via a script extension that inserts a VxBoxHole geometry into a VxBox geometry, therefore producing a hollow box. The hollow box is added to a dynamically controlled part and then added to the universe in the on_add_to_universe python script callback function.
I also added another part containing a sphere geometry inside the editor and placed it in the center of the hollow box (SphereAssembly), therefore trapping the sphere in its center.
When starting the simulation, the hole part will be added to the universe, and if the geometry display is activated (Shift-G, or right click on 3D view -> Debug Display -> Geometry), it will be visible in the 3D view.
By using mouse spring (Alt-left click on geometry surface), one can grab the hollow box and move it around and see how the trapped sphere collides with the inside box surfaces (see figure above with contacts displayed (Shift-C)).
Here is the corresponding pyvx code snippet for the python script:
from VxSim import * def on_add_to_universe(self, universe): """ Called when the script is added to the universe. Use this method to define specific dynamics actions that must be taken at initialization.""" # create composite cg compositeCG = pyvx.create("VxCompositeCollisionGeometry") # create a large box and a small box hole boxCG = pyvx.create("VxCollisionGeometryBox") #print dir(boxCG.geometry) boxCG.geometry.dimensions.x = 2.0 boxCG.geometry.dimensions.y = 2.0 boxCG.geometry.dimensions.z = 2.0 # note: default dimension of box hole is (x=1.0, y=1.0, z=1.0) boxholeCG = pyvx.create("VxCollisionGeometryBoxHole") # add box and box hole to composite cg compositeCG.collisionGeometries.add(boxCG) compositeCG.collisionGeometries.add(boxholeCG) # create a part and add the composite to it self.part = pyvx.create("VxPart") #print dir(self.part) self.part.collisionGeometries.add(compositeCG) self.part.position.z = 1.0 # add the part to the universe universe.parts.add(self.part) pass def on_remove_from_universe(self, universe): """ Called when the script is removed from the universe. Use this method to define specific dynamics actions that must be taken at shutdown.""" # remove the part from the universe universe.parts.remove(self.part) pass def pre_step(self): """ Called before the collision detection and before the dynamic solver. Use this method to get inputs or set values to dynamics objects.""" pass def post_step(self): """ Called after the collision detection and after the dynamic solver. Use this method to set outputs or get values from dynamics objects.""" pass
Hope this helps,
Please note that the solution provided above is no longer valid. The creation of Hole Geometry in the Editor is not supported. The pyvx library is deprecated and scheduled to be removed.
The current expected implementation of Hole Geometry uses C++ and is documented here https://www.cm-labs.com/vortexstudiodocumentation/Vortex_User_Documentation/Content/Concepts/geom_holes.html