[Closed] wire parameter and visibility
hello,
i would like to control the transparency of an object with the wire parameter
In the code below i have a slide manipulater and a box. when i change the value of the slide manipulator the transparancy of the box only changes when i click somewhere else. But if i would connect the slider manipulater to the position of the box, it reacts immediatly when i use the slider.
Does someone know why this is and how to fix this?
clearlistener()
delete objects
slide = sliderManipulator name:"sliding" value:50 minval:0 maxval:100 xpos:0.4 ypos:0.05 width:100 sldname:"Visibility"
obj_box = box name:"boks" pos:[0,0,0] width:25 length:24 height:25
obj_box.visibility = bezier_float()
paramwire.connect slide.baseobject[#value] obj_box[#visibility] "value/100 as float"
you probably don’t really know how manipulator work. you don’t have do wire anything. manipulators design to wire on the fly.
if you have slider control you also don’t need to wire. you can set slider’s controller to visibility controller.
and you can call redrawviews on every slider change
Hello,
Thank you DenisT for your reply, i wrote it was for visibilty, but i meant transparacy.
i tried the redrawviews before, but it didnt work, i still have to click somewhere else in the viewport to have the transparancy of the object have effect with the new slider manipulater value.
Below i also have an example with your suggestion to use a float_script controller for control of the transparancy, but there is no interaction between the slider manipulator and the box transparancy. Any idea what is wrong?
delete objects
slide = sliderManipulator name:"sliding" value:50 minval:0 maxval:100 xpos:0.4 ypos:0.05 width:100 sldname:"Transparancy"
obj_box = box name:"boks" pos:[0,0,0] widht:25 length:25 height:25
obj_box.visibility = bezier_float()
obj_box.visibility.controller = float_script()
obj_box.visibility.controller.script = "(" + slide.value as string + "/100.00)"
redrawviews()
do you need some kind of personal for this box control which is controlling box’s visibility, or you universal control which might control any objects with a property #visibility?
i would do it using a custom attribute:
global visAttr = attributes visAttr
(
parameters params rollout:params
(
visible type:#float default:1.0 ui:ui_visible
on visible set val do notifydependents this partID:#display
)
rollout params "Parameters"
(
slider ui_visible "Visiblility" range:[0,1,1] scale:0.01 width:152 align:#right offset:[8,0]
)
)
with redraw off
(
delete objects
b = box isselected:on
custattributes.add b visAttr baseobject:on
b.visibility = Bezier_Float()
b.visibility.controller = b.baseobject.visAttr.visible.controller = Bezier_Float()
)
hello,
DenisT, thank you for your script, i will try it tonight when i have a computer with 3ds max.
I see you wrote a second message, the best situation would be to have a universal control that can control any object with the property visibility.
and thank you for your help.
Hello,
DenisT, thank you for you help, i tested your script and it works like a charm, as you asked if i want it to use it for universal control that can control any object with the property visibility.
i have added a callbacks event. Now it works for every object in the scene. Dont know if it is the right way, if you have some advice in doing it better i would appriciate it.
I saw that your code places the slider in the modify panel, but is this also possible to place it in the create panel? maybe have to do with the name ‘rollout params’ that its located in the modify panel.
Anyway below the code for transparancy.
global transparancy_check()
global params
callbacks.RemoveScripts #selectionSetChanged id:#script_update
global visAttr = attributes visAttr
(
parameters params rollout:params
(
visible type:#float default:1.0 ui:ui_visible
on visible set val do notifydependents this partID:#display
)
rollout params "Parameters"
(
slider ui_visible "Visiblility" range:[0.005,1,1] scale:0.01 width:152 align:#right offset:[8,0]
)
)
with redraw off
callbacks.addScript #selectionSetChanged "transparancy_check $" id:#script_update
fn transparancy_check obj =
(
if isValidNode obj and selection.count == 1 then
(
try
(
custattributes.add obj visAttr baseobject:on
obj.visibility.controller
obj.visibility.controller = obj.baseobject.visAttr.visible.controller = Bezier_Float()
)
catch
(
print "No Controller exists. Creating new..!"
obj.visibility = true
)
)
)
i asked it because if you want to control any scene object including multiple selection a manipulator is just the thing you need. but it should made and used right way (not the way you’ve tried to use with the code on top of this thread)