PolyToolsModeling : GlobalUtilityPlugin

 

   

Graphite Modeling Tools - Quick Navigation

The PolyToolsModeling Global Utility Plugin introduced in 3ds Max 2011 exposes an interface that provides MAXScript access to the Graphite Modeling tools.

The functionality was first implemented in 3ds Max 2010 using different functions that were not officially supported as MAXScript tools. This interface consolidates all relevant properties and methods in one place and let MAXScript users apply them in their own tools.

Topic Navigation:  

Loops Panel

Edges Panel

Geometry (All) Panel

Polygons Panel

Loop Tools

Symmetry

Other Modeling Methods

Constructor:

Class instances not creatable by MAXScript

PolyToolsModeling interfaces:

Interface:  PolyToolsModeling

Methods:

Loops Panel

<bool>PolyToolsModeling.DistanceConnect () 		

Creates connections between sub-object elements across distance and other topology.

Sub-Object Level

Function

Polygon

Not supported

Edge

Select two edges and apply to make a connection between them that is going across the mesh between them.

Vertex

Select two end vertices and apply to make a connection between them that is going across the mesh between them.

EXAMPLE

Connecting two selected edges over distance:

--Step 1:
p = plane lengthsegs:10 widthsegs:10wirecolor:blue
convertTo p Editable_Poly
select p
max modify mode
subObjectLevel = 2
polyOp.setEdgeSelection p #{76,92}
--Step 2:
PolyToolsModeling.DistanceConnect ()
 

<bool>PolyToolsModeling.RemoveLoop () 	 

Removes a loop in the current sub-object level and automatically removes any left over vertices.

Sub-Object Level

Function

Polygon

Select two or more polygons and apply to remove whole rows of polygons.

Edge

Select one or more edges and apply to remove the loops which the selected edges is on.

Vertex

Select two or more vertices and apply to remove loops of vertices.

EXAMPLE

Removing Edge Loops using two Polygons, one Edge and two Vertices:

--Step 1:
p = plane lengthsegs:10 widthsegs:10 wirecolor:blue --create a plane
convertTo p Editable_Poly --convert the plane to Editable_Poly
select p --select the plane to be able to see the results
max modify mode --switch Command Panel to Modify mode
subObjectLevel = 4 --switch topolygonsub-object level
polyOp.setFaceSelection p #{22,23} --select two polygons to define the loops
--Step 2:
PolyToolsModeling.RemoveLoop () --remove the loops defined by the two polygons 
 

--Step 3:
subObjectLevel = 2 --switch to edge sub-object level
polyOp.setEdgeSelection p #{101} --select one edge
--Step 4:
PolyToolsModeling.RemoveLoop() --remove the loop defined by the one edge 
 

--Step 5:
subObjectLevel =1 --switch tovertexsub-object level
polyOp.setVertSelection p #{101} --select teo vertices
--Step 6:
PolyToolsModeling.RemoveLoop () --remove the loop defined by the two vertices 
 

<bool>PolyToolsModeling.SetFlow <bool>autoLoop   

Automatically fits selected edges or verticesto the surrounding flow of the mesh.

If autoLoop is supplied as true, a full edge loop will be created in Edge sub-object level.

Sub-Object Level

Function

Polygon

Not supported

Edge

Select oneor more edges and apply to fit to surrounding topology.

Vertex

Select oneor more vertices and apply to fit to surrounding topology.

<bool>PolyToolsModeling.SetFlowVertex ()

Automatically fits selected vertice to the surrounding flow of the mesh.

   

<bool>PolyToolsModeling.BuildEnd ()

Inserts 2 loops and builds a quad ending on both endings.

Sub-Object Level

Function

Polygon

Not supported

Edge

Select edges in a row (edge ring) and call this method to insert 2 loops connecting the selected edges and build quad endings.

Vertex

Select 2 vertices at the ends of two parallel loops and apply to build quad end.

<bool>PolyToolsModeling.BuildCorner ()

