Scripting: Doing a scale and then rotate on the same object
All  1-2  3-6

Previous
Next
 From:  achmey (ACHIM)
11421.3 
Thank you so much for the super-duper quick reply Michael!
That script has exactly the info i needed to get it running.

To summarize it quickly: The "trick" is basically to call factory.calculate() (and then cancel())
instead of .commit() and use the returned object-list as input for the next
transform-factory:


var scaleFactory = moi.command.createFactory( 'scale' );
scaleFactory.setInput( 0, curve );
scaleFactory.setInput( 1, pointpicker.pt );
scaleFactory.setInput( 2, 2.0 ); //scale
scaledCopyCurve = scaleFactory.calculate(); // (actually an list of objects)
scaleFactory.cancel();

var rotFactory = moi.command.createFactory( 'rotate' );
rotFactory.setInput( 0, scaledCopyCurve );
rotFactory.setInput( 1, rotFrame );
rotFactory.setInput( 2, 5 ); // angle
rotFactory.commit(); // either like this or use .calculate()/.cance() again (if more transforms follow)

Achim
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  pressure (PEER)
11421.4 In reply to 11421.3 
Hi Achim,

Re:
> The "trick" is basically to call factory.calculate() (and then cancel())

The cancel part probably isn't necessary here. The reason to cancel is if something like .update() causes stuff to be added to the scene while the plugin is running and you want to remove that stuff for a subsequent step of the plugin.

For a command (run from the commands folder) any active factory that hasn't had .commit() called will get canceled when the command exits. So, another time when you might need to cancel a factory is if your plugin is run as an instant script rather than as a command.

- Peer
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  achmey (ACHIM)
11421.5 In reply to 11421.4 
Hi Peer,

thanks for the clarification. So the .cancel() step could be left out when used in a command-script because there is a kind of final cleanup when the command ends. On the other hand it does not seem to hurt and would make the code reusable in a plugin/instant-script - or do you know of a caveat with this (other than bloated code - which of course might become a problem at some point)?

Achim
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
 From:  pressure (PEER)
11421.6 In reply to 11421.5 
I don't think calling .cancel() will cause any technical problem Achim.

- Peer
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All

 

 
 
Show messages: All  1-2  3-6