merging/bridging multiple sets of edges hellppeeeee!!!x

139 views
Skip to first unread message

sam williams

unread,
Nov 16, 2014, 4:48:01 PM11/16/14
to python_in...@googlegroups.com
Hi there all!,

im writing a re-topologizing script which is basically bridging and merging a load of specific edges on a large mesh. I have a long list of all the separate sets of edges that need merging. The problem is if i want to modify the code at an earlier stage, or change which edges to merge, it will throw out all the other edges on the list. Suddenly edge number 47 has become edge 53 or something. you get me!?

Also every time i use the command polyBridgeEdge. it selects the edges that were just bridged. Meaning next time i use the polyBridgeEdge command it wont execute until i clear the selection. So i have to do a ridiculous list like this:
 
cmds.polyBridgeEdge( 'Mesh.e[155]', 'Mesh.e[823]', divisions=1 )
cmds.select( clear=True )

cmds.polyBridgeEdge( 'Mesh.e[146]', 'Mesh.e[436]', divisions=1 )
cmds.select( clear=True )

cmds.polyBridgeEdge( 'Mesh.e[123]', 'Mesh.e[523]', divisions=1 )
cmds.select( clear=True )

cmds.polyBridgeEdge( 'Mesh.e[123]', 'Mesh.e[522]', divisions=1 )
cmds.select( clear=True )

i was wondering if anyone else has done a script which requires bridging loads of different edges. Is there a smart way to do this?. Bearing in mind as i develop and refine my script i am constantly changing which edges i am bridging and merging. So it makes the development of my script very tedious, to constantly update the remaining list so that the bridge/merge edge commands aren't picking the wrong edges.



thanks alot guys!x

Risto Jankkila

unread,
Nov 17, 2014, 3:09:54 AM11/17/14
to python_in...@googlegroups.com
Hi,

I'm not entirely sure if I understand what you're trying to do. It seems that you run it to problems when the mesh topology changes, and vertex/edge numbering changes accordingly?

If that's the case, then maybe this document will help you:

Anyway, for large meshes I would use MFnMesh from the API and it's addPolygon method instead of the polyBridgeEdge-command.

Cheers,
Risto





--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/b2d8fbde-872b-4121-a011-5a2d74bc8d10%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

sam williams

unread,
Nov 17, 2014, 4:46:35 AM11/17/14
to python_in...@googlegroups.com
thanks alot. will look into this more;) cheers, 

Sam 

sam williams

unread,
Nov 17, 2014, 4:55:47 AM11/17/14
to python_in...@googlegroups.com
so can the api methods be used pretty much to do everything that python commands can do? just alot faster right?. But a bit more complex to code i guess. I presume dealing with a load of edges over a large mesh, the api is ideal as otherwise it will take forever through python ?

thanks, 
Sam

Marcus Ottosson

unread,
Nov 17, 2014, 4:58:49 AM11/17/14
to python_in...@googlegroups.com
;)

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

Risto Jankkila

unread,
Nov 17, 2014, 5:51:04 AM11/17/14
to python_in...@googlegroups.com
:) You pretty much answered your own questions there. 

Regarding your original problem, I'm still not sure if your problem is related to changes in the mesh vertex ordering or not. If you can show us a bit more of the code you've written so far I might be able understand what the problem is.

Cheers,
Risto





sam williams

unread,
Nov 17, 2014, 7:25:01 AM11/17/14
to python_in...@googlegroups.com
my code is pretty huge now. Let me explain better:

Imagine you have a character mesh, but with loads of random groups of faces missing. My script fills in all the missing faces. However, its not just as simple as plugging all the holes with a generic 'fill hole' tool or something, each hole requires a particular set of bridging and merging commands to fill the hole correctly, so that the edge flow matches up with the surrounding geo.

So my method was to literally create a long list which goes through each hole in the geo and starts bridging certain edges to other edges then merging them etc. I did it manually first so i knew the number of the correct edge to merge with the other correct edge.

I can leave my python script as it is now and it will work. But it is quite slow and cannot easily be modified, because as you mentioned before it will throw the mesh vertex/edge ordering out.

