Notifications
Clear all

[Closed] How To Work With maxObjectTab?

Hello,

I have seen a few written articles about the maxObjectTab parameter array and how to assign nodes to it, in Paul Neale’s article he uses a pickbutton and in others I’ve read the nodes are added after a button is pressed.

What I would like to know is if, in a custom attribute definition, it’s possible to append nodes to the parameter array without having to use a UI item?

Thanks,
-Harry

6 Replies

sure you can. and it’s easy…
there two types of tabs in parameter block: with variable size and with fixed size
for fixed size tabs you can only set an item by index, for variable size tabs all standard array methods are available…
so:

testtabs = attributes testtabs 
(
	parameters params 
	(
		fixedtab type:#maxobjecttab tabsizevariable:off tabsize:4
		variabletab type:#maxobjecttab tabsizevariable:on tabsize:0
		
	)
)
ca = createinstance testtabs 
ca.fixedtab[1] = standard() -- GOOD!
ca.fixedtab[5] = standard() -- BAD!
append ca.fixedtab (standard()) -- BAD!
	
ca.variabletab[1] = standard() -- GOOD!
ca.variabletab[5] = standard() -- GOOD!
append ca.variabletab (standard()) -- GOOD!
deleteitem ca.variabletab 5 -- GOOD!
	 

Hi,

Thanks for that but I want to add the CA definition to an object and adjust the parameters of the nodes in the maxObjectTab array using UI items in a rollout, for example the nodes positions are randomised when a button is pressed – but I don’t want to have to select the nodes to be appended to the maxObjectTab array using, say, a pickButton before I can adjust them, I want to be automatically added. I have an array of objects containing all the nodes that I want to add, so I want to use that to append those nodes to the maxObjectTab array.

I know the initial question was pretty broad and vague, sorry about that.
-Harry

ca.variabletab = nodeArray

That should do what you want. All tabs are arrays so you can work on them the same way you would any array. So directly set it or loop through the array and set it.

-Eric

I had a go and unfortunately it didn’t work, perhaps an example of what I’m going for might clarify things:


(
	myBox1 = Box()
	myBox2 = Box()
	myBoxes = #()
	append myBoxes myBox1
	append myBoxes myBox2
	
	ca = attributes myTest
	(
		parameters myTestP rollout:myTestR
		(
			variableTab type:#maxObjectTab tabSizeVariable:on tabsize:0
		)
		
		rollout myTestR "Test"
		(
			button myTestB "Test Button" align:#center
			
			on myTestB do
				for a in variableTab do
					a.position += random [-5,-5,-5] [5,5,5]
		)
	)
	
	ca.variableTab = myBoxes
	
	addModifier myBox1 (EmptyModifier())
	custAttributes.add myBox1.modifiers[1] testCA
)

I wasn’t really sure where I should put the ca.variableTab = myBoxes part.

-Harry

there where many other mistakes in your code… i fixed them all…
also:

if you want to use nodes (change their transforms for example) you have to use nodeTab

if you use nodeTab you can’t add the node itself to its owned ca nodeTab. it will make dependency loop.

(
 	delete objects
 	myBox0 = Box isselected:on
 	myBox1 = Box()
 	myBox2 = Box()
 	myBoxes = #()
 	append myBoxes myBox1
 	append myBoxes myBox2
 	
 	ca = attributes testCA
 	(
 		parameters myTestP rollout:myTestR
 		(
 			variableTab type:#nodeTab tabSizeVariable:on tabsize:0
 		)
 		
 		rollout myTestR "Test"
 		(
 			button myTestB "Test Button" align:#center
 			
 			on myTestB pressed do
 			(
 				for a in variableTab do a.position += random [-5,-5,-5] [5,5,5]
 				redrawviews()
 			)
 		)
 	)
 	
 	--ca.variableTab = myBoxes
 	
 	addModifier myBox0 (EmptyModifier())
 	custAttributes.add myBox0.modifiers[1] ca
 	myBox0.modifiers[1].testCA.variableTab = myBoxes
 )

Hello again,

I can see one or two of my mistakes (I can’t believe I missed out “pressed”, what a n00b) and you helped clear some things up. I tried again with the maxObjectTab and got it to work so that the object with the Attribute Holder modifier applied can be stored in the maxObjectTab without causing dependency loops.


(
	myBox0 = Box()
	myBox1 = Box()
	myBox2 = Box()
	myBoxes = #()
	append myBoxes myBox0
	append myBoxes myBox1
	append myBoxes myBox2
	
	ca = attributes myTest
	(
		parameters myTestP rollout:myTestR
		(
			variableTab type:#maxObjectTab tabSizeVariable:on tabsize:0
		)
		
		rollout myTestR "Test"
		(
			button myTestB "Test Button" align:#center
			
			on myTestB pressed do
				for a in variableTab do
					a.node.position += random [-5,-5,-5] [5,5,5]
		)
	)
	
	addModifier myBox0 (EmptyModifier())
	custAttributes.add myBox0.modifiers[1] ca
	for a in myBoxes do
		append myBox0.modifiers[1].myTest.variableTab (nodeTransformMonitor node:a forwardTransformChangeMsgs:false)
)

I had heard that this was a better way of making character rigs name independent, previously I was using some strange things with script controllers which I think was slowing things down.

Thanks again,
-Harry