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

Select Editable Poly instead of Modifier as Default

5 REPLIES 5
Reply
Message 1 of 6
ritterknight
473 Views, 5 Replies

Select Editable Poly instead of Modifier as Default

I am wondering if there is a way to automatically select the Editable Poly when I select an object instead of it selecting the top modifier in the modifier stack.

 

Labels (1)
5 REPLIES 5
Message 2 of 6
darawork
in reply to: ritterknight

Hi,

 

Very good question. This always annoys me too. I use the top row of keyboard numbers to navigate the sub-object level selections. But I always have to use the mouse to get to the edit poly / edit mesh modifier.

I found this, but all the download links were dead.

https://www.scriptspot.com/3ds-max/scripts/modifier-auto-select

* I found the MZP after some extensive searching so make sure to have virus scanning on 3dsmax active.
** Save a backup of your ENU folder and the current project you're working on before testing it out  (C:\Users\YourUserName\AppData\Local\Autodesk\3dsMax\**** – 64bit\ENU).

If you need help on customising 3DSMax with custom MaxScript code, look here:
https://knowledge.autodesk.com/support/3ds-max/learn-explore/caas/CloudHelp/cloudhelp/2021/ENU/3DSMa....

 

/*
Tool Name: 'Modifier Auto-Select'

Tool by: Mathieson Facer
E-mail: info@mathiesonfacer.com
Website: www.mathiesonfacer.com
Start Date: August 24, 2009
	
History:
	February 28, 2010 - v2.02
		- Fixed typo in selectModifier function. Was passing argument to navigateModStack function as
		findMod when in the navigateModStack definition it was actually findModifier. Was causing tool
		not to work with multiple nodes selected.
	February 26, 2010 - v2.01
		- Made it so with multiple selected objects, if it doesn't find the modifier instance
		after walking down the stack, it walks back up to the top so the user doesn't have
		the bottom modifier auto-selected.
	February 25, 2010 - v2.0
		- Cleaned up code for re-release.
		- Added functionality when multiple nodes selected.
		- Made selectModifier and selectBaseobject two different functions.
To Do:
	- To do list goes here.		
Bugs:
	- List of bugs goes here.
Testing:

Test code can be placed in this area.

*/

struct MJF_modifierAutoSelect
(
	uiInst,
	
	selectionTimer = dotNetObject "System.Windows.Forms.Timer" ,
	storedModClass = "Baseobject",
	
	fn createUi =
	(
		uiInst = rollout modifierAutoSelectR "Modifier Auto-Select - facerFX Tools" width:200
		(
			local rW = 200
			local w1 = rW * .875
			local w2 = w1 / 2
			local w3 = w1 / 3
			local spnW1 = 50
			
			dropdownlist modClassDdl items:#() width:(w1 * .7) height:20 align:#left across:2
			button refreshModsBtn "Refresh" width:(w1 * .28) align:#right
			checkbox searchNameCbx "Has string:" align:#left across:2
			edittext searchNameEtb align:#right width:(w2 * 1.17)
			checkbutton enableCbt "Auto-Select Enabled" width:w1 align:#center
			
			fn getModClassesAsStrings =
			(
				local sceneMods = #()
				for x in objects do sceneMods += x.modifiers
				
				local modClassStrings = for x in sceneMods collect (classOf x) as string
				modClassStrings = makeUniqueArray modClassStrings
				append modClassStrings "Baseobject"
				sort modClassStrings
			)
			
			fn toggleAutoSelect state =
			(
				MJF_modifierAutoSelect.enableCallbacks state
				
				if state == false then
				(
					MJF_modifierAutoSelect.selectionTimer.stop()
				)
			)
			
			fn updateUi =
			(
				local modClasses = getModClassesAsStrings()
				modClassDdl.items = modClasses
				
				local modIndex = findItem modClasses MJF_modifierAutoSelect.storedModClass
				modClassDdl.selection = case modIndex of
				(
					0: 1
					default: modIndex
				)
			)
			
			on modClassDdl selected val do
			(
				MJF_modifierAutoSelect.storedModClass = modClassDdl.selected
			)
			
			on refreshModsBtn pressed do
			(
				updateUi()
			)
			
			on enableCbt changed val do
			(
				toggleAutoSelect val
			)
			
			on modifierAutoSelectR open do
			(
				updateUi()
			)
			
			on modifierAutoSelectR close do
			(
				toggleAutoSelect false
			)
		)
	),
	
	fn launchUi =
	(
		if classOf uiInst == RolloutClass then destroyDialog uiInst
		
		createDialog uiInst style:#(#style_titlebar, #style_border, #style_sysmenu)
	),
	
	fn enableCallbacks state =
	(
		callbacks.removeScripts id:#MJF_modifierAutoSelect
		
		if state then
		(
			callbacks.addScript #selectionSetChanged \
				"MJF_modifierAutoSelect.startSelectionChangeTimer()" \
				id:#MJF_modifierAutoSelect
		)
	),
	
	fn selectBaseobject objs =
	(
		if (objs.count == 1) then
		(
			local baseobject = objs[1].baseobject
			
			if (modPanel.getCurrentObject()) != baseobject then
			(
				modPanel.setCurrentObject baseobject node:objs[1]
			)
		)
	),
	
	fn getModsFromObjs objs modClass =
	(
		local allMods = #()
		for x in objs do allMods += x.modifiers
		
		local theMods = for x in allMods where (classOf x == modClass) collect x
		
		-- This filters for only the modifiers with the matching string pattern in the name.
		if uiInst.searchNameCbx.state then
		(
			theMods = for x in theMods where \
				(matchPattern x.name pattern:("*" + uiInst.searchNameEtb.text + "*")) collect x
		)
		
		-- This filters out any modifiers that do not have an instance on all supplied nodes.
		for i = theMods.count to 1 by -1 do
		(
			local deleteMod = false
			
			for x in objs do
			(
				if ((findItem x.modifiers theMods[i]) == 0) then
				(
					deleteMod = true
				)
			)
			
			if deleteMod then
			(
				deleteItem theMods i
			)
		)
		
		theMods
	),
	
	fn navigateModStack direction:#down findModifier: =
	(
		local lastMod = undefined		-- Needed to check if we're at the end of the modifier stack.
		while (modPanel.getCurrentObject() != findModifier) and \
			(modPanel.getCurrentObject() != lastMod) do
		(
			lastMod = modPanel.getCurrentObject()
			case direction of
			(
				#down: max prev mod
				#up: max next mod
			)
		)
	),
	
	fn selectModifier objs modClassStr =
	(
		/*
		<DOC> Selects the modifier of the specified class from the currently selected node.  Doesn't work with multiple nodes selected.
		Arguments:
			<array> objs:	An array of nodes.  Needs to be an array since it will work with "selection".
			<modifier> modClassStr:	Class of a modifier to auto-select.
		Return:
			Does not return anything.
		*/
		
		local modClass = execute modClassStr
		
		if (modClass != undefined) then
		(
			local theMod = (getModsFromObjs objs modClass)[1]
			
			if (isValidObj theMod) then
			(
				if (objs.count == 1) then
				(
					if (modPanel.getCurrentObject() != theMod) then
					(
						modPanel.setCurrentObject theMod node:objs[1]
					)
				)
				else if (objs.count > 1) then
				(
					navigateModStack findModifier:theMod
					
					if (modPanel.getCurrentObject() != theMod) then
					(
						navigateModStack direction:#up
					)
				)
			)
		)
	),
	
	fn initTimer =
	(
		-- This function is out of scope because it is being called through the timer. Need to call anything
		-- in the struct through the struct instance.
		fn callSelectMod =
		(
			if (MJF_modifierAutoSelect.storedModClass == "Baseobject") then
			(
				MJF_modifierAutoSelect.selectBaseobject (selection as array)
			)
			else
			(
				MJF_modifierAutoSelect.selectModifier (selection as array) MJF_modifierAutoSelect.storedModClass
			)
			MJF_modifierAutoSelect.selectionTimer.stop()
		)
		
		dotnet.addEventHandler MJF_modifierAutoSelect.selectionTimer "tick" callSelectMod
		MJF_modifierAutoSelect.selectionTimer.interval = 1
	),
	
	fn startSelectionChangeTimer =
	(
		/*
		<DOC> Rollout and timer required to call the selectMod function above because of an issue with the callback mechanism.
		Arguments:
			<array> objs:	An array of nodes.  Needs to be an array since it will work with "selection".
			<modifier> modifier:	Class of a modifier to auto-select.
		Return:
			Does not return anything.
		*/
		
		selectionTimer.start()
	)
)
MJF_modifierAutoSelect = MJF_modifierAutoSelect()
MJF_modifierAutoSelect.createUi()
MJF_modifierAutoSelect.initTimer()

