[Scripting] Pick 3D View Target

 From:  Michael Gibson
7056.3 In reply to 7056.2 
Hi Umdee,

> 1. Can the view be refreshed at the end of the script to remove lingering artifacts,
> such as the occasional point graphic that remains after picking?


You're probably running your script as "instant inline script", where MoI just directly executes your script code and does not do any other kind of set up or cleanup for you.

If you run your code instead as a "command" there will be various things done to automatically clean up displayed picked points and things like that.

Running it as a "command" means putting the script into a file with a .js file extension, and then copying that file into the \commands sub-folder. That then makes a command name available with the same name as the file (but without any .js file extension). So for example if your command file is named MyCommand.js then the command name is just "MyCommand" (no file extension) and that will be what you put in the shortcut key to execute it. Just the command name, no script: at the front either.

Commands have various setup stuff done for them automatically like loading any .htm file of the same command name and having it ready to go before the script code is run and also will generate undo units for any changes to geometry autoamtically and do various cleanup stuff as a part of the command ending process.

If you are running as an instant script you would need to call moi.ui.clearPickedPoints() yourself to clear that current list of picked points which get displayed.


> 2. If I have no need for construction lines while picking, is there a way to disable them to simplify user interaction?

Sorry no currently there's no way to disable construction lines in a point picker, other than setting pointpicker.onlyUseSnapFunc = true, in which case you also need to supply a snap function yourself by pointpicker.addSnapFunc() and that snap function has to set the point itself rather than using the regular pick workflow.


> 3. Let's say I want only surface snapping enabled during the picking process. Is there a concise
> way to store snapping states, disable all but surface snapping, and restore snapping states?
> Here is an ugly way that seems to work:

There isn't currently any built in way to do that in a more convenient way.

You can force snapping on to a particular object by setting pointpicker.restrictToObject( face ); but there isn't any way to set all object snaps on just an individual point picker, it gets most of them from the global drawing aids states.

There are just a limited number of overrides like being able to force "on" snap on by pointpicker.enableOnObjectSnap = true; but there isn't an equivalent for every single kind of snap.

- Michael