MoI discussion forum
MoI discussion forum

Full Version: Can "presets" for selecting objects be implemented?

Show messages:  1-8  9-23

From: Michael Gibson
26 Mar   [#9] In reply to [#8]
Hi Frederick,

re:
> Anytime I want to export, one click - instead of TAB, type the prefix,
> then issue the Export command.

You can set up a shortcut key that will combine those into a single keypress.

For example:
script: moi.geometryDatabase.deselectAll(); moi.geometryDatabase.selectNamed( 'BC*' ); moi.command.execCommand( 'Export' );

- Michael
From: fcwilt
26 Mar   [#10] In reply to [#9]
Hi Michael,

How slick is that!

I will give that a try tomorrow.

Frederick
From: fcwilt
27 Mar   [#11] In reply to [#9]
Hi Michael,

That script worked just as desired.

One, hopefully final, related question:

The dialog that appears when exporting to STL, "MeshOptions", I'm guessing that is buried deep within MoI and cannot be easily bypassed?

Frederick
From: Michael Gibson
27 Mar   [#12] In reply to [#11]
Hi Frederick,

re:
> I'm guessing that is buried deep within MoI and cannot be easily bypassed?

It can be bypassed when calling it from a script, like this:

script: moi.geometryDatabase.deselectAll(); moi.geometryDatabase.selectNamed( 'BC*' ); moi.geometryDatabase.fileExport( '', 'NoUI=true' );


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:

// Different possible options:
// NoUI=true
// Angle=12.0
// Output=ngons | quads | triangles
// MaxLength=0.0
// MaxLengthApplyTo=curved | planes | all
// MinLength=0.0
// AspectRatio=0.0
// Weld=true
// Display=shadedwithedges | shadednoedges | wireframe
// ExpandedDialog=false

- Michael
From: fcwilt
27 Mar   [#13] In reply to [#12]
Hi Michael,

It seems you have thought of everything.

Just amazing work.

Thanks - you have made this camper very happy.

Frederick
From: fcwilt
27 Mar   [#14] In reply to [#12]
Hi Michael,

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"?

Frederick
From: Michael Gibson
27 Mar   [#15] In reply to [#14]
Hi Frederick,

re:
> 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"?

Yes, that's correct. The xxx should be a string object, like this:

var str = 'STL_Test';
// str is a string that contains 'STL_Test'

var str2 = str.slice( 4 );
// str2 contains a chunk of the original string starting at index 4 and through to the end so it contains 'Test'

moi.ui.alert( str2 );

If you're stuck please post your modified ExportParts.js file.

- Michael
From: fcwilt
27 Mar   [#16] In reply to [#15]
Hi Michael,

I was treating it like a "library" function passing it both the string and the index.

Old school.

Thanks much.

Frederick
From: fcwilt
27 Mar   [#17] In reply to [#15]
Hi Michael,

It's working just fine.

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?

Thanks.

Frederick

Attachments:
ExportParts.zip


From: Michael Gibson
27 Mar   [#18] In reply to [#17]
Hi Frederick,

re:
> But what is generating the prompt?

It's the call to GetObjects().

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.


- Michael
From: fcwilt
27 Mar   [#19] In reply to [#18]
Hi Michael,

Thanks very much for the feedback.

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?

I think I'm getting the hang of this stuff.

Frederick
From: Michael Gibson
27 Mar   [#20] In reply to [#19]
Hi Frederick, I've attached an example here.

- Michael

Attachments:
Example.zip


From: fcwilt
27 Mar   [#21] In reply to [#20]
Hi Michael,

Thank you.

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().

I could not get it to work.

See attached.

Thanks.

Frederick

Attachments:
ExportParts.zip


From: Michael Gibson
27 Mar   [#22] In reply to [#21]
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.

- Michael
From: fcwilt
28 Mar   [#23] In reply to [#22]
Hi Michael,

That seems simple enough.

I will give it a try shortly.

Thanks.

Frederick

Show messages:  1-8  9-23