-- MJF_modifierAutoSelect.launchUi()

 


Regards,

Darawork
AutoDesk User
Windows 10/11, 3DS Max 2022/24, Revit 2022, AutoCad 2024, Dell Precision 5810/20, ASUS DIY, nVidia Quadro P5000/RTX 5000/GTX760

Message 3 of 6
darawork
in reply to: darawork

Hi,

 

Doesn't seem to be working with 3DSMax 2023 (latest update) 😞

darawork_0-1671136944333.png


But maybe someone who knows Maxscript better than me (thousands of people), might be able to fix the code?
https://forums.autodesk.com/t5/3ds-max-programming/bd-p/area-b35

Regards,

Darawork
AutoDesk User
Windows 10/11, 3DS Max 2022/24, Revit 2022, AutoCad 2024, Dell Precision 5810/20, ASUS DIY, nVidia Quadro P5000/RTX 5000/GTX760

Message 4 of 6
ritterknight
in reply to: ritterknight

My solution as of now is to set a hot key for the "next modifier"  "previous modifier."

It adds an extra push of the finger, but it's better than having to click with the mouse.

I'm surprised code would be needed for something that seems like it would be intuitive and necessary for even a newbie like me to have decent speed in work flow.

Thanks again for your responces.

Message 5 of 6
darawork
in reply to: ritterknight

Hi,

I didn't realise that there was a hotkey assignable function for 'Modifier List Up/Down' Cool.
Thanks for the tip. I'll set it up here. 

Sorry the Maxscript didn't work, looks promising.
Maybe needs a bit of looking at so as to work with 2023.

It would be a nice feature addition though, if the user could set 'Edit Poly or Edit Mesh' to float top the top of the stack, if requested to do so as default.

Regards,

Darawork
AutoDesk User
Windows 10/11, 3DS Max 2022/24, Revit 2022, AutoCad 2024, Dell Precision 5810/20, ASUS DIY, nVidia Quadro P5000/RTX 5000/GTX760

Message 6 of 6
ritterknight
in reply to: ritterknight

Agreed that would be really nice feature to have.  I'm glad I could help with the hotkey though. I've got a mouse with lots of buttons, so it doesn't waste too much time spamming my thumb to get to the edit poly ha.

Thanks again for the recommendations.

 

Best

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report