V4 released!
 1-2  …  103-122  123-142  143-162  163-182  183-188

Message 10083.143 deleted 15 May 2021 by ANDYA

Previous
Next
 From:  pokoy (MARCIN)
10083.144 In reply to 10083.1 
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!
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  mkdm
10083.145 In reply to 10083.1 
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.
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
10083.146 In reply to 10083.145 
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
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  mkdm
10083.147 In reply to 10083.146 
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.
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  mkdm
10083.148 In reply to 10083.146 
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.
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
10083.149 In reply to 10083.148 
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
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
10083.150 In reply to 10083.148 
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
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  mkdm
10083.151 In reply to 10083.150 
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.
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  mkdm
10083.152 In reply to 10083.150 
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.
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Booleano
10083.153 
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.

"" How would I have to modify each line of code. Attached image of my window Thanks.
<moi: CommandButton icon = "moi: //ui/icons/ReconstructCurve.png" command = "ReconstructCurve"> </ moi: CommandButton>



Attachments:

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
10083.154 In reply to 10083.153 
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
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
10083.155 In reply to 10083.152 
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
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Booleano
10083.156 In reply to 10083.154 
Hi Michael.

Perfect.
Can the icons be resized?
If the text is long, it comes out like this.

Thank you.




Attachments:

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
10083.157 In reply to 10083.156 
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
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Message 10083.158 deleted 20 May 2021 by MKDM

Previous
Next
 From:  mkdm
10083.159 In reply to 10083.155 
Hi Michael.

re:
> Yes, check out the properties used in LightingOptions.htm

Thanks :)
DONE!

With this final tip I managed to modify an exixsting script that "render" the viewport into a file or into the clipboard.

Now, I'm able to generate two viewport renderings.

The first, that is the render of the current active viewport.

And the second, that is the "alpha channel" counterpart of the first render: the background if fully BLACK and all the objects are fully WHITE (using a particular lighting style)

In this way I can very very easily import both renderings into Affinity Photo and use the "alpha channel" render to cut-out the background of the rendered viewport.

Both renders are 8000x6000 or 12000x9000 pixels

Thanks for your help.
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Booleano
10083.160 In reply to 10083.157 
Hi Michael.

Once again, thank you very much for your invaluable help.
I have modified my custom window, only with the extra tools that are not in MOI.
But it would be great if you could include in this window, icons that run a script (Scrip1,Scrip2,Scrip3).
And it would look like the attached image (can I do any icon design instead of the "?" Signs).

What code should I use, and in what type of file to write it.
For example, how to put this script:
script: / * Create a style for each object name * / var AllObjects = moi.geometryDatabase.getObjects (); var NamedObjects = new Object (); for (var i = 0; i <AllObjects.length; ++ i) {var Obj = AllObjects.item (i); if (Obj.name! = '') {if (! NamedObjects [Obj.name]) {NamedObjects [Obj.name] = new Array (); } NamedObjects [Obj.name] .push (Obj); }} for (var Name in NamedObjects) {var style = moi.geometryDatabase.findStyle (Name, true); var Objects = NamedObjects [Name]; for (var i = 0; i <Objects.length; ++ i) {Objects [i] .styleIndex = style.index; var SubObjects = Objects [i] .getSubObjects (); for (var j = 0; j <SubObjects.length; ++ j) {SubObjects.item (j) .styleIndex = style.index; }}}


EDITED: 20 May 2021 by BOOLEANO

Attachments:

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
10083.161 In reply to 10083.160 
Hi Booleano,

re:
> And it would look like the attached image (can I do any icon design instead of the "?" Signs).

Yes, you can make your own icon image saved as a .png file, copy the file over into the ui\icons folder,
and have them referenced as the other buttons do as an icon="" attribute on the command button tag.

re:
> What code should I use, and in what type of file to write it.

For direct script code like that, you can put it contained inside of a function in a <script> tag inside the <head>
of your document, and have the script function called in an onclick="" handler on the command button tag.

So inside the <head> of your document, you would put:

code:
<script>
function DoCreateStyles()
{
/* Create a style for each object name */ var AllObjects = moi.geometryDatabase.getObjects ();  ... rest of script code  here ....
}


And on your command button tag put:

code:
<moi:CommandButton onclick="DoCreateStyles();">,,,


- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Booleano
10083.162 In reply to 10083.161 
Hi

Thanks again for your help.

The ideal thing for me would be that you attach the documents for a script.
I don't know if there would be 2 files, for example the name would be "Styles"
1 - "Styles.htm"
And this

And on your command button tag put:
code:
<moi:CommandButton onclick="DoCreateStyles();">,,,

I don't know how it would be

I am attaching a file of what I think I understood.
Please, if it's wrong, you can modify it and resubmit it to serve as a template for the other scripts.
If the second file is missing, please can you send it to me.
Attachments:

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All

 

 
Show messages:  1-2  …  83-102  103-122  123-142  143-162  163-182  183-188