Script Select Object by Name

Next
 From:  Mindset (IGNITER)
8259.1 
Michael Gibson,

I really appreciate how good your software is and how great you and the entire user community is.

Here's my question:
How might one select an object by name from within a script?
(I really did try to search for the answer myself before asking)


Thank you,
-- MindSet
  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
8259.2 In reply to 8259.1 
Thanks MindSet, I'm glad you like MoI!

To select an object by name in a script, you'll need to loop through all objects looking for the one with the .name property that you want.

For example here's a shortcut key script that will select objects with a name of "objA":

<script>
script: var objs = moi.geometryDatabase.getObjects(); for ( var i = 0; i < objs.length; ++i ) { var obj = objs.item(i); if ( obj.name == 'objA' ) obj.selected = true; }
</script>

Also note that you can select an object by a typed in name without using script by pushing the tab key to put focus in the XYZ control and then type in the name and push enter. You can also use wildcard characters like typing in obj* will match anything starting with "obj".

- 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
8259.3 In reply to 8259.2 
Hi Michael.

@ Also note that you can select an object by a typed in name without using script by pushing the tab key to put focus in the XYZ control and then type in the name and push enter. You can also use wildcard characters like typing in obj* will match anything starting with "obj".

Wow! I never knew that feature. Thanks a lot!!

See you.

- Marco (mkdm)
  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:  Mindset (IGNITER)
8259.4 
I found an example from Jun 2015
script: moi.geometryDatabase.selectNamed("ABC_NAME");


http://moi3d.com/forum/index.php?webtag=MOI&msg=7464.6

-- MindSet
  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
8259.5 In reply to 8259.4 
Hi Mindset, oh yeah I forgot that one was exposed to script. That's the same function that typing in the XYZ control and pushing enter uses, so you can also use wildcard matching with * or ? characters calling that one.

- 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:  Mindset (IGNITER)
8259.6 In reply to 8259.5 
Even better!

Thank you; you do such a great job and provide fantastic service!

-- MindSet
  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