Script outputs a circle but not a cylinder
 1-13  14-33  34-39

Previous
Next
 From:  bemfarmer
5441.14 In reply to 5441.12 
Thanks Michael.

Well, for what it is worth, none of these scripts work (for me) in MoI, in Windows 7 64 bit.
Neither in Tab entry, nor in Shortcut key.
Keep getting data type mismatch. Spent a couple of hours experimenting, no success.
Maybe something very simple, Mac vs WindowsPC ?


Also, copy/paste, Ctrl+C and Ctrl+V, only copy up to the first invisible CR/LF, when entering in MoI shortcut keys, but
the entire text is pasted in Notepad, or Notepad++.










Maybe I can blame it on .Net 4.5 (Joke)

EDITED: 1 Oct 2012 by BEMFARMER


  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.15 In reply to 5441.14 
Hi Brian, things may get confused when you're pasting in a long multi-line script into a keyboard shortcut, the keyboard shortcut is going to expect to have just one line of text.

It can be better to put the script into its own file (with .js file extension) in some folder like c:\scripts and then in the keyboard shortcut put the full path to the script file in there instead of pasting in inline script text.

If you're still having problems with doing it that way please post the script files here and I can test them.

- 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:  bemfarmer
5441.16 In reply to 5441.15 
Thanks Michael,
I'll try some more, tomorrow. :-)
  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:  stevecim
5441.17 In reply to 5441.15 
I just tried what Michael suggested, used notepad++ , created a line.js file in c:\scripts,
In MoI tab-> full path to script , worked ok for me... Win 7 64 bit, MoI 2.0. Don't have ver3 here at work


Cheers, steve

correction, create line works, but circle and box don't, type mismatch error... this could be a moi version 2.0 error?

EDITED: 1 Oct 2012 by STEVECIM

  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.18 In reply to 5441.14 
Hi Brian, its time to get a Mac (just kidding).
I'm sorry to hear it's not working for you. Please try this one:

script: var factory = moi.command.createFactory( 'box' ); factory.setInput( 0, moi.vectorMath.createFrame() ); factory.setInput( 2, 20.0 ); factory.setInput( 3, 20.0 ); factory.setInput( 4, 20.0 ); factory.commit(); moi.view.resetAll;

The inputs require floating point numbers and that's the only "Type mismatch" I see. Maybe Windows is more picky than Mac.
Another thing to try is to put standard quotes around box like so: "box"


Also if you put the script into a .js file you should leave out the word script: at the beginning (I think).

I used the scripts successfully in version 2.5 and the newest 3 Beta.
  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.19 In reply to 5441.17 
>correction, create line works, but circle and box don't, type mismatch error...

The line script above is the only one with standard quotes. Maybe this is it.
  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.20 In reply to 5441.18 
It appears to be the call to moi.vectorMath.createFrame() - that function takes 3 optional arguments for an origin point and x and y axis directions, but those optional parameters are not behaving the same way between Windows and Mac at the moment, it's not working on Windows to omit those arguments right now.

If you switch that to call moi.vectorMath.createTopFrame() instead then it should probably work everywhere, like this:

script: var factory = moi.command.createFactory( 'box' ); factory.setInput( 0, moi.vectorMath.createTopFrame() ); factory.setInput( 2, 20.0 ); factory.setInput( 3, 20.0 ); factory.setInput( 4, 20.0 ); factory.commit(); moi.view.resetAll;

- 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.21 In reply to 5441.20 
Thanks for figuring this out Michael! And again I learned something new.
Instead of

Draw circle on xz (Front) plane
script:
var frame = moi.vectorMath.createFrame(
		moi.vectorMath.createPoint( 0, 0, 0 ),
		moi.vectorMath.createPoint( 1, 0, 0 ),
		moi.vectorMath.createPoint( 0, 0, 1 ) );
var factory = moi.command.createFactory( 'circle' );
factory.setInput( 1, frame );
factory.setInput( 3, 10 );
factory.commit();


I'll now use the much simpler

script:
var factory = moi.command.createFactory( 'circle' );
factory.setInput( 1, moi.vectorMath.createFrontFrame() );
factory.setInput( 3, 10 );
factory.commit();


Edit: The former script is still required if the center of the circle has to be elsewhere.
The line moi.vectorMath.createPoint( 0, 0, 0 ) determines the center.
  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.22 In reply to 5441.21 
Hi Martin, you can also createFrontFrame() and then set just the origin of the frame by setting the .origin property on the frame.

So something like:

var frame = moi.vectorMath.createFrontFrame();
frame.origin = moi.vectorMath.createPoint( 5, 10, 2 );


Also for the next v3 beta I've tweaked moi.vectorMath.createFrame() so that the optional arguments there will work ok on Windows too when they are left out, there seems to be a little difference in behavior with how optional arguments are handled between the regular Windows OLE automation mechanism and the one in Wine, but it only takes a minor modification for me to make it work ok on both.

