0

I have a 2D shell part containing a number of shell faces. I would like to extract one different sketch for each of the faces in the part. So far I know how to create a single sketch containing all the shell faces information but this is not what I want. I would like to know how to create one sketch per shell face. This is what I have done (not right).

stest= model.ConstrainedSketch(name='__polyTest__',sheetSize=2000.0)
mdb.models['Model-1'].parts['Result'].projectReferencesOntoSketch(filter=
    COPLANAR_EDGES, sketch=mdb.models['Model-1'].sketches['__polyTest__'])

Many thanks for your help.

user3641829
  • 261
  • 2
  • 11

1 Answers1

1

Open your part in the current viewport and try this:

from part import *
from sketch import *

p=session.viewports[session.currentViewportName].displayedObject
currentModel=mdb.models[p.modelName]

for faceNum,face in enumerate(p.faces):
    try:  # Will only work on valid sketch planes.  Must be a flat face
        t = p.MakeSketchTransform(sketchPlane=face, sketchUpEdge=p.edges[0], 
            sketchPlaneSide=SIDE1, origin=(659.077803, 0.256062, -816.16))
        s = currentModel.ConstrainedSketch(name='__profile__', 
            sheetSize=834.36, gridSpacing=20.85, transform=t)
        edgeList=[p.edges[edgeNum] for edgeNum in face.getEdges()]
        p.projectEdgesOntoSketch(sketch=s, edges=tuple(edgeList))
        currentModel.ConstrainedSketch(name='Sketch-face' + str(edgeNum), objectToCopy=s)
    except:
        pass 
DougR
  • 3,196
  • 1
  • 28
  • 29