I just thought there must be a smarter api way to do this. I was just looking into that addPolygon method thing. As i am a bit slow, was trying to understand how it could be integrated.

thanks, 
Sam 

ps. the script is required because i will have to repeat this same process with many more meshes. though all will have the same faces missing each time

Marcus Ottosson

unread,
Nov 17, 2014, 8:00:37 AM11/17/14
to python_in...@googlegroups.com
What happens when you select all faces, and run a Mesh -> Fill Hole?

You could also do a Fill Hole, followed by Triangulate and then Quadrangulate to have it try and draw the appropriate edge loops in the filled up area.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

Risto Jankkila

unread,
Nov 17, 2014, 8:45:58 AM11/17/14
to python_in...@googlegroups.com
Hi,

seems that it will be very difficult to find a general solution for your problem. From what I gathered it sounds like you need an arbitrary procedure for each hole in the mesh. 

Anyway the Python API will probably be faster than the commands module. If you decide to use API and run into any problems, I might be able to assist you further.

Cheers,
Risto












Marcus Ottosson

unread,
Nov 17, 2014, 8:54:49 AM11/17/14
to python_in...@googlegroups.com

though all will have the same faces missing each time

Would it happen to be an identical mesh as well?

In that case, you might have some luck with Offline Files, which will essentially record a set of commands, such as filling all holes in a particular fashion, and would then let you re-apply the offline file.

It’s how Maya’s reference mechanism works, except you’ll have control over what and how reference edits are applied.

The procedure might go something like this.

  1. Reference the mesh
  2. Fix it
  3. Export Offline File

Then, in a new file.

  1. Reference the mesh
  2. Apply Offline File

Which could potentially be scripted into.

  1. Select mesh
  2. Create reference from selection
  3. Apply Offline File
  4. Import Reference

Best,
Marcus



For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

sam williams

unread,
Nov 17, 2014, 9:32:18 AM11/17/14
to python_in...@googlegroups.com

Cool, all good advice. Will look into reference files as well. You know with the api. I get a bit stuck understanding how to write the methods out. if i was using the addPolygon method. how do you specify the edges you need filled. does it imitate the bridge command in the same way?


MObject MFnMesh::addPolygon (const MPointArray & vertexArray,
bool mergeVertices = true,
double pointTolerance = 1.0e-10,
MObject parentOrOwner = MObject::kNullObj,
MStatus * ReturnStatus = NULL  
)
Thanks, 
Sam

Risto Jankkila

unread,
Nov 18, 2014, 3:40:14 AM11/18/14
to python_in...@googlegroups.com
Hi,

unfortunately it's nothing like the bridge command. 

Here's a simple example of using MFnMesh.addPolygon() from Python API 2.0:

--
import maya.api.OpenMaya as om

# Assuming an object called pPlane1 exists
kObjectName = "pPlane1"
kMergeDistance =  0.01

# Get our objects dagPath
sel = om.MSelectionList()
sel.add(str(kObjectName))
dagPath = sel.getDagPath(0)

# Pass dagPath to MFnMesh constructor
meshFn = om.MFnMesh(dagPath)

# Create a list of arbitrary points
vtx1 = om.MPoint(1, 0, 0)
vtx2 = om.MPoint(0, 1, 0)
vtx3 = om.MPoint(0, 0, 1)
vertexArray = [vtx1, vtx2, vtx3]

meshFn.addPolygon(vertexArray, True, kMergeDistance)
--

As you can see I'm passing a list of arbitrary points to the addPolygon-method.  In your case you would have to retrieve those positions by using getPoints-method (for example). The MFnMesh-class also has a getHoles()-method that may or may not be useful for you :)

Cheers,
Risto



--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

Risto Jankkila

unread,
Nov 18, 2014, 3:58:21 AM11/18/14
to python_in...@googlegroups.com
Also, I think that using references as Marcus suggested sounds like a good solution for this particular problem. I just wanted to give you an example of how to use the Python API.

/R

Reply all
Reply to author
Forward
0 new messages