Script outputs a circle but not a cylinder
 1-14  15-34  35-39

Previous
Next
 From:  Martin (MARTIN3D)
5441.35 In reply to 5441.34 
Thank you Brian (Benfarmer) it seems you where spot on with your explanation why scripts execute twice when invoked by TAB.

Thank you Michael for taking the time and addressing my issues in detail. I use the TAB method out of convenience because it seems to be the fastest method to quickly try out scripts during development so its great if the next update allows this.
Unless I'm doing something wrong editing a script file in the MoI commands folder required me to restart MoI after each edit in order to get MoI to recognize the changes. I already discovered that it has its advantages to assign objects to variables and to use the variables in factories.
  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:  Michael Gibson
5441.36 In reply to 5441.35 
Hi Martin,

> Unless I'm doing something wrong editing a script file in the MoI commands folder required me
> to restart MoI after each edit in order to get MoI to recognize the changes.

This is because of a caching mechanism - every time MoI loads a text file from disk it keeps a cached version in memory so that it won't have to load it from disk again the next time you run that command or show that same UI.

I've been meaning to add some way to turn that off though, I'll see about adding a setting in moi.ini for disabling caching.

- Michael
  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:  Martin (MARTIN3D)
5441.37 In reply to 5441.36 
Hi Michael,

I see, such a setting in moi.ini would be good. In the meantime I will switch back to using .js files and just save each test file with a number added like test1.js for the first version, test2.js for the next. This way MoI is forced to load a new command file.
  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:  Martin (MARTIN3D)
5441.38 In reply to 5441.37 
Hi Michael,

what is the correct way to assign objects to variables? So far I use factory.commit which adds the object to the scene, then I select it somehow (which is not always easy) and assign the selection to a variable. It works but I think there must be a better way. I saw that you use factory.calculate() to assign an object to a variable followed by factory.cancel() and tried the following script:

code:
/*draw cylinder*/
var factory = moi.command.createFactory( 'cylinder' );
factory.setInput( 1, moi.vectorMath.createFrame() );
factory.setInput( 3, 20 );
factory.setInput( 4, moi.vectorMath.createPoint( 0, 0, 40 ) );
var cylinder1 = factory.calculate();
cylinder1.name = 'Zylinder 1';
factory.cancel();
moi.geometryDatabase.addObject(cylinder1);


The script above crashes MoI so I assume my understanding of how this all works is wrong :-)
  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:  Michael Gibson
5441.39 In reply to 5441.38 
Hi Martin, it's possible for some factories to return more than one object as the result of their operation so because of that the factory.calculate() method does not just return a single object like your code there is expecting, it actually returns an "object list".

You can then retrieve the object out of that object list by something like this:

var objlist = factory.calculate();
var cylinder1 = objlist.item(0);

- Michael
  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:  1-14  15-34  35-39