Notifications
Clear all

[Closed] Position, rotation, and custom attributes

I feel like I’m finally starting to get the hang of custom attributes, and now I’ve got a question.

What I would like to do is store a set of position and rotation values as parameters, and a second set of values that store the object’s current offset from the first set. What is the best way to set something like this up?

Is there any way to achieve this strictly in the context of the custom attributes, or will I need to set up global callbacks for them to interact with?

20 Replies
1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

any mxs plugin (including scripted CA) might have parameter block. there is a parameter types – #poin3Tab and #point4Tab. so you can store the position and offsets directly in #point3Tab, and rotations as point4 where p[4] angle and p[1],p[2],p[3] are axis[1],[2],[3] .
or you can use for rotations #poin3Tab as well by converting quat -> eulers -> point3

sounds like more or less what 3DS Max’s “freeze transform ” (alt+right click menu) is designed to do using list controllers. And since list controllers are no more difficult to access than CA’s in max script, I’d just use them.

Well ok, but what if I want to run a function based on the difference between an object’s current position and rotation, and the stored position and rotation values? For example, altering the size based on the difference in position, and the wire color based on the difference in rotation. (Preferring, if possible, to keep the data and the functions stored within the object in question).

Yeah, I get how to /store/ the values, my question is, do I have a way of making them update dynamically based on the node’s current transform data?

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

dynamically? can you clear for me what you want? give me a sample scenario…

By dynamically I just mean that the values would update on the fly as an object is moved about or rotated, or the values it is being compared to are changed by the user or by some other scripted event.

I think paramWire.connect could do that. You might have to separate rotation and pos into discreet parameters, though.

Hi, I want to add some custom attributes to an object, but do not want to have them show up in the ui. I want to be able to find an object that has a custom attribute on it so that I can locate it. The reason for this is that (despite my efforts) artists are changing the names of objects and I am dealing with broken scripts. It would just be easier for me to locate an object by its custom attributes. So far I have the following, which adds an attribute, but I may be going about the location of a scene object in the wrong way.

masterPH = $Sphere001
nodeMasterID = attributes onThisObjectAttr
(
parameters mainP rollout:mainR

(
	nodeID type:#node animatable:false
)

rollout mainR "Node Identify:" 

(		
	checkbox nodeIDcBx enabled: false
)

)
custAttributes.add masterPH nodeMasterID

The above, as stated, will add something to the object in track view and the UI, but its not what I want to do. Suggestions?

Thanks

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

i guess this is all that you need:

global NodeIdentifierAttr = attributes NodeIdentifierAttr (;)
custattributes.add (box()) NodeIdentifierAttr baseobject:off

Relying on node names is (as you’ve discovered) a chancy proposition at the best of times.

You might be interested in taking a look at User-Defined properties, they seem to meet your requirement of being (relatively) hidden, if all you essentially want to do is store a sort of “original name” for a node. Of course, it’s only slightly less vulnerable than relying on the name of the node.

http://docs.autodesk.com/3DSMAX/15/ENU/MAXScript-Help/files/GUID-AF1F51D4-449B-4C4D-9F58-85DB145BC0B9.htm

Hi, thanks for the replies. Dennis, that is a much better way to add the attribute, thanks for that.
Now, at the risk of taking liberties, how would I go about selecting a node(s) that have attributes like this on them and collecting them or it?

I saw this on another page and have tweaked it, but itjust returns a list of undefined attrs:

for attrDef in custAttributes.getSceneDefs() do
(

for attr in (custAttributes.getDefInstances attrDef) do
(
	custAttributes.getOwner attr
)

print attr

)

your print attr statement should be inside the inner loop


for attrDef in custAttributes.getSceneDefs() do 
(

	for attr in (custAttributes.getDefInstances attrDef) do
	(
		custAttributes.getOwner attr
		print attr
	)

)

Page 1 / 2