Community
3ds Max Programming
Welcome to Autodesk’s 3ds Max Forums. Share your knowledge, ask questions, and explore popular 3ds Max SDK, Maxscript and Python topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Tab into edit mode (like Blender)

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
Intuos5
1523 Views, 6 Replies

Tab into edit mode (like Blender)

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:

  1. Enter subobject mode in the last used sub-object level, otherwise default to edges
  2. Exit sub-object mode and go to object mode (This works as is)
  3. Have it check whether a modeling command is active, in which case the Tab key would be free to use to cycle active snaps.

Any help would be much appreciated!

6 REPLIES 6
Message 2 of 7
Swordslayer
in reply to: Intuos5

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
)

 

Message 3 of 7
Intuos5
in reply to: Swordslayer


@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 ;).

 


 

 

 

 

Message 4 of 7
Swordslayer
in reply to: Intuos5

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.

Message 5 of 7
Intuos5
in reply to: Swordslayer

@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.

Message 6 of 7
Swordslayer
in reply to: Intuos5

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.

Message 7 of 7
Intuos5
in reply to: Swordslayer

@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.

Post to forums  

Autodesk Design & Make Report