Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

Function returning incorrect slider ranges

Function returning incorrect slider ranges

AndyVanDalsem
Participant Participant
809 Views
1 Reply
Message 1 of 2

Function returning incorrect slider ranges

AndyVanDalsem
Participant
Participant

Hi,

I'm trying to write a function to return Custom Attribute values, in this case the range of the sliders in the Attribute's Rollout. 
The way it's written now the function returns the correct range if only one object is selected: [0,100,0]

But if multiple objects are selected it starts returning ranges of [0,0,0]

Can anyone tell me why this is happening and where I went wrong?

Here's the script and I'm attaching a sample scene. 

fn print_Att_Info = 
(
	for i in selection where i.modifiers.count > 0 do
	(
		for j in i.modifiers do
		(
			if classOf j == emptyModifier do
			(
				def = custAttributes.getDefs j
				for d in def do
				(
					rolloutName = (custAttributes.getPBlockDefs d)[1][4][2]
					rolloutDef = (getProperty j.CustAttributes[d.name] rolloutName)
					for c in rolloutDef.controls do
					(
						if isProperty c "range" do
						(			
							format "obj:%\n ctrl:%\n range:%\n " i.name c.caption c.range
						)
					)
				)
			)
		)
	)
)

 Thanks for any help!

0 Likes
Accepted solutions (1)
810 Views
1 Reply
Reply (1)
Message 2 of 2

denisT.MaxDoctor
Advisor
Advisor
Accepted solution
ems = getclassinstances EmptyModifier 
for em in ems do 
(
	modpanel.setcurrentobject em
	for k=1 to em.custattributes.count do
	(
		ca = em.custattributes[k]
		--def = custattributes.getdef ca
		--ss = custattributes.getdefsource def
		--format "-------------------------------\n%\n--------------------------------\n" ss
		for c in ca.Custom_Attributes.controls where iskindof c SliderControl do format "%\n" c.range
	)
)
	

 

as you can see from this snippet, the slider range value is only valid for 'get' after it has been created once ...

 

you use the same CA everywhere, so you have to define its attribID (it makes sure you are using an instance of the same CA definition). In this case, only one instance needs to be created to have the correct range for all others.

 

   

 

0 Likes