예제 #1
0
    def CutClothWithCutterCurve(self, oMeshCutCloth, sMirrorX=None):
        #print("-CCurve.CutClothWithCutterCurve() on curve '{}'".format(self.sName))
        G.Dump("CutClothWithCutterCurve: " + oMeshCutCloth.name)
        self.RebuildCurve()     ###CHECK17:?
        
        #=== Mirror the cutter mesh about X=0.5 if requested (needed for side cuts to enforce symmetry ===
        if sMirrorX == "MirrorX":
            oModMirrorX = Util_CreateMirrorModifierX(self.oCutterO)
            oModMirrorX.mirror_object = bpy.data.objects["EmptyAtZeroPointFiveForClothCutting"]     # Specify empty set to X=0.5 so mirror is done about body center
            AssertFinished(bpy.ops.object.modifier_apply(modifier=oModMirrorX.name))        

        #=== Create a boolean modifier and apply it to remove the extra bit beyond the current cutter ===
        SelectObject(oMeshCutCloth.name, True)
        oModBoolean = oMeshCutCloth.modifiers.new('BOOLEAN', 'BOOLEAN')
        #oModBoolean.solver = "CARVE"                ###INFO: Older 'CARVE' Boolean Solver appears to destroy all the custom data layers.  BMESH is default but it has problems...  ###DESIGN17: what to do?
        ###BUG17: BMESH cuts sometime don't work
        oModBoolean.object = self.oCutterO
        oModBoolean.operation = 'DIFFERENCE'            ###INFO: Difference is the one we always want when cutting as the others appear useless!  Note that this is totally influenced by side of cutter normals!!
        AssertFinished(bpy.ops.object.modifier_apply(modifier=oModBoolean.name))  ###INFO: Have to specify 'modifier' or this won't work!
        
        #=== Boolean cut leaves quads and ngons on the border and triangles give us more control on what to delete -> Triangulate before border cleanup ===
        bpy.ops.object.mode_set(mode='EDIT')
        bpy.ops.mesh.select_all(action='SELECT')
        bpy.ops.mesh.delete_loose()                     # For some reason back cloth leaves loose verts!  Clean with this call
        bpy.ops.mesh.quads_convert_to_tris()            ###CHECK17: Needed??
        bpy.ops.mesh.select_all(action='DESELECT')
        bpy.ops.object.mode_set(mode='OBJECT')
        Util_HideMesh(self.oCutterO)