Switching object properties>renderable on and off from attribute holder

Hi
I want to switch objects renderable property on and off from attribute holder.
I can switch off renderable property by maxscript by "$.renderable = off". how can I connect this property to attribute holder.
Thank you

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
savascetin's picture

Thanks

Thank you again

barigazy's picture

try this


rendOnOffCA = attributes rendOnOff
(
	parameters main rollout:roll
	(
		rend_on_off type:#boolean animatable:false ui:cb_on_off default:on
 
	)
	rollout roll "Parameters"
	(
		checkbox cb_on_off "Renderable"
		on cb_on_off changed state do ((refs.dependentNodes (custAttributes.getOwner this))[1]).renderable = state
	)
)
emptyMod = EmptyModifier name:"Render Switcher"
obj = Box()
custAttributes.add emptyMod rendOnOffCA
addmodifier obj emptyMod

barigazy

savascetin's picture

thank you

Thank you. How can i use this script on a precreated object?

barigazy's picture

This is better solution using

This is better solution using function.
Just select object and run code below

fn addRenderSwitcher obj =
(
	rendOnOffCA = attributes rendOnOff
	(
		parameters main rollout:roll
		(
			rend_on_off type:#boolean animatable:false ui:cb_on_off default:on
			currobj type:#maxObject
 
		)
		--this.currobj = (NodeTransformMonitor node:obj)
		rollout roll "Parameters"
		(
			checkbox cb_on_off "Renderable"
			on cb_on_off changed state do currobj.node.renderable = state
		)
	)
 
	emptyMod = EmptyModifier name:"Render Switcher"
	custAttributes.add emptyMod rendOnOffCA
	emptyMod.currobj = nodeTransformMonitor node:obj forwardTransformChangeMsgs:false
	addmodifier obj emptyMod
)
addRenderSwitcher $

barigazy

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.