Just a little example that uses the Object Model to create a null and a ObjectToCluster constraint for each selected component (point, edge, polygon, …).
Note line 13. I can use CollectionItem.SubElements to get the indices of the selected components.
from win32com.client import constants as C si = Application log = si.LogMessage if si.Selection.Count > 0 and si.ClassName(si.Selection(0)) == 'CollectionItem' and si.Selection(0).SubComponent is not None: # pnt, poly, edge, ... clusterType = si.Selection(0).Type.replace( 'SubComponent','' ) o = si.Selection(0).SubComponent.Parent3DObject for i in si.Selection(0).SubElements: c = o.ActivePrimitive.Geometry.AddCluster( clusterType, "", [i] ) n = si.ActiveSceneRoot.AddNull() n.Kinematics.AddConstraint( "ObjectToCluster", c )
Is it possible to constrain a null to point in a point cloud that is simulated? I have no results with Object to Cluster constrain, ICE Kinematics is not an option because mainly I deal with a large number of positions. Thanks!
Ok, i found a way out (http://www.si-community.com/community/viewtopic.php?f=41&t=2224), but rotations is still under question…
how ’bout https://xsisupport.wordpress.com/2012/02/28/making-a-null-follow-a-particle/ ?
It uses ICE kinematics. I have a basic script that creates a null for every point and adds that kinematic compound to it. For 2000 points it executes about an hour. And even after that I can’t plot result because it massively slows down SI
Oh, ok, I got it, I’ve created nulls first and then applied Transform Objects by Particles command to all of them at once. In this case I got a faster result! Thanks!
My relatives every time say that I am killing my time here at web, however I know I am
getting know-how every day by reading thes nice content.
Any reason you dispatched the Application object instead of just using “Application”? (I know you have to for things like imported modules in plugins, and I think relational views too, but otherwise not really, right?)
While we’re at it, dispatching XSI.Collection vs XSIFactory.CreateObject(“XSI.Collection”)… Which one is better? Is there a difference?
Is there a reason why in this example you dispatch Application instead of using it directly as is?
Also, while we’re at it, is it better to dispatch XSI.Collection or use XSIFactory.CreateObject()? Is there a difference, downside or overhead at all to using either?
RE: dispatching Application
I don’t remember why I didn’t use the siutils shortcuts, but when I removed those shortcuts I was too literal and just pasted in what was in the module. You’re right, I don’t need to dispatch Application.
RE: dispatching XSI.Collection vs using XSIFactory.CreateObject()?
I don’t know. The Syntax Help in the script ed uses dispatch, so that suggests dispatch is the preferred way to do it.
Many thanks for this. Speeds up some work I’m doing now 🙂