show/hide items with a float script on a CA boolean?

show/hide items with a float script on a CA boolean?

Anonymous
Not applicable
933 Views
2 Replies
Message 1 of 3

show/hide items with a float script on a CA boolean?

Anonymous
Not applicable

Hello again friends,

 

I'd like to be able to use a custom attribute boolean switch as an on/off switch for show/hide items in the viewport (in this case, some rig control splines). This would save me the trouble of going into the layers to do it.

 

Since the hide/show properties aren't animatable, I can't reach them through the track view. The visibility track only works at render time.

 

Can anybody point me in the right direction please?

 

Thanks very much for your time. I'll be grubbing around trying to find the solution in the meantime.

0 Likes
Accepted solutions (1)
934 Views
2 Replies
Replies (2)
Message 2 of 3

Swordslayer
Advisor
Advisor
Accepted solution

Proof of concept:

 

(
	delete objects

	local master = Dummy prefix:"Master" wirecolor:green isSelected:true
	local slave = Circle prefix:"Slave" wirecolor:red

	local switcher = attributes switcher
	(
		parameters params rollout:main
		(
			nodeList type:#nodeTab tabSize:0 tabSizeVariable:true
			hidden type:#boolean default:true ui:chxHidden

			on nodeList tabChanged change tabIndex tabCount do this.main.updateList()
			on hidden set arg do for obj in nodeList do obj.isHidden = not arg
		)

		rollout main "Switcher"
		(
			checkBox chxHidden "Visible"
			multiListBox lbxNodeList "Objects: " items:#() selection:0
			button btnAdd "Add" width:50 across:3 offset:[6, -5]
			button btnAddMultiple "..." width:20 offset:[-3, -5]
			button btnRemove "Remove" width:60 offset:[-9, -5]

			fn updateList =
				lbxNodeList.items = for obj in nodeList where isValidNode obj collect obj.name
	 
			fn addSingleItem item:(pickObject()) =
				if item != undefined do appendIfUnique nodeList item
	 
			fn addMultipleItems items:(selectByName title:"Select Multiple" buttonText:"Add") =
				for item in items do appendIfUnique nodeList item
	 
			fn removeItems listUnselected:(-lbxNodeList.selection) =
				nodeList = for i in listUnselected collect nodeList[i]
 
			on main open do updateList()
			on btnAdd pressed do addSingleItem()
			on btnAddMultiple pressed do addMultipleItems()
			on btnRemove pressed do removeItems()
		)
	)
	custAttributes.add master switcher
	append master.nodeList slave
	setCommandPanelTaskMode #modify
)

 

0 Likes
Message 3 of 3

Anonymous
Not applicable

Wonderful scripting, thanks very much! This is a lot for me to digest, I'm quite the noob. But I will be studying it.

 

With your permission, I'd like to add some comments.

 

1. As it's currently set up, it's creating a dummy and appending a CA to that dummy; the rollout then uses a multilist box and sets multiple items hidden/unhidden at once.

 

I'd like to be able to add 2 CAs to an existing CA Holder modifier and use those as checkboxes; so there would be 2 boolean CAs, each with a checkbox for each item. There could be more items later if I can learn how to do this, but I'd like it to be with a single checkbox per item.

 

So what I'm wondering is how to call an item and set it's isHidden property from within a CA Holder modifier.

 

Does that make sense? I want to make sure I'm being clear. In any event, I will try and learn from your example, maybe I can hack it for my use. Thank you very, very much for your time and expertise.

0 Likes