PDA

View Full Version : Layers in Slider - a problem


xcvbnm
03-12-2006, 02:55 PM
I'm writing a scripts through which one can access the layer properties by simply dragging a slider. There are two sliders, first will set the layer number and second sets the properties (hidden, frozen etc) corresponding to that layer.
This way you dont have to go to layer manager or layer properties at all.

Its giving an error when you create additional layers while the script is running. The error occurs only when I try to set either 'hidden' or 'frozen' property of the added layer by dragging the slider.

The error is related to one of the sliders and has nothing to do with layers. If you ignore the error the script works for some time then max crashes.

Can someone please suggest a solution?
Here is the script -

--Set layer properties using a slider
--Psan 2006


(
sld = sliderManipulator xPos:0.05 yPos:0.9 width:170 sldName:"Layer Properties" maxVal:8 snapVal:1.0 name:"Layer Properties"
nsld = sliderManipulator xPos:0.05 yPos:0.8 width:170 sldName:"Layer Number" minVal:1 maxVal:10 snapVal:1.0 name:"Layer Number"
layersld = layermanager.getlayer 0
layersld.addnode sld
layersld.addnode nsld

val = 0.0
nsld.value = 1
layer = layermanager.getlayer (layermanager.count-1)
if layer==undefined then (nsld.sldName = "None")
else
(
layer.current = true
nsld.sldName = layer.name
str = "Layer "+ layer.name +" is now active"
displayTempPrompt str 3000
)

when parameters sld changes do
(
if layer==undefined then return 0

if sld.value != val then
(
val = sld.value
if val==0 then
(
sld.sldName = "Normal"
layer.ishidden = false
layer.isfrozen = false
layer.xray = false
layer.renderable = true
layer.castShadows = true
layer.display = #viewport
)
if val==1 then
(
sld.sldName = "Hidden"
layer.ishidden = true
layer.isfrozen = false
layer.xray = false
layer.renderable = true
layer.castShadows = true
layer.display = #viewport
)
if val==2 then
(
sld.sldName = "Frozen"
layer.ishidden = false
layer.isfrozen = true
layer.xray = false
layer.renderable = true
layer.castShadows = true
layer.display = #viewport
)
if val==3 then
(
sld.sldName = "XRay"
layer.ishidden = false
layer.isfrozen = false
layer.xray = true
layer.renderable = true
layer.castShadows = true
layer.display = #viewport
)
if val==4 then
(
sld.sldName = "No Render"
layer.ishidden = false
layer.isfrozen = false
layer.xray = false
layer.renderable = false
layer.castShadows = true
layer.display = #viewport
)
if val==5 then
(
sld.sldName = "No Shadows"
layer.ishidden = false
layer.isfrozen = false
layer.xray = false
layer.renderable = true
layer.castShadows = false
layer.display = #viewport
)
if val==6 then
(
sld.sldName = "Box Mode"
layer.ishidden = false
layer.isfrozen = false
layer.xray = false
layer.renderable = true
layer.castShadows = false
layer.display = #boundingbox
)
if val==7 then
(
sld.sldName = "Wires"
layer.ishidden = false
layer.isfrozen = false
layer.xray = false
layer.renderable = true
layer.castShadows = false
layer.display = #wireframe
)
if val==8 then
(
sld.sldName = "Shaded"
layer.ishidden = false
layer.isfrozen = false
layer.xray = false
layer.renderable = true
layer.castShadows = false
layer.display = #shaded
)
)
)

when parameters nsld changes do
(
nlayer = nsld.value
layer = layermanager.getlayer nlayer
if layer==undefined then (nsld.sldName = "None")
else
(
layer.current = true
nsld.sldName = layer.name
if nlayer==0 then nsld.sldName = "Default 0"
str = "Layer "+ layer.name +" is now active"
displayTempPrompt str 3000
)
)

)

CGTalk Moderation
03-12-2006, 02:55 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.