Notifications
Clear all

[Closed] Edge Extrude "Preset" for toolbar

Hey guys!

I use the Extrude tool a lot to create “V” grooves with the same parameters. I need a simple script in which I can define the height and width that will perform an Extrude operation with those values by pressing a button placed in the toolbar.

I’m using Editable Poly objects. If you guys can give me the code so I can duplicate and plug in different values I would be forever grateful! It’s been driving me nuts lol I’m sure it’s dead simple if you know what you’re doing but it’s less simple than say, changing the wire color or material using the Maxscript listener lol

Brandon

5 Replies
1 Reply
(@gazybara)
Joined: 11 months ago

Posts: 0

Because “Extrude Edge” is not exposed in maxscript you can use Edit_Poly modifier.
NOTE: if you not check “Collapse to Poly” checkbox E-Poly modifier will stay on the top.
Also with this tool you can extrude edges of multiple selected objects and delete this modifier from selection


 try(destroyDialog ::bgaRoll)catch()
 rollout bgaRoll "Extrude Edge"
 (
 	spinner spn_height "Height: " pos:[5,5] fieldwidth:60 range:[-1e5,1e5,10]
 	spinner spn_width "Width:  " pos:[5,25] fieldwidth:60 range:[0,1e5,3]
 	checkbox cb_collapse "Collapse To Poly" pos:[5,45]
 	button btn_ext "Extrude" pos:[5,65] width:110
 	button btn_remove "Del Extrude Modifiers" pos:[5,90] width:110
 	on btn_ext pressed do 
 	(
 		if selection.count != 0 do
 		(
 			if getCommandPanelTaskMode() != #create do setCommandPanelTaskMode mode:#create
 			with redraw off
 				for obj in selection where canConvertTo obj Editable_Poly do
 				(
 					addModifier obj (Edit_Poly name:"Extrude Edges" currentOperation:40 extrudeEdgeHeight:spn_height.value extrudeEdgeWidth:spn_width.value)
 					if cb_collapse.checked do convertToPoly obj
 				)
 		)
 	)
 	on btn_remove pressed do
 	(
 		if selection.count != 0 do
 		(
 			if getCommandPanelTaskMode() != #create do setCommandPanelTaskMode mode:#create
 			with redraw off
 				for o in selection where o.modifiers.count != 0 do
 				(
 					for m = o.modifiers.count to 1 by -1 where o.modifiers[m].name == "Extrude Edges" do deleteModifier o m
 				)
 		)
 	)
 )
 createDialog bgaRoll 120 120 10 110 style:#(#style_titlebar, #style_sysmenu, #style_toolwindow)
  

$.edgeExtrudeHeight = -5
$.edgeExtrudeWidth = 0.5
$.EditablePoly.buttonOp #Extrude

Just select all of it and drag it to your button bar. Now you can make an edge selection in your EditPoly, and then click the button to perform the extrusion.

BTW, I found this just by using the macro recorder

@Laserschwert
I was able to see “$.EditablePoly.buttonOp #Extrude” in the listener but not the other two lines. Unfortunately, this didn’t work. It will perform an Extrude operation, but with the values last defined by the settings.

@gazybara
Since I’m working with instances, I’m trying to avoid using modifiers so I don’t have to delete the copy, and mirror it back over.

My hope is that I use this elusive script with one set of values like -4 and 2 for a large groove and create a button for it. Then duplicate it and use the values -2 and 1.5 for a small groove. This way I can simply make my selections, hit one of the two buttons and it just does it without skipping a beat.

What? It works without problems for me… I created two buttons:

$.edgeExtrudeHeight = -4
$.edgeExtrudeWidth = 2
$.EditablePoly.buttonOp #Extrude

and

$.edgeExtrudeHeight = -2
$.edgeExtrudeWidth = 1.5
$.EditablePoly.buttonOp #Extrude

And depending on which one I click, the current edge selection is extruded with either of those values. The first two lines DO set the current settings, the third line executes the extrusion with those settings. This does exactly what you were asking for…

1 Reply
(@system)
Joined: 11 months ago

Posts: 0

Alright, now I feel like an idiot lol I made the mistake of trying to run it in the Listener window lol It would seem that it only ran the last line. Pasted it into a new script and evaluated all and it worked as advertised.

Sorry about that! You were right on the money Thanks man!