ScriptSpot

Forum topic · General Scripting

Help me get this script work in Edit Poly Modifier

By pedroamorim · 2015-02-25

Description

Right now I have this script and it works perfectly in Editable Poly. But I decided to update it to work in Edit Poly as well.

It's not working very well :)

This is a smart script that I have assigned to a single key and does diferent things depending on subobject and number of things selected.

 


macroScript SuperSmartCreate
category:"Pedro Scripts"
toolTip:"Super Smart Create"

(
	local curObj = modPanel.getCurrentObject()
	Case (classOf curObj) of
	(
		Edit_Poly:
		(Case subobjectlevel of
			(
			 1: ($.modifiers[#Edit_Poly].ButtonOp #ConnectVertices)

			 2:	(if (((curObj.getSelection #edge) as array).count == 0) then
				 (
					messagebox "Put the create face code here."
				 )

				 local doBridgeConnect = false
				 Edgs = curObj.GetSelection #edge as array
				 case (Edgs.count) of
				 (
					1: (
						--Inserts a vertex in the selected edge
						curObj.divideEdge (Edgs[1]) 0.5
						curObj.commit()
						subobjectLevel = 1
					)
					2: (
						(
							EdgA = PolyOp.getEdgeVerts  curObj Edgs[1]
							EdgB = PolyOp.getEdgeVerts  curObj Edgs[2]
							if (EdgA[2]==EdgB[1]) then
							(
								curObj.CreateFace #(EdgA[1],EdgA[2],EdgB[2])
							) else
							if (EdgB[2] == EdgA[1]) then
							(
								curObj.CreateFace #(EdgB[1],EdgB[2],EdgA[2])
							) else
							  (
								  doBridgeConnect = true
							  )
						)
					)
					default: ( doBridgeConnect = true )
				 )
				 if doBridgeConnect then
				 (
					 curObj.bridgeSelected = 1
					 if not (curObj.EditablePoly.Bridge()) then
					 (
						 --curObj.connectEdgeSegments = 1
						 $.modifiers[#Edit_Poly].ButtonOp #ConnectEdges
					 )
				 )
			 )

			 3:	($.modifiers[#Edit_Poly].ButtonOp #Cap)

			 4:	(if (((curObj.getSelection #face) as array).count < 2) then
					 messagebox "Put the create face code here."
                 else
					(
						$.modifiers[#Edit_Poly].ButtonOp #BridgePolygon
					)
                )

			 5:()
			)
		)



		Editable_poly:
		(Case subobjectlevel of
			(
			 1: (curObj.EditablePoly.ConnectVertices ())

			 2:	(if (((polyop.getEdgeSelection $.baseobject) as array).count == 0) then
				 (
					macros.run "Editable Polygon Object" "EPoly_ECreate"
				 )

				 local doBridgeConnect = false
				 Edgs = polyop.GetEdgeSelection $ as array
				 case (Edgs.count) of
				 (
					1: (
						--Inserts a vertex in the selected edge
						curObj.EditablePoly.divideEdge (Edgs[1]) 0.5 select:on
						subobjectLevel = 1
					)
					2: (
						(
							EdgA = PolyOp.getEdgeVerts  curObj Edgs[1]
							EdgB = PolyOp.getEdgeVerts  curObj Edgs[2]
							if (EdgA[2]==EdgB[1]) then
							(
								curObj.CreateFace #(EdgA[1],EdgA[2],EdgB[2])
							) else
							if (EdgB[2] == EdgA[1]) then
							(
								curObj.CreateFace #(EdgB[1],EdgB[2],EdgA[2])
							) else
							  (
								  doBridgeConnect = true
							  )
						)
					)
					default: ( doBridgeConnect = true )
				 )
				 if doBridgeConnect then
				 (
					 curObj.bridgeSelected = 1
					 if not (curObj.EditablePoly.Bridge()) then
					 (
						 curObj.connectEdgeSegments = 1
						 curObj.EditablePoly.ConnectEdges ()
					 )
				 )
			 )

			 3:	(curObj.EditablePoly.capHoles #Edge)

			 4:	(if ((($.GetSelection #Face) as array).count < 2) then
					 macros.run "Editable Polygon Object" "EPoly_Create"
                 else
					(
						$.bridgeSelected = 1
						$.EditablePoly.Bridge ()
					)
                )

			 5:()
			)
		)




		unwrap_uvw:
		(Case SubobjectLevel of
			(
			1: ()
			2: ()
			3: ()
			)
		)
	)
)

Comments (2)

different methods for Edit_Poly

pixamoon · 2015-02-27

Hi,

There are different functions, methods for Edit_Poly Modifier.
You can find everything in max script help.

For example to get vertices:

Editable_Poly:
EdgA = PolyOp.getEdgeVerts curObj Edgs[1]

Edit_Poly:
EdgA[1] = #()
EdgA[1] = curObj.GetEdgeVertex Edgs[1] 1
EdgA[2] = curObj.GetEdgeVertex Edgs[1] 2

end so on...

I changed some stuff in code, so connect edges works now, but you need to finish other parts. Please see attached.

Hope this helps :)
Pixamoon

Attachments