Hi Pior,
re:
> Is there an official place somewhere listing all these script classes, and maybe even
> an inventory of useful commands like this one ?
There is a collection of scripts used in buttons in the help file here:
http://moi3d.com/3.0/docs/moi_command_reference11.htm#shortcutkeys
And there are some other frequently requested ones collected here:
http://kyticka.webzdarma.cz/3d/moi/
> This page could even be accessible directly from the Shortcut Keys option
> panel for instance.
In the future I would like to make an online "script repository" that would hold a bunch of scripts listed in different categories and have a browser for them built into MoI but there will be a lot of work involved in making that so I'm not sure when it will be able to happen.
> So naturally I'd be curious to know if there a way to call a complex command like this "sketch repeat"
> script from the html code. This is what I meant by appending it to a button, if that makes sense :)
> This would basically allow me to store custom commands without necessarily having to assign them
> to KB shortcuts.
Yes, on a <moi:CommandButton> element instead of having a command="commandname" attribute instead put in an onclick="" event handler attribute which can contain general script code. So for the sketch repeat it would look like this:
code:
<moi:CommandButton onclick="moi.ui.sidePane.RepeatCheckbox.value = true; moi.command.execCommand( 'SketchCurve' );">Button label</moi:CommandButton>
(Looks like you found that already...)
> Lastly a follow-up question on CPlane : is there a clever way to select a surface, then
> click a button/run a command and have the CPlane be instantly placed on there and
> aligned to said surface ? As opposed to having to launch CPlane and then picking the
> center point and setting the orientation manually each time.
A couple of v4 betas back there were some new methods added to faces that allow scripts to retrieve information on the face so it is possible to do that. Here's a script that will set the cplane to a selected planar face:
script: /* Set cplane to selected face */ var faces = moi.geometryDatabase.getSelectedObjects().getFaces(); if ( faces.length == 1 ) { var f = faces.item(0); if ( f.isPlanar ) { moi.view.setCPlane( f.planarFrame ); } }
Hope that helps!
- Michael