Discussion:
[Maya-Python] merging/bridging multiple sets of edges hellppeeeee!!!x
sam williams
11 years ago
Permalink
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
--
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_maya+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/293aef17-de13-419f-b6da-eb7e03536ba9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Marcus Ottosson
11 years ago
Permalink
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.
...
--
*Marcus Ottosson*
***@gmail.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_maya+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODOnrNjPdV-1%3DAZdJirF34aLVCBknYESqZ-Ot%3Dy9M6O4A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Risto Jankkila
11 years ago
Permalink
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
...
--
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_maya+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CA%2B5uDBYwvRJBRpYYpy4QQEV9B5ruNG8MtXoKO%2BVvPCqg%3DoAgJQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Marcus Ottosson
11 years ago
Permalink
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
​
...
--
*Marcus Ottosson*
***@gmail.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_maya+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOB3pLrUgxigDcwVf4nAWufpGqU8Xw_DFr%2BDSkw_Mbjhiw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
sam williams
11 years ago
Permalink
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
--
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_maya+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/678546d1-e0e8-451f-adcd-a2dc535ce34e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Risto Jankkila
11 years ago
Permalink
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_maya+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CA%2B5uDBbMdzhuCJn9g6m1T%2BoD_jij4yqp%3DDGxfyBmP94340p93g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Risto Jankkila
11 years ago
Permalink
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
...
--
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_maya+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CA%2B5uDBbFb26Ww_EPYdxNdX%3D%3DKx0A6XMSg45cbEUyz%3DhFJdopCg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Loading...