Chaos Corona Forum
General Category => General CG Discussion => Topic started by: cjwidd on 2020-06-11, 22:01:57
-
Trying to create a toolbar button to toggle lock / unlock selected objects (including cameras).
This (http://www.scriptspot.com/3ds-max/scripts/lock-cameras-or-objects) script from Maico G. achieves this, but does so within a UI rollout. Given the simplicity of the operation, I'd rather just click a toolbar button once to lock or unlock; or assign to hotkey and toggle lock / unlock from a hotkey.
I've tried revising the script, but have not been successful. Any tips or suggestions are welcome!
(
Rollout caption "LockCamera & Objects" width:168 height:200
(
label lbl1 "Maico G. " pos:[104,160] width:48 height:16
label lbl2 "Lock or unlock the camera movements or objects." pos:[16,29] width:136 height:32
button btn1 "Lock" pos:[35,72] width:95 height:30
groupBox grp2 "Lock" pos:[8,9] width:152 height:176
button btn2 "Unlock" pos:[36,115] width:95 height:30
on btn1 pressed do
setTransformLockFlags $ #all
on btn2 pressed do
setTransformLockFlags $ #none
)
newroll = newrolloutfloater "Lock Camera" 170 220
addRollout caption newroll
)
-
3ds Max maxscript help has some examples, amongst them there are two simple scripts for locking/unlocking objects. I'm using them all the time.
-
link? or script?
EDIT: I think you might be referring to this (http://docs.autodesk.com/3DSMAX/14/ENU/MAXScript%20Help%202012/files/GUID-8EB13535-72B4-439C-94D3-E93434BA163-301.htm) article, but it doesn't address the issue, per se. It does show the code that locks transform flags for an object, and how to disable the flags, but my question really hinges around how to construct an if / else statement - or whatever is required - to toggle the locks.
-
I have two buttons in toolbar, one of them locks transforms, the other one unlocks them. If you want toggle, then you need to modify the script. Sorry, but i can't help you with this.
By the way, i don't see how toggle would be better than two separate commands for this action, unless you want to assign the script to keyboard shortcut and don't want to memorize too many shortcuts.
-
By the way, i don't see how toggle would be better than two separate commands for this action
Yeah, I suppose it's just about parsimony really; it would be convenient to be able to select an arbitrary object and unlock it if it's locked or lock it if it's unlocked by pressing a single button - or better, by pressing a single hotkey.
-
checkbutton is what you want I think.
https://help.autodesk.com/view/3DSMAX/2016/ENU/?guid=__files_GUID_084BC777_9353_455E_A869_9F5C514E0CE6_htm (https://help.autodesk.com/view/3DSMAX/2016/ENU/?guid=__files_GUID_084BC777_9353_455E_A869_9F5C514E0CE6_htm)
this is really rough and will fail if you have nothing selected. I will take a closer look later. hope this helps.
try(destroyDialog ro)catch()
rollout ro "LockObjects"
(
checkbutton btn1 "Lock" width:95 height:30
on btn1 changed state do
(
if state == on then
(
setTransformLockFlags $ #all
)
else setTransformLockFlags $ #none
)
)
createDialog ro 130 40
-
By the way, i don't see how toggle would be better than two separate commands for this action
Yeah, I suppose it's just about parsimony really; it would be convenient to be able to select an arbitrary object and unlock it if it's locked or lock it if it's unlocked by pressing a single button - or better, by pressing a single hotkey.
But what if you select multiple objects with mixed transform lock state, then your toggle will flip their state and you won't have a clue which state particular object has. I think two separate buttons is simpler and more reliable solution.
-
By the way, i don't see how toggle would be better than two separate commands for this action
Yeah, I suppose it's just about parsimony really; it would be convenient to be able to select an arbitrary object and unlock it if it's locked or lock it if it's unlocked by pressing a single button - or better, by pressing a single hotkey.
But what if you select multiple objects with mixed transform lock state, then your toggle will flip their state and you won't have a clue which state particular object has. I think two separate buttons is simpler and more reliable solution.
they cant be flipped since it will always be overridden either with locked or not locked.
But there are other problems with a checkbutton ;)
-
I think two separate buttons is simpler and more reliable solution.
+1