I need some help.
Hallo.
The script writen below creates layers by a base name via sub-names defined in script. To create layers at least one checkbox should be checked to enter a word in edittext line.I add a function to the script to block edittext line until a checkbox was checked but only last checkbox doing what I need.
I need to your help to fix this issue.
Thanks
--- LayerCreator 1.0 --- --- Globals for script --- global lyrDefNames global lyrNames --- Define globals--- lyrDefNames=#() lyrNames=#() ---The function to create layers--- fn crtNewLayer = ( for n = 1 to lyrNames.count do ( i= n x= lyrNames y= layermanager.getlayerfromname x [i] z= layermanager.newlayerfromname x [i] if y != undefined then z ) ) ---Rollout for interface of script--- rollout LayerCreator "LayerCreator 1.0" width:280 height:208 ( GroupBox Layers "Select Layers for Scene Objects" pos:[8,40] width:264 height:112 checkbox lyrCameras "Cameras" pos:[144,88] width:120 height:24 checkbox lyrController "Controller Objects" pos:[16,88] width:120 height:24 checkbox lyrHiden "Hiden Objects" pos:[16,120] width:120 height:24 checkbox lyrLights "Light Objects" pos:[144,56] width:120 height:24 checkbox lyrMesh "Mesh Objects" pos:[16,56] width:120 height:24 checkbox lyrParticles "Particles" pos:[144,120] width:120 height:24 edittext lyrBsName " Base Name of Layers" pos:[13,7] width:254 height:17 enabled:false button crtLayers "Create New Layers" pos:[8,160] width:264 height:37 enabled:true toolTip:"" --- The function to enable edittext because at least one checkbox should be checked before enter a word in edittext line ---- fn txtEnbl= ( cb=#( lyrCameras.triState, lyrController.triState, lyrHiden.triState, lyrLights.triState, lyrMesh.triState, lyrParticles.triState) for i= 1 to cb.count collect if cb [i] != 1 then ( lyrBsName.enabled= false ) else ( if cb [i] == 1 then ( lyrBsName.enabled= true ) ) ) ---Adding a string by each checkbos to the global lyrDefNames ---- on lyrCameras changed theState do ( txtEnbl () if lyrCameras.checked == true then ( objCameras= "_Cameras" append lyrDefNames objCameras ) else ( lyrDefNames [1] = undefined ) ) on lyrController changed theState do ( txtEnbl () if lyrController.checked == true then ( objController= "_Controller" append lyrDefNames objController ) else ( lyrDefNames [2] = undefined ) ) on lyrHiden changed theState do ( txtEnbl () if lyrHiden.checked == true then ( objHiden= "_Hiden" append lyrDefNames objHiden ) else ( lyrDefNames [4] = undefined ) ) on lyrLights changed theState do ( txtEnbl () if lyrLights.checked == true then ( objLights= "_Lights" append lyrDefNames objLights ) else ( lyrDefNames [5] = undefined ) ) on lyrMesh changed theState do ( txtEnbl () if lyrMesh.checked == true then ( objMesh= "_Mesh" append lyrDefNames objMesh ) else ( lyrDefNames [3] = undefined ) ) on lyrParticles changed theState do ( txtEnbl () if lyrParticles.checked == true then ( objParticles= "_Particles" append lyrDefNames objParticles ) else ( lyrDefNames [6] = undefined ) ) --- Adding a sting when text entered to the text line --- on lyrBsName entered txt do ( bsName= lyrBsName.text as string cmbNames= ( if bsName != "" then ( if lyrDefNames != undefined then ( for i= 1 to lyrDefNames.count collect append lyrNames (bsName + lyrDefNames [i]) ) ) else ( if bsName =="" then ( lyrNames= #() ) ) ) ) --- When button pressed creating layers--- on crtLayers pressed do crtNewLayer () ) createdialog LayerCreator
Comments
BTW
@Deman3D
I not tested this tool and I leave it to you to check that.
Cheers!
bga
lyrDefNames=#()
I arrange the code a little, check it, hope it helps
Thanks
Your script codes are very helpful to understand how I should create a loop for my purpose.
Thank you very much.
...
I arranged a bit more ei. I clean up the mess
;)
Just joking...
Anyway it's more convinient this way. You can see all names in the list before layers creation
bga
Thanks.
Thank you very much for your script you created to me. Yes your codes are much better than mine and properly work but as you can understand I am trying to learn maxscript to support my workflow on 3ds max. I will examine your script detailed and they are very precious to me while I try to learn something more.
Regards.
...
My pleasure. If you not understand something in my code just ask, but before that try to find answers in maxscript help document. It's better that way if you want to learn and understand why or how things works. We all started that way.
If you not already watched this video training just take a look http://vimeo.com/album/1514565
bga