Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk 3ds® Max® / MaxScript / selecting multiple objects by name
  RSS 2.0 ATOM  
4 pages: 2.3.4 first

selecting multiple objects by name
Rate this thread
 
33972
 
Permlink of this thread  
avatar
  • Location: West Midlands, England, UK
  • Total Posts: 14445
  • Joined: 06 August 2007 11:06 PM
  • Permlink of this post

El-D

Hi Steve,

I’ve been browsing trying to work out a script and came across this thread. 

I’d also like to select all objects in a scene begining with the same characters but I’d like to loop this and extract the chacters from an array.

ie My array has ( obj,def,asd)

In my loop I’d like to select all obj and process, followed by all def and then all asd.
So something like.

for i in objlist do
(
 selobj 
objlist[i]
 select 
$*selobj*
 
blah blah.
)


The select seems to pick up my variable as a literal though. I’ve tried as name and as string but it never seems to pick it up.

Is it just a syntax issue I’m having?  As you have probably guessed already, I’m not very good at scripting and am trying to learn (albeit slowly) but struggle more with the syntax than the overall structure of what I am doing.

Any help would be greatly appreciated.

Regards

Tim

(
startNames 
#("ab",  "cdef", "ghijk")
 
for  1 to startNames.count do
   
(
   
for obj in geometry where ((subString obj.name 1 startNames[i].count) == startNames[i]) do
      
(
      
-- whatever you need here
      obj
.wirecolor color 0 0 255 -- just an example
      )
   )
)


Max 4.2 through 2013.
XP-64 (SP2)
NVidia 9800GTX-512 (Driver 266.58).
Core 2 Quad Q6600 2.4GHz, 8Gb Ram, DX9.0c.

Replies: 1
/img/forum/dark/default_avatar.png

Very bizarre, I was expecting an email when I recieved a response.. must check my settings.

Thankyou very much. It works perfectly ...after a few tweaks to get my name/strings/shapes correct.

I say perfectly, this code does but the bit I am attempting to excecute isn’t.

for Xobj in XREFNames do
( i=i+1
myNewObjs = getMAXFileObjectNames xobj
xrefs.addNewXRefObject xobj myNewObjs modifiers: #merge manipulators: #merge
for obj in shapes where ((subString obj.name 1 OBJNames.count) == OBJNames) do
(
select obj
instanceReplace obj myNewObjs
print “test”

)

)

Is it a timing issue?  Does the xref appear instantly and become available to select? As soon as I try to replace or select the xref to instance the script the script hangs. When I say hangs, it stops processing on the first object in the array before the print"test" but doesn’t lock up. 

I suspect either a syntax or timing issue but can’t see where I am going wrong.

Many Thanks.

Tim

Author: El-d

Replied: 28 October 2009 10:44 PM  
avatar
  • Location: West Midlands, England, UK
  • Total Posts: 14445
  • Joined: 06 August 2007 11:06 PM
  • Permlink of this post

Couple of things first.

The “Notify me by mail” check box doesn’t appear to work, however, if you scroll to the top of the page you should find a “Subscribe to this thread” link (just under the topic). That one does work.

If you post code always put it in code tags. That prevents the forum from interpreting things in square brackets as tags. e.g. [ i ] (without the spaces) will be interpreted as “begin italics” instead of being actially displayed.
Also, try and keep the code consistently indented (yes, I know the forum screws with it) - makes it much easier to read.

for Xobj in XREFNames do
   
(
   i
=i+1
   myNewObjs 
getMAXFileObjectNames xobj
   xrefs
.addNewXRefObject xobj myNewObjs modifiers#merge manipulators: #merge 
   
for obj in shapes where ((subString obj.name 1 OBJNames[i].count) == OBJNames[i]) do
      
(   
      select obj 
      instanceReplace obj myNewObjs
      
print "test"
      
)
   )

You will have to post all the code. There are too many “undefined” variables there - XREFNames, shapes, OBJNames.
Be careful mixing collections as collections and collections as arrays - there’s no guarantee that “for obj in collection...” will be the same sequence as “for i = 1 to collection.count...”.

I assume that this is all related to your other thread? Maybe it would be better to continue this there rather than hijacking Brian’s thread?

And finally, make sure you put your Max version in your sig - very important to know that. As soon as I looked up the xref functions I see “New in 3ds Max 2010”. Bit of a problem if you’re not actually using 2010…



Max 4.2 through 2013.
XP-64 (SP2)
NVidia 9800GTX-512 (Driver 266.58).
Core 2 Quad Q6600 2.4GHz, 8Gb Ram, DX9.0c.

Replies: 1
/img/forum/dark/default_avatar.png

Cheers. I’ll move it over.

Author: El-d

Replied: 28 October 2009 11:41 PM  
4 pages: 2.3.4 first