Hi dan, when a command exits MoI remembers what the geometry database revision number was at that exit time, and later on that's what is used to inside of moi.geometryDatabase.selectLastCreated(). So that function will select the objects that were created by the last command that finished. In your case there you're using it inside of a command that has not exited yet, so it's not going to find objects created by that still running command.
Try this sequence to get the created point object instead:
code:
var pointfactory = moi.command.createFactory('point');
pointfactory.setInput(0,moi.vectorMath.createPoint(0,0,0));
// call factory.update() to generate objects, while the factory is still kept active.
pointfactory.update();
// factory.getCreatedObjects() will now be able to retrieve an object list of what the command generated.
var objlist = pointfactory.getCreatedObjects();
// call factory.commit() to finalize the factory, if commit is not called the factory will be canceled when the
// command exits and the objects it created will be removed. Note that you can't call .getCreatedObjects()
// after .commit() because the factory clears out all of its internal states once .commit() is called and it's
// not expecting to have any connection to what it did previously at that point.
pointfactory.commit();
> Also is there a way to assign a name to an object, in this case a point, during creation?
Once you have the object list you can iterate over it and assign a name to each object by setting the obj.name property, like obj.name = 'thename'; , or you can assign the same name to everything contained inside of an object list by calling objlist.setProperty( 'name', 'thename' ); . The object does not have to be selected when you access the .name property directly through script.
In v4 I'm expecting to implement more types of geometry creation methods other than the factory interface.
Hope this helps!
- Michael
|