Select Objects using Custom Attributes?

Select Objects using Custom Attributes?

Anonymous
Not applicable
2,036 Views
4 Replies
Message 1 of 5

Select Objects using Custom Attributes?

Anonymous
Not applicable

I am working with models exported from S3D to an FBX format. The original object names have been replaced with Object_22222 but the custom attributes are visible. I need to select objects by type (ie, equipment) and group them so I can apply the appropriate material.

Here is a sample of the attributes I would like to access.

3DSMax_customattribute001.JPG
There are a few hundred objects that use the attribute "Equip Name" and the name is unique to each so I think I will need to identify objects based on the attribute and not the actual name.

Is it possible to select objects using the custom attribute?

0 Likes
2,037 Views
4 Replies
Replies (4)
Message 2 of 5

jeff
Collaborator
Collaborator

Just a thought -- perhaps you can access the custom attributes from maxScript and rename the objects that way?

https://help.autodesk.com/view/3DSMAX/2017/ENU/?guid=__files_GUID_0A1E08F8_A8C5_4737_AA6F_39194AD165...

Max since 1992 (3d Studio) · Win 10-64 · Wintel workstation · 64 GB RAM · nVidia Quadro RTX 4000 · BB render garden via Deadline
0 Likes
Message 3 of 5

Anonymous
Not applicable

thx Jeff

I will try that. As with most projects, the deadline is crazy and I've had to go back to the CAD group to get the model in another format.

0 Likes
Message 4 of 5

lightcube
Advisor
Advisor

The method is fairly simple if you do a little MAXScript. Here is a way to accomplish this:

 

  1. Click F11 to open the MAXScript Listener.
  2. Click the MacroRecorder button and make sure the Enabled option is on.
  3. Select one of your objects with the custom attribute and type an extra character into the field. Take note of the line that appears in the macro recorder section (pink background). You will see something like $.baseObject.caName.propName = "thenameX". (The caName portion represents the name of the customattribute definition and the propName represents the actual property name. You will use these values below.)
  4. Revert the value of your object.
  5. Click Scripting > Max Script Editor.
  6. Click File > New.
  7. Paste the MAXScript code from below and swap the caName / propName for the ones you recorded above.
  8. Click Tools > Evaluate All (CTR+E).
--Select Objects with CA property equalling a value
select (for obj in objects where isProperty obj #caName AND isProperty obj.caName #propName AND obj.caName.propName == "thename" collect obj)

That will select the objects. Verify that the results. If they are the correct objects, you can repeat steps above with the code below--again swapping the caName and propName with those of your custom attributes. Presuming that the material you want is the current material in the material editor (Slate here)

--Give Material to objects with a CA value
theMat = (sme.GetMtlInParamEditor())
if superclassof theMat == Material then (
	for obj in objects where isProperty obj #caName AND isProperty obj.caName #propName AND obj.caName.propName == "thename" do (
		obj.mat = theMat
	)
)

If you do this a lot and on different values, it would be best to build a little UI with rollouts. But that's for another day.

 



Shawn Olson

Developer of Wall Worm

3ds Max 4/Gmax - 3ds Max 2027
Mudbox 2009-2022

Windows 11 x64
i9 11900K
128GB RAM
Geforce 3090
0 Likes
Message 5 of 5

lightcube
Advisor
Advisor

Sorry about several edits, I was editing in-place and misread original request. Current iteration above should now get you where you want to be.



Shawn Olson

Developer of Wall Worm

3ds Max 4/Gmax - 3ds Max 2027
Mudbox 2009-2022

Windows 11 x64
i9 11900K
128GB RAM
Geforce 3090
0 Likes