Selection questions
 1-8  9-22

Previous
Next
 From:  Bravlin
9147.9 In reply to 9147.8 
Oh its nice.
By the way maybe you share a couple of words or links about Moi architecture ?
What levels it have. How does .js plugins processed. I am trying to understand the plugin development process for MOI.
I guess i am spoiled by Autodesk reach SDK. But without one the customization goes via "guess and try" method.
I am not big in development, but have some experience in C++ for Softimage.
  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
9147.10 In reply to 9147.9 
Hi Bravlin, well the layers are that the inner core is C++ compiled code and the UI is implemented in HTML and JavaScript which use the WebKit and JavaScriptCore libraries.

JavaScriptCore has an API that MoI uses to make an object in the js runtime that calls C++ functions when properties are accessed or functions invoked.

Unfortunately making a well documented SDK is an extremely time consuming process and since I'm only one person working on MoI I just do not have enough time available to do developer oriented documentation. So it has not been possible to make that a priority as of yet. It is something that I would like to work on in the future but other functionality targeted at "regular" non-developer users has been and still is my priority currently.

- 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:  Bravlin
9147.11 
ok. i see. let's leave complex SDK to better days.
For example Softimage have Script Editor, SDK Explorer etc.
They helps to debug and examine scripts, objects atributes etc.
What developer environment MOI have ?
In some scripts i notice moi.ui.alert( ) used as loggin mechanism.
  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
9147.12 In reply to 9147.11 
Hi Bravlin, MoI does not currently have any built in developer environment, you just use a text editor to write the files and use moi.ui.alert('text') to pop up messages to help you see what is going on.

Also set the option in moi.ini to disable file caching so it will reload scripts every time they are run, to find that go to http://moi3d.com/wiki/Scripting and go to the link that says "See here for info on disabling file caching so commands will reload on every run".

I would like to work on having an integrated script debugger built in to MoI in the future but it will be a highly time consuming thing to work on so I'm not sure when that will happen.

- 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:  Bravlin
9147.13 
Q_03:
Still talking about styles.
How should i query style for a subcomponents ?
This approach is good for objects but on a components its kinda slow.

I guess it takes time to iterate throgh all subcomponents.
Here is a small script to imitate selection set. It should toggle components selection by moving them to style 'selectset' and back to activstyle.

Maybe we can select style components through moi UI objects ?

EDITED: 30 Jan 2019 by BRAVLIN

  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
9147.14 In reply to 9147.13 
Hi Bravlin, can you post the pieces that are needed to reproduce the slow performance? Like for example if it is happening when running your script on a particular model please post the model too so I can give it a test over here.

One other quick note for the part about creating the style if it's not there, you can use moi.geometryDatabase.findStyle( 'name', true /*CreateIfNotFound*/ ); something like this:

code:
    var style = moi.geometryDatabase.findStyle( 'name', true ); // true for second parameter means create the style if not already existing.
    var  index = style.index;


- 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:  Bravlin
9147.15 
Sure. Try it this way: select some faces from one object. Use script to set current selection to 'selectset' style.
Deselect all. Then use script again to reselect comps. And you see the performance loss (or some lag).
I have i72.2GHz 8GB DDR3.
Unfortunately it happen on every model so i guess it's not a model issue.

EDITED: 10 Dec 2018 by BRAVLIN

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
9147.16 In reply to 9147.15 
Hi Bravlin, I'm not noticing any lag over here with your script.

But a couple of things that could improve performance though - first thing is a script that does selection type stuff is better to run as an "instant script" than as a command.

A command in MoI handles various things related to creating and deleting objects like setting up undo units, clearing selection lock, loading UI files, etc...

If you run it as instant script you will bypass all that stuff. Also you can trigger instant script while running inside of a command. If it's run as a command it will exit any currently running command since there can only be one "command" running at a time.

One way to run things as an instant script is to have the script code pasted directly into the Command field of the Shortcut key editor, prefixed with "script:" . But it is also possible to set up instant script from a .js file. To do that, make a directory named "scripts" as a sibling of "commands" in the moi appdata directory and put it in there. Then for your shortcut key use the name of the script file including the .js file extension like: SaveSelectToStyle.js . You can also put it in any directory and put the whole path to it in the shortcut key like c:\scripts\SaveSelectToStyle.js .

Also a couple other things would be to use geometryDatabase.findStyle() to get the style, and also line 23 if(obj.type = 7) looks like a bug, first you would need == there but also type number 7 is a mesh object will only be around when you're exporting to a mesh format. The objects that you're working with in TEST.3dm are BRep objects so you could use obj.isBRep . I would kind of think that trying to assign to the read only obj.type property would trigger an exception but I guess not, that might be a bug.

