-------------------------------------
But how is a special "prefix instead of selection" based export any different than setting the selection by prefix and then using regular selection based export?
-------------------------------------
It's different in that I don't have to keep using the "select by name" feature .
Given a Export command that would select by a pre-established prefix I would just issue the command and the STLs would be exported.
Anytime I want to export, one click - instead of TAB, type the prefix, then issue the Export command.
I update the STL files frequently and since their are all done at the same time they all have the same time stamp in Windows - which is very helpful - to me.
That will use defaults for meshing parameters. You can also send in mesh parameters by using these options separated by semi-colons in the 'NoUI=true' string:
Just when I think I'm starting to understand this stuff I find I don't.
Using the prefix works great for simplifying object selection.
But I really don't need the prefix in the exported STL files.
So I read about the java script slice function which sounds like what I need to remove the STL_ from the object name when creating the filename for exporting.
I tried an experiment, using the ExportParts command you created for me, but I get an error - cannot find variable "slice".
So I'm guessing to use slice (and others things like it) I need to use something like xxx.slice where xxx is where slice "lives"?
I was wondering about a way to display "debug" messages - and it was in the code you posted . Handy.
But something is generating a prompt to select parts to export - even though the code appears to be selecting them correctly before the prompt appears.
The prompt is a good thing because it gives me a chance to cancel the export if I invoked it by mistake.
But what is generating the prompt?
And a related question:
The .HTM file - that provides a user interface if needed?
Is it required?
What invokes that file?
Can you use that file to collect input and feed it into the script?
The object picker will only target preselected objects if the selection happened before the command started.
Since you want to automatically select stuff instead of having the user pick them you probably don't want to use the object picker there at all.
Instead of calling GetObjects() you could call moi.geometryDatabase.getSelectedObjects(); and to wait at the prompt you could call WaitForDialogDone() instead of GetObjects().
> The .HTM file - that provides a user interface if needed?
Yes the .htm file has the UI for the command which will be loaded into the command options area in the upper right of the main window.
> Is it required?
No, if the command doesn't want to show any UI there the .htm file can be omitted.
> What invokes that file?
It's part of the "command" infrastructure. When you run a command if there is an .htm file present it will get loaded into the command options area before the .js code is run.
> Can you use that file to collect input and feed it into the script?
Yes you can put controls in the .htm and the script can access them.
Since you can collect user input from the .HTM file, and I gather there is no real documentation, do you know of a good example, that is simple enough to learn the basics from?
Going back a post or two to where you mentioned this:
-The object picker will only target preselected objects if the selection happened before the command started.
-Since you want to automatically select stuff instead of having the user pick them you probably don't want to use the object picker there at all.
-Instead of calling GetObjects() you could call moi.geometryDatabase.getSelectedObjects(); and to wait at the prompt you could call WaitForDialogDone() instead of GetObjects().
Hi Frederick, almost - so what I meant was get rid of all the objectpicker stuff and you can get the selected objects by the return value of moi.geometryDatabase.getSelectedObjects(), like:
var objs = moi.geometryDatabase.getSelectedObjects();
And now that it's selecting objects by name there won't be any unnamed objects selected so I think you can skip the deselectUnnamedParts part as well.
So maybe just this (untested):
function ExportByPrefix() {
mgd.deselectAll();
mgd.selectNamed(pfix);
WaitForDialogDone();
DoExportParts( mgd.getSelectedObjects() );
}
re:
// what are these 4 lines below supposed to do
Those were updating the prompt (the top line in the command options area) by hiding one line of text and showing the next one.