I am unwelding specific mesh edges with Python in a GH component to achieve creased SubD edges. SubD conversion is done with GH’s Subd from Mesh component. The mesh has Ngons with 5 and 6 vertices. UnweldEdge() destroys the Ngons. I am trying to store the Ngons and add them again after UnweldEdge(). This results in an invalid mesh and SubD from Mesh reverts to triangulating the Ngon faces. Mesh edges look ok though. With the original mesh, Subd from Mesh respects the Ngon faces (DEBUG output). How can I keep the Ngon intact while unwelding the edges?
Any other way to crease edges programmatically? As far as I understood from @dalelear the relevant methods for this are not yet exposed in rhcommon:
Edit: I extracted the relevant part of the geometry. It is internalized in the below GH file.
def ngon_tag(mesh, indices):
ngs = []
for ng in mesh.Ngons:
if ng.BoundaryVertexCount > 4:
ngs.append(ng)
# After UnweldEdge Ngons are gone
res = mesh.UnweldEdge(indices, True)
# AddNgons recreates Ngons but results in an invalid mesh and subsequently
# GH SubD from Mesh component triangulates Ngons with more than 4 vertices.
mesh.Ngons.AddNgons(ngs)
return mesh
Subd from Mesh with orignal mesh, Ngons respected:
There is also a SetEdgeTags function on the SubDEdgeList that is available in Rhino 7.7. This function is the preferred approach to setting creases for a set of edges.
Thanks for adding SetEdgeTags to rhcommon. The C# component below uses it. Creasing decisions are based on points at the control polygon edges middle point (point at middle → edge is creased). 1075_210602_RFD-SubdEdgeTagWSearch_SO.gh (11.5 KB)
Some issues persist that I cannot resolve.
Issue 1
The SubdDEdges component generates an Object reference not set to an instance of an object error. I suspect this is caused by caching: When I copied the C# component in another definition and connected the inputs, SubDEdges worked. (Edit: ) Any upstream change before the C# component brings back the error. Output of the C# component superficially looks good. I tried calling ClearEvaluationCache and UpdateAllTagsAndSectorCoefficients in all possible combinations. Still getting the same error.
Issue 2
After baking the output of the C# component, we get weird shading behavior. Arctic mode is extremely slow and artifacts show on the SubD. This does not happen if we bake the SubD before the C# component. We have seen this before with modeled SubDs, but it was resolved by a recent update.
This function was added to Rhino 7.7 which is still not the official release until next week. Once we release 7.7, we will update the RhinoCommon API docs.
@stevebaer
Is there an equivalent method to SetEdgeTags() for SubD.Vertices in rhinocommon?
I have to crease some vertices, but not all of them, around an open edge loop. Please see the following sketch. Vertices to be creased are encircled in red.
thanks for your code @lasathrs, please is there a way to analyse the closest subD vertex or add tolerance but within the code? sometimes it doesn’t detect some PC points? thank you!
I updated the little script to include tolerance, I tested it and it works for the one point but you might need to adjust your SubD a little Crease Corner_LS.gh (21.7 KB)