Scripts

 From:  Michael Gibson
2247.3 In reply to 2247.1 
Hi andras,

It's currently not really very easy to make such scripts since I don't have any proper documentation on doing it. You have to kind of learn by looking at the existing commands and other scripts.

If you are not familiar with JavaScript programming, then that's another thing you'll need to know about first, definitely.


> Javascript so I looked for books on internet but I found a lot
> kind of book especially for web programing. Which one is the
> appropriate for moi's sripting?

There's kind of a couple of different layers of stuff.

First there is the JavaScript language itself, which is kind of a separate thing from the web browser.

I think that the classic book for this is the "Rhino" one:
http://oreilly.com/catalog/9780596101992/

Then another layer on top of JavaScript is DHTML/DOM - this is not a part of the JavaScript language itself, but rather is a kind of environment provided by the web browser that you can call in to to manipulate HTML and set up elements, hide and show UI, change the text on things, etc... Some of this does apply to MoI as well since MoI uses HTML for its UI. I'm not really sure what is the best book for this these days, probably one of the other O'Reilly books would be good though.

Then another layer separate from that is MoI's script interfaces. This is another environment that MoI provides to JavaScript code to do things like set up point pickers, create 3D objects, etc...

There is no book currently available on that last layer because it is something that is specific to just MoI.


Some resources:

http://moi3d.com/wiki/Scripting - link to the moi.idl file which lists all the scriptable properties and methods for MoI's interfaces.

http://kyticka.webzdarma.cz/3d/moi/ - Petr's has gathered up all the other scripts and custom commands that have been done before here so there are examples here to look at.

Also every command in MoI has a script (.js) and UI (.htm) file that you can look at as additional examples - these are all in the \commands subfolder inside of MoI's main installation folder.


> And how can I installd the existing script (for example CSec). I
> put in the command folder the both file and than I add a shortcut
> keys but I got Jscript error message ...0 line ...etc.

What exactly did you put as the shortcut key command, can you please post a screenshot of it?

If you put something like script:CSec - that won't work in this case since this is a custom command and not an "inline script". For a custom command you need to put in just the command name like: CSec .

- Michael