With regards to this idea post, I figured it would be nice to create a new forum thread to create a basic Maxscript definition to mimick Blender. The Maxscript also simplifies transitioning to a newer version of Max by moving the script over.
What I would like to do is to define Tab to enter/exit subobject mode and set the 1/2/3/4/5 keys to correspond to scripts with: subobjectLevel =1/2/3/4/5 in the hotkeyeditor, so I won't accidentally exit out of subobject editing mode.
Like @Swordslayer advised me to do.
macroScript ObjectLevel
category: "Sub-objectlevel"
buttonText: "Objectlevel"
(subobjectLevel = 0
)
macroScript SubobjectLevel1
category: "Sub-objectlevel"
buttonText: "SubobjectLevel1"
(subobjectLevel = 1
)
macroScript SubobjectLevel2
category: "Sub-objectlevel"
buttonText: "SubobjectLevel2"
(subobjectLevel = 2
)
macroScript SubobjectLevel3
category: "Sub-objectlevel"
buttonText: "SubobjectLevel3"
(subobjectLevel = 3
)
macroScript SubobjectLevel4
category: "Sub-objectlevel"
buttonText: "SubobjectLevel4"
(subobjectLevel = 4
)
macroScript SubobjectLevel5
category: "Sub-objectlevel"
buttonText: "SubobjectLevel5"
(subobjectLevel = 5
)
My question is: I like to use Tab to cycle through active snaps (like in Revit) and I assigned it like that in Blender too. How do I define the objectlevel macroscript further in order for it to:
Any help would be much appreciated!
Solved! Go to Solution.
Solved by Swordslayer. Go to Solution.
This will cycle active snap mode if the left mouse button is currently pressed down (i.e. when you're dragging when you supposedly need it the most), otherwise it will toggle subobject mode on/off (doesn't give preference to edges though).
macroScript ObjectLevel
category: "Sub-objectlevel"
buttonText: "Objectlevel"
(
if mouse.buttonStates[1] then actionMan.executeAction 0 "40906" -- Snaps: Cycle Active Snap Type
else max subobject sel
)
@Swordslayer wrote:This will cycle active snap mode if the left mouse button is currently pressed down (i.e. when you're dragging when you supposedly need it the most), otherwise it will toggle subobject mode on/off (doesn't give preference to edges though).
@Swordslayer That's an interesting idea! So thank you very much for the input sofar! I did find that for tools such as the line and knife tool (which do not require long mouse presses, but only a click to confirm), I cannot cycle snaps. For these tools snap cycling is really important important to me and in that case, the mouse button does not satisfy this condition. I gave it some thought and I think that I may have a logical structure in mind now to achieve my needs.
What I am thinking at the moment is (I don't know if this is technically feasible though) and I don't know the correct syntax either:
The script could check the active command as condition to cycle snaps, which entails:
If(active command =/= selection, cycle snaps, If((subobjectlevel =1/2/3/4/5), objectlevel, subobjectlevel =2)
The idea here is that if selection is the active command, it means any other modeling command is either finished or has been exited out. This seems to be Blender's approach, because you cannot enter/exit (sub)objectmode if another command other than selection is active.
Perhaps subobjectlevel = 2 could be used instead of going to "subobject sel" like you have it, but I guess I'll need to experiment with that for a bit if we could get my proposal to work ;).
max subobject sel will enter into the previous mode you were in, if you were in face mode and you switched to object level, it will return you back to face mode again. If you want to always switch to edge mode, it's doable like this:
macroScript ObjectLevel
category: "Sub-objectlevel"
buttonText: "Objectlevel"
(
if mouse.buttonStates[1] or isCreatingObject() or toolmode.commandMode == #modify then actionMan.executeAction 0 "40906"
else if subObjectLevel != undefined and subObjectLevel > 0 then subObjectLevel = 0
else if (setCommandPanelTaskMode #modify; numSubObjectLevels >= 2) do subObjectLevel = 2
)
I've also added two more alternative conditions to the mousepress, one checks whether an object is currently being created, the other checks whether an interactive modification (like the cut tool) is taking place.
@SwordslayerI did some testing with the script, it works as expected.
It does break when I am in the line command and hit tab to Cycle snaps, rather than cycling snaps, it goes into subobject mode of the previous object. 3ds Max crashes afterwards.
E: If this is something that cannot be solved easily, please let me know. I'm already happy to be able to use subobjectlevel =1/2/3/4/5 and tab to exit. Cycle snaps is bugged in 2020 anyways.
Okay, this is dumb, macros by default create undo record for the whole action, and registering undo at a time when object creation is taking place exits the object creation – so at the start of the macro, new undo starts being recorded, which exits object creation and makes the tests pass and enter subobject mode... The way to prevent that is turn off the explicit undo creation – add the line autoUndoEnabled: off so the macro looks like this:
macroScript ObjectLevel
category:"Sub-objectlevel"
buttonText:"Objectlevel"
autoUndoEnabled:off
(
if mouse.buttonStates[1] or isCreatingObject() or toolmode.commandMode == #modify then actionMan.executeAction 0 "40906"
else if subObjectLevel != undefined and subObjectLevel > 0 then subObjectLevel = 0
else if (setCommandPanelTaskMode #modify; numSubObjectLevels >= 2) do subObjectLevel = 2
)
As for broken snap behavior, it's worth reporting – see the bugreport link in my signature.
@SwordslayerThank you very much! It works like a charm!
I had already reported the bug to the forum, I have sent a bug report just now as well.
Can't find what you're looking for? Ask the community or share your knowledge.