Builds a quad corner based on vertex selection to make an edge loop turn.

Sub-Object Level

Function

Polygon

Not supported

Edges

Select one or more edges at the corner of an edge loop and apply to build quad corner.

Vertex

Select 2 vertices and apply to build quad corner.

<bool>PolyToolsModeling.RandomConnect <float>jitter <bool>autoLoop

Connects edges and randomizes the position of the newly created vertex within each edge.

Returns true on success, false on failure (for example if called while not in Edge Sub-Object Level).

The first argument controls the Random Jitter factor.

  • A jitter value of 0 produces a connection through the centers of the selected egses without any randomness.

  • A value of 0.5 jitters the position of the new vertices within the length of the edge (between its two vertices).

  • Values above 0.5 will produce vertices outside the selected edge, potentially causing polygon overlaps and z-fighting geometry.

The second argument controls whether the initial selection should be expanded to neighbor edge loops to facilitate connecting when the initial selection is not enough to produce any.

  • If set to false, connections will be produced only within the initial selection.

  • If set to true, the initial selection will be expanded first by selecting edge rings from the existing selected edge loops, then the resulting selection will be used to create the random connections.

EXAMPLE

Random Connecting Within a 10x10 Grid using autoLoop passed as true:

--Step 1:
p = plane lengthsegs:10 widthsegs:10 wirecolor:blue --create a plane
convertTo p Editable_Poly --convert the plane to Editable_Poly
select p --select the plane to be able to see the results
max modify mode --switch Command Panel to Modify mode
subObjectLevel =2 --switch to polygonsub-object level
polyOp.setEdgeSelection p #{82} --select one edge to define a loop
--Step 2:
PolyToolsModeling.RandomConnect 0.3 true --create loops and connect randomly 
 

Note that although there was just a single edge selected, the AutoLoop second argument set to true produced an edge ring from the selected edge, then performed the random connect over the new selection. With autoLoop false, no connection edges would have been created.

--Step 3:
PolyToolsModeling.RandomConnect 0.3 true --create loops and connect randomly
--Step 4:
PolyToolsModeling.RandomConnect 0.3 true --create loops and connect randomly 
 

In the third step, we start once again from a single edge loop which, if used with autoLoop set to false, would not produce any connections. Now we produce a large number of parallel random loops, but they are "blocked" by unselected straight edgeloops which would once again produce no connections if autoLoop would be passed as false in the fourth step.

 

EXAMPLE

Random Connecting Within a 10x10 Grid using autoLoop passed as false:

--Step 1:
p = plane lengthsegs:10 widthsegs:10 wirecolor:blue --create a plane
convertTo p Editable_Poly --convert the plane to Editable_Poly
select p --select the plane to be able to see the results
max modify mode --switch Command Panel to Modify mode
subObjectLevel =2 --switch to polygon sub-object level
polyOp.setEdgeSelection p #{80,82,84,86,88} --select edges to define a ring
--Step 2:
PolyToolsModeling.RandomConnect 0.5 false --connect selected only 
 

In this particular case, our initial selection already contains enough edges in a ring to create a valid random connection. We don't want the selected edge ring to be expanded further, so we pass false as the second argument, producing a random connection only within the existing selection!

Edges Panel

<bool>PolyToolsModeling.SpinEdge <bool>alternativeDir

Spins the selected edge/edges in the polygon, changing their direction.

Returns true on success, false on failure.

Sub-Object Level

alternativeDir = false

alternativeDir = true

Polygon

Not supported

Not supported

Edge

Select edge/edges and apply to spin edges clockwise.

Select edge/edges and apply to spin edges counter-clockwise.

Vertex

Not supported

Not supported

<bool>PolyToolsModeling.InsertVertex <integer>number

Inserts the specified number of vertices in the selected edges. The inserted vertices are evenly spaced along the edge.

Returns true on success, false on failure.

Sub-Object Level

Function

Polygon

Not supported

Edge

