PDA

View Full Version : [MaxScript] Getting Object info on Selection


pgstudio
12-27-2007, 05:31 PM
Hi guys...

Im with a little problem.
Im 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

Bobo
12-27-2007, 10:36 PM
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) :)

pgstudio
12-28-2007, 01:59 PM
Really thanks for this help.. its working pretty well now.
Another quick question

Im 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

vScourge
12-28-2007, 05:27 PM
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.

pgstudio
12-28-2007, 05:59 PM
Thanks for the info, but im not using any 3rd party exporter

Im just writing the object information on a txt file using max script for that.
im 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

vScourge
12-28-2007, 06:43 PM
Cool. In your script, instead of "obj.pos as string", use "(obj.pos * 2.54) as string" to export in centimeters.

pgstudio
12-28-2007, 06:44 PM
I`ll try..
thanks for the quick reply

Cheers..
PG

Bobo
12-28-2007, 10:33 PM
Really thanks for this help.. its working pretty well now.
Another quick question

Im 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


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"

CGTalk Moderation
12-28-2007, 10:33 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.