Notifications
Clear all

[Closed] [MaxScript] Getting Object info on Selection

Hi guys…

I´m with a little problem.
I´m doing a script and i want to update my interface with object data (name, position, rotation) when i click on object.
I did that with a button, but i want that info when i click the object, so i can avoid clicking this button.
My code is:

on btnGet pressed do
(
    ddlColor.selection    = getUserProp $ "color"
    ddlBehavior.selection = getUserProp $ "behavior"
    ddlTexture.selection  = getUserProp $ "texture"        
    ....
    ....
)

i want something like
on mouse.Click do (
)

any idea ??

Thanks for all and sorry for this newbie question…

Cheers…
PG

7 Replies

You need to look for the #SelectionSetChanged (from top of my head, no Max open here) General Callback. Take a look at Part 2 of the ListView ActiveX Control How To Tutorial in the MAXScript Reference – it implements such a callback to update the ListView whenever the selection changed (if I remember correctly, that is)

Really thanks for this help… it´s working pretty well now.
Another quick question

I´m exporting object data to a text file and one of the info i need is the object position and it seems that the script exports this info in Max Units and not the unit i set on my configuration (Centimeters, in this case)

Is there anyway to set my script to export using the unit setup i have choosen???

Thanks for all…

Cheers,
PG

1 Reply
(@bobo)
Joined: 11 months ago

Posts: 0

Check out the UNITS struct in the Reference. There is a units.formatValue() method (IIRC) that converts a value from generic units to the User (Display) Units currently set.

For example, if System Units is set to 1GU= 1inch and your Display Units is set to centimeters, calling

units.formatValue 10.0

results in the string

“25.4cm”

What script/plugin are you using to export?

It’s really up to the exporter code to determine what units it uses. It’s not unusual for them to use native max system units (the default is 1.0 inches), but they could certainly be coded to do a conversion before writing it out.

If you have access to the exporter source, you could try altering it to do the conversion. For example, if the system units are the default 1.0 inch and you want centimeters, multiply the max units by 2.54 (no. of centimeters in 1 inch), etc.

If it’s a compiled plugin you don’t have source access to, you could write a maxscript to do the export with it, then open/alter the text file with the converted units.

Thanks for the info, but i´m not using any 3rd party exporter

I´m just writing the object information on a txt file using max script for that.
i´m using something like “object.pos as string” and it writes using Max units and not the unit i set.
Got my problem ?

Thanks for all

Cheers…
PG

Cool. In your script, instead of “obj.pos as string”, use “(obj.pos * 2.54) as string” to export in centimeters.

I`ll try…
thanks for the quick reply

Cheers…
PG