Get the range of a custom attribute

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  12 December 2008
Get the range of a custom attribute

Hello,


I have an object with some custom attributes on it :
$Dummy01.valueX
$Dummy01.valueY

I define my attributeData by doing somethin like that :
spinner ValueX_sp "ValueX" range:[-100,100,0]


then i add the attributedata to the Dummy :
custAttributes.add $Dummy01 AttributeData



But somewhere else in my code, i need to know the range of this attributes.
So i thinked that
 $Dummy01.valueX.range
would work, but it does'nt.
Does someone know a method to get the Range back from an Attribute ?

Thanks
 
  12 December 2008
The range is not defined on parameters, only on the UI control; try setting the value to 5000 - it will happily accept it.

To get the range of the UI control, access it from the rollout... e.g.


ca_test = attributes test (
	rollout roll_test "test" (
		spinner spn_test "test" range:[0,100,1]
	)
	parameters main rollout:roll_test (
		myval type:#float ui:spn_test
	)
)
custAttributes.add $ ca_test
format "Range: %\n" $.roll_test.spn_test.range
 
  12 December 2008
Thanks for the help, i would never have thought it was working this way ^^
 
  12 December 2008
on one particular attribute i was setting up I stored the range values in the parameter block so that i could update them via some spinners and it would reflect this next time it was opened - i had some error checking for the values but you get the idea -

 StrAttr = attributes Stretchrig 
 (
 parameters StretchControls rollout:StrSettings
 	(		
 	MinRange Type:#float Default:-0.5
 	MaxRange Type:#float Default:2.0
 	)
 	
 rollout StrSettings "Setup" width:157 height:67
 (
 	spinner minstr "Min Stretch	" pos:[26,4] width:119 height:16 range:[-1,10,MinRange] scale:0.01
 	spinner maxstr "Max Stretch	" pos:[26,23] width:119 height:16 range:[-1,10,MaxRange] scale:0.01
 	spinner Strval "Stretch Value  " pos:[18,47] width:127 height:16 scale:0.01 range:[MinRange,MaxRange,0]
 			
 	on minstr changed val do
 		MinRange = val
 	on maxstr changed val do
 		MaxRange = val
 )
 
 )
 custattributes.add $.baseobject StrAttr


of course , you could just use a point3 parameter type instead to store the actual range, rather than a value from it.
__________________
Regards,
Pete

Read my technical blog - lonerobot.net
 
  12 December 2008
Its working fine but... i have a strange problem.

I have an object with a custom attribute,

I can access its range with
$box01.roll_test.spn_test.range

It returns [0,100,0]

Okay nice, i make the script everything is working.
I close my scene and reopen it.

My $Box01 is sitting there, and i retype the same line:
$box01.roll_test.spn_test.range

It returns [0,0,0] !?

And the most strange is coming.
I select $Box01 and go in Modify Mode, There i can see the spinner.
I retype the same line
$box01.roll_test.spn_test.range

and now it Returns the right value : [0,100,0]

It acts like if the Range was applied only after "showing" the spinner in Max...
Why does the range not exist before ?
Is there a command to "refresh" the Range of my attribute ? so i am not forced to select each object and go in modify mode... (i could make a script for that, but i don't like this sort of temporary fixs ^^

Thanks for your help!
 
  12 December 2008
Originally Posted by Floating_Inkpot: It acts like if the Range was applied only after "showing" the spinner in Max...
Why does the range not exist before ?

Correct - and it doesn't exist before because 3ds Max doesn't require it before.

Again, you're accessing the range of a spinner.. the attribute parameter itself doesn't have a range.

If you do want to store the range as a parameter, I would recommend creating a point3 parameter (where you now probably have a float). You can't link this directly to the spinner in the UI, so you will have to add additional code to handle getting/setting the value as far as the UI is concerned.

Something like...

ca_test = attributes test (
	rollout roll_test "test" (
		spinner spn_test "test" range:this.theRange
		
		on spn_test changed val do (
			this.theRange.z = val
		)
	)
	parameters params_test rollout:roll_test (
		theRange type:#point3 default:[0,100,50]
		
		on theRange set val do (
			roll_test.spn_test.range = val
		)
	)
)
mySphere = sphere()
custAttributes.add mySphere ca_test

mySphere.theRange -- get value
mySphere.theRange = [min,max,val] -- set value (min, max and val should be numbers)
 
  12 December 2008
Ok thx for the help again
i will try this method as soon as i come back to home
 
  12 December 2008
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 05:19 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.