Select an edge and apply to insertvertices on the selected edge/edges.

Vertex

Not supported

Geometry (All) Panel

<bool>PolyToolsModeling.Quadrify <bool>withinSel <bool>selectOnly

Remove triangulation from the model to achieve mainly four sided polygons.

When withinSelis set to true, applies to the current sub-object selection only.

When selectOnly is set to true, does not remove but only selects the edges to be removed.

Returns true on success, false on failure.

Polygons Panel

<bool>PolyToolsModeling.GeoPoly ()

Untangles a polygon and organizes the vertices to form a perfect geometric shape.

Sub-Object Level

Function

Polygon

Selectpolygons and apply to make geometric shape. If several adjacent polygons are selected the result will be averaged between the polygons.

Edge

Not supported

Vertex

Not supported

Loop Tools

<bool>PolyToolsModeling.CenterLoop <bool>autoLoop

Centers edges or edgeloops on the edgerings they are on and places the vertices in the middle of the edges.

Select an edge or more edges and apply.

If the autoLoop argument is true , the selection will be automatically looped.

   

<bool>PolyToolsModeling.SpaceLoop <bool>autoLoop

Spaces the vertices evenly along the selected edges/edgeloops so that the distances between the vertices become equal.

If the autoLoop argument is true, the selection will be automatically looped.

If the SHIFT key is pressed while this method is being executed, it will also be able to space loops on the top and bottom of a cylinder.

   

<bool>PolyToolsModeling.CurveLoop <bool>autoLoop <bool>spaceLoop

Adjusts each set of selected edges/edgeloops into smooth curves.

The curvature of each loop is determined by the position of the selected vertices along the loop. Think of the curve you would create as a spline going from the endpoints of the edges/loop with a smoothly interpolated spline knot at each selected vertex.

If the autoLoop argument is true , the initial selection will be automatically looped before the tool is applied.

If the spaceLoop argument is true , all vertices will be evenly spaced along the loop.

If the spaceLoop argument is false , the initial relationship between vertices on the loop will be kept.

NOTE:

The edgeloop selection should not be closed (like a circle)for this tool to work since there needs to be a start and end-point fora curve.

The actual edgeloop can be closed but not the selected edgeloop.

   

<bool>PolyToolsModeling.StraightLoop <bool>autoLoop <bool>spaceLoop

Straightenseach set ofselected edges/edgeloops into straight lines.

If any of the vertex "endpoints" of the set of edges/edgeloop are selected the line will go from the first edge that the selected vertex is on and straight out from that edge. If no vertices are selected the line will go between the two endpoints of the edges/edgeloop.

If the autoLoop argument is true , the initial selection will be automatically looped before the tool is applied.

If the spaceLoops argument is true , all vertices will be evenly spaced along the loop.

If the spaceLoops argument is false , the initial relationship between vertices on the loop will be kept.

If the SHIFT key is pressed while this method is being executed, it will also be able to straighten loops on the top and bottom of a cylinder.

   

<bool>PolyToolsModeling.CircleLoop <bool>autoLoop

Turns each set of selected edges/edgeloops into the form of a circle.

The selected vertex along each loop determines the beginning point for the circle.

For open loops one of the "endpoints" of the edges/loop should be selected.

For closed loops(like around a cylinder)the vertex you want to least have change position should be selected.

If the autoLoop argument is true , the initial selection will be automatically looped before the tool is applied.

If the SHIFT key is pressed while this method is being executed, it will also be able to circle loops on the top and bottom of a cylinder.

Tip: It can be good to make sure that the vertex next after the first on the loop goes in the general direction of the intended circle to make sure that the circle is not "inverted".

   

<bool>PolyToolsModeling.RelaxLoop <bool>autoLoop

Relaxes/smooths out the curvature of each set of selected edges/edgeloops.

Call multiple times to relax more.

If the autoLoop argument is true, checked the initial selection will be automatically looped before the tool is applied.

If the SHIFT key is pressed while this method is being executed, it will also be able to relax loops on the top and bottom of a cylinder.

   