So give this one a try with it set up to run as immediate script, does it behave any better for you? :

code:
function DoSaveSelectToStyle()
{
    var gd = moi.geometryDatabase; 
    var activstyleidx = moi.geometryDatabase.activeStyle;
    var objects = gd.getObjects(); 
    var savedobjsnum = 0;

    var si = moi.geometryDatabase.findStyle( 'selectset', true /*CreateIfNotFound*/ ).index;
   
    
    // reselect all selectset objs
    for ( var i = 0; i < objects.length; ++i )
    { 
        var obj = objects.item(i); 
        if(obj.styleIndex == si)
        {
            obj.styleIndex=activstyleidx; 
            obj.selected=true;
            savedobjsnum +=1;
        }
        else
        {
            if(obj.isBRep)
            {
                var subs = obj.getSubObjects();
                for ( var j = 0; j < subs.length; ++j ) 
                { 
                    var sub = subs.item(j); 
                    if(sub.styleIndex == si)
                    {
                        sub.styleIndex=activstyleidx; 
                        sub.selected=true;
                        savedobjsnum +=1;
                    }
                }
            }
        }
    }
    
    // if no objs in style selectset
    if(savedobjsnum == 0)
    {
        var selobjects = gd.getSelectedObjects(); 
        selobjects.setProperty( 'styleIndex', si ); 
    }
}
DoSaveSelectToStyle();




- 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:  Bravlin
9147.17 
"=". My bad. That's what happens when you work without IDE support.
I paste code of functions here, but i use them as .js files.

I tried your code today but unfortunately it also have this lag.
Maybe we can somehow reach UI style selection functions (those that fires up when we press near style gui to select all obj)?
They sure doesn't have any performance issues.

Here is how this lag looks like: https://www.dropbox.com/s/wjy47s71b8quh5r/Dv5mujpFSg.mp4
I use " SHIFT+` " as hotkey to fire script.

EDITED: 11 Dec 2018 by BRAVLIN

  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
9147.18 In reply to 9147.17 
Hi Bravlin,

re:
> Maybe we can somehow reach UI style selection functions (those that fires up when we press near
> style gui to select all obj)?
> They sure doesn't have any performance issues.

There isn't any way set up to access that from script right now but I can add script access to it for the next v4 beta.

Just to make sure I understand, you mean a way to trigger by script the same thing that happens when you click on this selection dot spot in the scene browser? :


- 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:  Bravlin
9147.19 
Yes. I guess the similar query interface will be handy for a group selection 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:  Bravlin
9147.20 
Theas thread helps with performance issue a lot.
http://moi3d.com/forum/messages.php?webtag=MOI&msg=6440.1

script: /*SAVE SELECT TO STYLE*/moi.command.execCommand ('var gd = moi.geometryDatabase; var activstyleidx = moi.geometryDatabase.activeStyle; var objects = gd.getObjects(); var savedobjsnum = 0;var si = moi.geometryDatabase.findStyle( "selectset", true ).index; for ( var i = 0; i < objects.length; ++i ) { var obj = objects.item(i); if(obj.styleIndex == si){ obj.styleIndex=activstyleidx; obj.selected=true; savedobjsnum +=1; } else { if(obj.isBRep) { var subs = obj.getSubObjects(); for ( var j = 0; j < subs.length; ++j ) { var sub = subs.item(j); if(sub.styleIndex == si){sub.styleIndex=activstyleidx; sub.selected=true; savedobjsnum +=1; }}}}}if(savedobjsnum == 0){var selobjects = gd.getSelectedObjects(); selobjects.setProperty( "styleIndex", si ); }');
  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
9147.21 In reply to 9147.20 
Hi Bravlin, some of the advice in that thread is outdated now as of MoI v4. In v4 MoI no longer runs command scripts in a separate process, they are run inside the main MoI process and so there is no longer any performance gain from moving functions from a .js file into the .htm file.

- 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
 From:  Bravlin
9147.22 
XSI-like hide toggler. Hide and unhide only last selected object (in our case last named object).

script: /*HIDE*/ var selobjs = moi.geometryDatabase.getSelectedObjects();if(selobjs.length > 0){var allobjs = moi.geometryDatabase.getObjects();for ( var i = 0; i < allobjs.length; ++i ){var obj = allobjs.item(i);if(obj.name == "lasthide")obj.name="";}selobjs.SetProperty("name", "lasthide");selobjs.SetProperty("hidden", true);}else{moi.geometryDatabase.selectNamed("lasthide");selobjs = moi.geometryDatabase.getSelectedObjects();selobjs.SetProperty("name", "");selobjs.SetProperty("hidden", false);}
  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-8  9-22