Show messages:
1-18
…
79-98
99-118
119-138
139-158
159-178
179-188
From: Michael Gibson
Hi Marco,
re:
> Select all objects (solids or surfaces) that belongs to the currently selected edges (and, at
> the same time, deselect the input selected edges)
You can get the selected edges using this:
code:
var edges = moi.geometryDatabase.getSelectedObjects().getEdges();
Then you'll want to loop through every edge something like this:
code:
for ( var i = 0; i < edges.length; ++i )
{
var edge = edges.item(i);
....
}
To deselect the edge you would do:
code:
edge.selected = false;
To get the parent surface or solid of the edge you would do:
code:
edge.getParentBRep();
So putting that all together it would go something like this:
code:
var edges = moi.geometryDatabase.getSelectedObjects().getEdges();
for ( var i = 0; i < edges.length; ++i )
{
var edge = edges.item(i);
edge.selected = false;
edge.getParentBRep().selected = true;
}
Hope that helps! - Michael
From: mkdm
Perfect Michael!
Exactly what I needed.
Thanks!
One question...
Trying to write some new scripts for my very personal workflow, I've seen that the version of JS that Moi can interpret is rather...aged.
I can't use any modern construct or technique of ES6 like, arrow functions, let and const, deconstructing and so on...
Which version of JS Moi is capable of?
Are you thinking of support newer and more modern version of JS?
Thanks again.
From: Michael Gibson
Hi Marco, I'm glad that was what you needed.
> Which version of JS Moi is capable of?
I think it's ECMAScript5.
> Are you thinking of support newer and more modern version of JS?
No, currently I don't have any specific plans for that.
- Michael
From: mkdm
re > No, currently I don't have any specific plans for that.
..Pity
ES6 has a very good sets of other modern programming languages paradigm.
Anyway. Thanks for the reply.
Message 10083.143 was deleted
From: pokoy (MARCIN)
I totally missed the v4 release as I have lost the track but here's my belated congrats and a big thank you!
V4 managed to open files that I couldn't import in my main DCC app so it's already helped me within the first 10 minutes after the purchase :D
Also, it's nice to see that this place still is as cozy and warm as it was years ago.
Michael, thank you again for MoI3d and stay safe and healthy!
From: mkdm
Hello Michael.
I ask you a little help to do the followings two things, because I don't know where I could find this documentation.
FIRST question:
In one of my scripts, I need to programmatically and temporarily set to "FixedColor" this two settings:
code:
moi.view.surfaceColorMode
moi.view.edgeColorMode
But none of the attempts that I show you here worked out.
code:
moi.view.surfaceColorMode = "FixedColor";
moi.view.edgeColorMode = "FixedColor";
moi.view.surfaceColorMode = 0;
moi.view.edgeColorMode = 1;
moi.view.surfaceColorMode = "Fixed color";
moi.view.edgeColorMode = "Fixed color";
moi.view.surfaceColorMode = "FixedColor";
moi.view.edgeColorMode = "FixedColor";
Also I can't figured out how to revert to the original state:
code:
moi.view.surfaceColorMode = "ByStyle";
moi.view.edgeColorMode = "ByStyle";
None of them did work.
What I have to write in the code?
SECOND question:
I need to put in an javascript array ALL the NAMED objects. That is, ALL the objects that have a NAME explicitly set by the user.
What is the Moi'API call to use?
Thanks and have a nice day.
From: Michael Gibson
Hi Marco,
re:
> But none of the attempts that I show you here worked out.
Your code is working ok for me over here. Here is what I tested:
moi.view.surfaceColorMode = "FixedColor";
moi.view.edgeColorMode = "FixedColor";
moi.ui.alert( moi.view.surfaceColorMode ); // Says "FixedColor".
moi.ui.alert( moi.view.edgeColorMode ); // Says "FixedColor";
moi.view.surfaceColorMode = "ByStyle";
moi.view.edgeColorMode = "ByStyle";
moi.ui.alert( moi.view.surfaceColorMode ); // Says "ByStyle".
moi.ui.alert( moi.view.edgeColorMode ); // Says "ByStyle".
re:
> I need to put in an javascript array ALL the NAMED objects. That is, ALL the objects that have a NAME explicitly set by the user.
>
> What is the Moi'API call to use?
Call moi.geometryDatabase.getObjects() to return an object list of all objects, then go through and test each object's .name property.
Something like:
var objs = moi.geometryDatabase.getObjects();
var names = [];
for ( var i = 0; i < objs.length; ++i )
{
var obj = objs.item(i);
if ( obj.name )
names[ obj.name] = true;
}
- Michael
From: mkdm
Hi.
re:
> "Your code is working ok for me over here."
Hmmm...strange thing :) It didn't work for me.
Ok. I'l try it one more time
Thanks for the other reply also.
From: mkdm
OK :)
I managed how to achieve what I want.
I discovered that (it seems) the problems is that after calling:
code:
moi.view.surfaceColorMode = "FixedColor";
moi.view.edgeColorMode = "FixedColor";
the current active viewport (in my case the "3D" viewport) doesn't do a "refresh", so the objects still looks like before.
But, instead, if I other two lines of code, all works as excpeted:
code:
moi.view.surfaceColorMode = "FixedColor";
moi.view.edgeColorMode = "FixedColor";
// just to FORCE the refresh of the active viewport
moi.geometryDatabase.selectAll();
moi.geometryDatabase.deselectAll();
So, now it works.
Anyway...am I using the correct solution?
Thanks.
From: Michael Gibson
Hi Marco, was it that the edges looked ok but surfaces did not?
There is probably a bug where surface colors are not getting recalculated, I'll see about fixing that up but for now the method you're using should work around the bug.
- Michael
From: Michael Gibson
Hi Marco, also instead of calling the selection functions you could try calling:
moi.geometryDatabase.updateStaticFaceColors();
That should trigger the needed recalculation for changes to surface color. I will update changing surfaceColorMode to do that automatically.
- Michael
From: mkdm
HI. Thanks for help.
re:
> was it that the edges looked ok but surfaces did not?
In can say for sure that surfaces were not updated but honestly I didn't notice If also edges has the same problem
re:
> moi.geometryDatabase.updateStaticFaceColors();
Ok. I'll also try that.
Thanks.
From: mkdm
Thanks Michael.
I'm now using the call to moi.geometryDatabase.updateStaticFaceColors(); to force a refresh of the surface color in the viewport.
It works :)
Please, help me also with this last (for the moment) question:
Is there a way to programmatically set the current Lighting mode?
I mean, a way to programmatically mimic what we can find into the moi.ini settings:
code:
LightingOptions={"selected":"Porcelain"...and so on...}
I ask this because I need to store in a backup variable the current Lighting mode, then set it to a custom Light that I created, named "Drat 2", the reset it back to its original moi's setting.
Is there an Api call to set that LightingOptions={"selected"} ?
Thanks.
From: Booleano
Hi:
I have this pop-up window, with several icons made by me, that call scrips.
They are what I know are within yellow lines
And I would like to know how to put a name under each icon.
This is a line of code for a custom icon in the "SidePane.htm" file.
"
<moi: CommandButton icon = "moi: //ui/icons/ReconstructCurve.png" command = "ReconstructCurve"> </ moi: CommandButton> | "
How would I have to modify each line of code.
Attached image of my window
Thanks.
Image Attachments:
MOI_V_1.jpg
From: Michael Gibson
Hi Booleano,
re:
> How would I have to modify each line of code. Attached image of my window Thanks.
You would put the text content inside the opening/closing tag of the <moi:CommandButton> element, like this:
<moi:CommandButton icon = "..." command = "...">
Text content goes here</moi:CommandButton>
- Michael
From: Michael Gibson
Hi Marco,
re:
> I'm now using the call to moi.geometryDatabase.updateStaticFaceColors(); to force a refresh of
> the surface color in the viewport.
> It works :)
Great, that should work for now. That's a bug that I will fix up though, it should be doing that automatically when surfaceColorMode is modified.
re:
> Is there a way to programmatically set the current Lighting mode?
Yes, check out the properties used in LightingOptions.htm .
- Michael
From: Booleano
Hi Michael.
Perfect.
Can the icons be resized?
If the text is long, it comes out like this.
Thank you.
Image Attachments:
MOI_V_2.JPG
From: Michael Gibson
Hi Booleano,
re:
> Can the icons be resized?
Yes, the icon size comes from this entry in moi.css :
code:
moi\:CommandButton > img, moi\:CommandMenuButton > img, moi\:CommandSplitButton > img {
width:3.25em;
height:3.25em;
}
You can override that by putting in that same rule in a <style> block in the <head> of your .htm file, with different width and height values.
- Michael
Message 10083.158 was deleted
Show messages:
1-18
…
79-98
99-118
119-138
139-158
159-178
179-188