Notifications
Clear all

[Closed] CA incremental default value using for loop

the following code fails to realize what stated in the title of this thread as, after execution, all spheres present in the scene accept the CA but the default value for all objects is 0 and not incremental integers as expected.

Thanks in advance for any advice.

select $sphere*
n = selection.count

testCA = attributes testCA
(
	parameters main rollout:params
	(
		testCA type:#integer ui:ui_test
	)
		rollout params "CA incremental default value" width:162 height:93
	(
		spinner ui_test "incr_defv_CA: "range:[0,1000,i] type:#integer
	)
)

for i = 1 to n do
	custAttributes.add $sphere* testCA
3 Replies

You could do it like this…

spheres = $sphere*
n = spheres.count

testCA = attributes testCA
(
	parameters main rollout:params
	(
		testAttribute type:#integer ui:ui_test
	)
		rollout params "CA incremental default value" width:162 height:93
	(
		spinner ui_test "incr_defv_CA: "range:[0,1000,1] type:#integer
	)
)

for i = 1 to n do
(
	custAttributes.add spheres[i] testCA
	spheres[i].testAttribute = i
)

I changed the name of the parameter as it was the same as the CA.

Thanks Raytracer05,
There’s a lot that I need to learn.

That’s ok. Is it all starting to make sense or do you need me to explain what I’ve done?