- 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:  bemfarmer
5441.23 In reply to 5441.20 
That looks right. I replaced the line "factory.setInput( 1, moi.vectorMath.createFrame() );"
with the code used in Mirror script. The following script works in either of a shortcut key to c:\Script\DrawCircle.js
or with the whole script in a shortcut key line pasted from Notepad++ DrawCircle.js.

I forgot, (again), how to do \code or whatever it was.

The following is for Right view, and it works in Windows7:

code:
script:/*DrawCircle*/var factory = moi.command.createFactory( 'circle' );var FrameOrigin = moi.vectorMath.createPoint( 0, 0, 0 );var FrameXAxis = moi.vectorMath.createPoint(0, 1, 0 );var FrameYAxis = moi.vectorMath.createPoint( 0, 0, 1 );var Frame = moi.vectorMath.createFrame( FrameOrigin, FrameXAxis, FrameYAxis );factory.setInput( 1, Frame );factory.setInput( 3, 10 );factory.commit();


It has been a good learning experience. :-)
That Dave Morrill documentation could use some upgrade, with lots of examples...

EDITED: 1 Oct 2012 by BEMFARMER

  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:  bemfarmer
5441.24 
Okay, it is "less than sign" code "greater than sign,
and to end 'less than sign" /code "greater than sign.
  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.25 In reply to 5441.22 
>frame.origin = moi.vectorMath.createPoint( 5, 10, 2 );

Excellent, thank you again Michael.

This Dave Morill documentation helps a lot! What a huge effort! But I agree what's missing are the simple "Hello World"-type examples. On the other hand I fully understand that scripting or it's documentation can't have priority in the MoI development at this time.

Nevertheless one more question if it's okay:
I found moi.ui.propertiesPanel.editName() which brings up a dialog to edit the name of the selected object but I can't find out how to give an object a name directly without dialog.
  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.26 In reply to 5441.24 
Code looks good. Can you use it with copy and paste formated like this Brian? :-)

Boolean Union of selected objects:
code:
script: /*boolean union*/
var factory = moi.command.createFactory( 'booleanunion' );
factory.setInput( 0, moi.geometryDatabase.getSelectedObjects() );
factory.commit();
  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.27 In reply to 5441.25 
Hi Martin,

> I found moi.ui.propertiesPanel.editName() which brings up a dialog to edit the name of the selected
> object but I can't find out how to give an object a name directly without dialog.

Objects have a .name property that you can set directly using script. So for example:

obj.name = 'my name';

- 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.28 In reply to 5441.27 
Thank you Michael, now I can create an object and name it immediately. A huge help for selecting certain objects for use with createFactory.
I use selectAll() / invertSelection() because I can't get moi.geometryDatabase.selectLastCreated(false) to work.

Name those innoccent, newborn objects:
code:
script:
moi.geometryDatabase.selectAll();
var factory = moi.command.createFactory( 'circle' );
factory.setInput( 1, moi.vectorMath.createFrontFrame() );
factory.setInput( 3, 10 );
factory.commit();
moi.geometryDatabase.invertSelection();
moi.geometryDatabase.getSelectedObjects().item(0).name = "My little circle";


Select them by object name:
code:
script:
moi.geometryDatabase.selectNamed( 'My little circle' );
  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.29 In reply to 5441.28 
I just discovered something strange. Every single script in this thread actually creates two objects on top of each other. I move the generated circle and there's another one below. Can anyone confirm this?
  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:  bemfarmer
5441.30 In reply to 5441.29 
Using the Tab method to run the script creates two circles.
Using the Shortcut key method only creates one circle.

Similarly for the line script.

Paste into shortcut keys only works up to the first CR LF (carriage return, linefeed).
  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:  bemfarmer
5441.31 In reply to 5441.29 
I'll hazard a guess, probably wrong.
Javascript is an interpreter, scans the script (causing a copy), then runs the
script (causing another copy), in TAB mode. Shortcut works properly. Just a wild guess.

Edit: MoI version two also does double copies.
  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:  bemfarmer
5441.32 In reply to 5441.25 
I agree, Assign scripting a lower priority than interactive MoI development. :)
  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.33 In reply to 5441.28 
Hi Martin,

> because I can't get moi.geometryDatabase.selectLastCreated(false) to work.

This is probably because you're not creating the objects in the context of a "command" - there are various things that the command mechanism sets up before and at the end of a command, and the mechanism for recognizing the last created objects is one of those, as well as stuff for setting up undo units, etc...

If you want those kinds of things to work you will need to put your script into a file in the commands folder and then run it as a command rather than as inline instant executed script.

- 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-13  14-33  34-39