exclusive…
one is a visibility for render, another is a visibility for view.
I want visibility for view. Lights and helper objects don’t render in the viewport anyway.
i would do something like:
RadioVisAttr = attributes RadioVisAttr attribID:#(1010101,2020202)
(
parameters params
(
vis_id type:#integer default:1 animatable:on
)
)
delete objects
b1 = box name:#b1 pos:[0,0,0] wirecolor:green
b2 = box name:#b2 pos:[40,0,0] wirecolor:orange
b3 = box name:#b3 pos:[80,0,0] wirecolor:yellow
bb = #(b1, b2, b3)
attr = createinstance RadioVisAttr
for k=1 to bb.count do
(
b = bb[k]
s = b.visibility = float_script()
b.visibility.controller = s
s.addconstant "id" k
s.addobject "ca" attr
s.setexpression "if ca.vis_id == id then 1 else 0"
)
redrawviews()
ss = attr.vis_id.controller = float_script()
ss.setexpression "s"
instead of float_script you can use just float controller with radiobuttons control
If I understand, DenisT, this code is just for shaded viewport. I’m not sure that’s what @Malkalypse is looking for.
There’s a line in your code I can’t understand: s = b.visibility = float_script()
ClassOf b.visibility is ‘BooleanClass’
ClassOf Float_Script is ‘FloatController’
How does that work?
the first attempt to assign any controller to visibility is always assigns bezier_float. so at the next line i re-assign float_script
i’ve posted my code before i read the answer…
my code is a solution for render case
here is a modification for a view case:
RadioVisAttr = attributes RadioVisAttr attribID:#(1010101,2020202)
(
parameters params
(
vis_id type:#integer default:1 animatable:on
)
)
delete objects
b1 = box name:#b1 pos:[0,0,0] wirecolor:green
b2 = box name:#b2 pos:[40,0,0] wirecolor:orange
b3 = box name:#b3 pos:[80,0,0] wirecolor:yellow
bb = #(b1, b2, b3)
attr = createinstance RadioVisAttr
for k=1 to bb.count do
(
b = bb[k]
s = b.visibility = float_script()
b.visibility.controller = s
s.addconstant "id" k
s.addobject "ca" attr
s.setexpression "(refs.dependentnodes this).ishidden = (ca.vis_id != id); 1"
)
redrawviews()
ss = attr.vis_id.controller = float_script()
ss.setexpression "s"
Hey Denis,
That’s definitely very interesting but Andres is right, it’s not what I’m looking for. It’s not the visibility track I am trying to change, it’s the .isHidden state.
here is a radiobuttons controlled version:
RadioVisAttr = attributes RadioVisAttr attribID:#(1010101,2020202)
(
parameters params rollout:params
(
vis_id type:#integer default:1 animatable:on ui:ui_vis_id
on vis_id set val do
(
for node in (refs.dependentnodes this) do
(
node.visibility.controller.setexpression (node.visibility.controller.getexpression())
)
)
)
rollout params "Radio Vis"
(
radiobuttons ui_vis_id "Vis ID:" labels:#("1","2","3") columns:3
)
)
delete objects
b1 = box name:#b1 pos:[0,0,0] wirecolor:green
b2 = box name:#b2 pos:[40,0,0] wirecolor:orange
b3 = box name:#b3 pos:[80,0,0] wirecolor:yellow
bb = #(b1, b2, b3)
attr = createinstance RadioVisAttr
for k=1 to bb.count do
(
b = bb[k]
append b.baseobject.custattributes attr
s = b.visibility = float_script()
b.visibility.controller = s
s.addconstant "id" k
s.addobject "ca" attr
s.setexpression "print id; (refs.dependentnodes this).ishidden = (ca.vis_id != id); 1"
)
select b1
max modify mode
redrawviews()