Symmetry

<bool>PolyToolsModeling.SymmetryGather <node>node <value>axis <float>threshold

Collects symmetry data from the node specified as first argument.

The second argument defines the symmetry axis as name- #x, #y or #z

The third argument defines the position variation threshold to use when searching for symmetry vertices.

   

<bool>PolyToolsModeling.SymmetryPosToNeg <value>axis

Copies the vertex positions from the positive side of the symmetry axis to the negative side.

The axis argument can be either #x, #y or #z.

Corresponds to the "+To-" button in the Symmetry Tools floating dialog.

   

<bool>PolyToolsModeling.SymmetryNegToPos <value>axis

Copies the vertex positions from the negative side of the symmetry axis to the positive side.

The axis argument can be either #x, #y or #z.

Corresponds to the "-To+" button in the Symmetry Tools floating dialog.

   

<bool>PolyToolsModeling.SymmetryFlip <value>axis

Swaps the symmetry data about the specified axis.

   

<bool>PolyToolsModeling.SymmetryCopy ()

Copies the vertex positions of the currently selected vertices into an internal "clipboard".

   

<bool>PolyToolsModeling.SymmetryPaste ()

Pastes the vertex positions back onto the same vertices, even if not selected.

EXAMPLES

Using the Symmetry methods:

--Step 1:
s = sphere radius:12 segs:32 wirecolor:blue
convertTo s Editable_Poly
select s
max modify mode
subObjectLevel = 1
PolyToolsModeling.SymmetryGather s #x 0.01
 
--Step 2:
PolyOp.moveVert s #{122} [5,0,5]
--Step 3:
PolyToolsModeling.SymmetryPosToNeg #x
 

--Step 4:
PolyOp.moveVert s # {170} [-5,0,0]
--Step 5:
PolyToolsModeling.SymmetryNegToPos #x
 

--Step 6:
PolyOp.moveVert s #{58} [3,0,5]
--Step 7:
PolyToolsModeling.SymmetryFlip #x
 

--Step 8:
PolyOp.setVertSelection s #{122,170}
PolyToolsModeling.SymmetryCopy()
PolyOp.moveVert s #{122,170} [5,0,-20]
--Step 9:
PolyToolsModeling.SymmetryPaste()
 

Other Modeling Methods

<bool>PolyToolsModeling.MultiHide ()

Hides either selected polygons or selected vertices based on the current sub-object level.

Sub-Object Level

Function

Polygon

Select polygons and apply to hide them.

Edge

Not supported

Vertex

Select vertices and apply to hide them.

<bool>PolyToolsModeling.RotateSelection <float>degree <integer>coordsys <point3>viewDirection

Rotates the current sub-selection at the specified degree in the coordinate system defined by the second argument counter-clockwise relatively to the view direction specified by the third argument.

Returns true on success, false on failure, for example if not in a sub-object level.

EXAMPLE

Rotating Polygon Selection at 30 degrees CCW:

--Step 1:
p = plane lengthsegs:10 widthsegs:10 wirecolor:blue --create a plane
convertTo p Editable_Poly --convert the plane to Editable_Poly
select p --select the plane to be able to see the results
max modify mode --switchCommand PaneltoModify mode
subObjectLevel = 4 --switch topolygonsub-object level
polyOp.setFaceSelection p #{22,23} --select two polygons to define the loops
--Step 2:
PolyToolsModeling.RotateSelection 30 1 -(viewport.getTM()).row3
 

<bool>PolyToolsModeling.MirrorElement <value>axis <bool>clone

Mirror the selected element about the specified axis.

If the clone argument is passed as true, the element will be duplicated.

If the clone argument is false, the original element will be mirrored.

Returns true on success, false on failure.

   

<integer>PolyToolsModeling.CreateFace <bitArray>bitarray

Creates a Polygon from the vertex indices provided by the bitarray argument.

Returns the index of the new polygon.

   

See Also