Cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted

How to use Extruded Draft

Pioneer
Pioneer

Hi.

I'm trying to create cone development.I have use "ExtrudedSurfaces.Add" API but it will not work.I have neglected crown argument.

Thanks.

~VPJ

Spoiler
Profiles Profs = Pdoc.ProfileSets.Add().Profiles;
Profile Prof = Profs.Add(TopPln);  // Plane selection
Relations2d Rels = (Relations2d)Prof.Relations2d;
Dimensions Dim = (Dimensions)Prof.Dimensions;

const double OD = 1.6;
const double height = 0.480;
const double angle = 60 * (Math.PI / 180);
const double thick = 0.006;

Circle2d c1 = Prof.Circles2d.AddByCenterRadius(0, 0, OD / 2.0);
Line2d LV = (Line2d)Prof.ProjectRefPlane(FrontPln);
Rels.AddKeypoint(c1, (int)igCircleCenter, LV, (int)igLineMiddle);

Dimension dimOD = Dim.AddCircularDiameter(c1);
dimOD.Constraint = true;
dimOD.TrackDistance = 0.015;

int stat = Prof.End(ProfileValidationType.igProfileClosed);
Debug.Assert(stat == 0);

//Create a Extruded surface
Profile[] profArr = new Profile[] { Prof };
// ExtrudedSurface mdl = Pdoc.Constructions.ExtrudedSurfaces.AddFinite(1, profArr, FeaturePropertyConstants.igRight, height);

ExtrudedSurface mdl = Pdoc.Constructions.ExtrudedSurfaces.Add(
NumberOfProfiles: 1,
ProfileArray: profArr,
ExtentType1: SolidEdgePart.FeaturePropertyConstants.igFinite,
ExtentSide1: SolidEdgePart.FeaturePropertyConstants.igRight,
FiniteDepth1: height,
TreatmentDraftSide1: SolidEdgePart.DraftSideConstants.seDraftInside,
TreatmentDraftAngle1: angle
);

//Create a Thicken feature

Model mdl2 = Pdoc.Models.AddThickenFeature(FeaturePropertyConstants.igRight, thick, 1, profArr);
Application.Exit();

 

8 REPLIES

Re: How to use Extruded Draft

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

Vijay,

there are NO optional parameters in the ExtrudedSurfaces.Add() method. You have to define them all!

  PartDocument doc = (PartDocument)app.ActiveDocument;
  RefPlane topPln = doc.RefPlanes.Item(1);
  RefPlane rightPln = doc.RefPlanes.Item(2);
  RefPlane frontPln = doc.RefPlanes.Item(3);

  Profiles profs = doc.ProfileSets.Add().Profiles;
  Profile prof = profs.Add(topPln);  // Plane selection
  Relations2d rels = (Relations2d)prof.Relations2d;
  Dimensions dims = (Dimensions)prof.Dimensions;

  const double OD = 1.6;
  const double height = 0.400;
  const double angle = 60 * (Math.PI / 180);
  const double thick = 0.006;

  Circle2d c1 = prof.Circles2d.AddByCenterRadius(0, 0, OD / 2.0);
  Line2d LV = (Line2d)prof.ProjectRefPlane(frontPln);
  rels.AddKeypoint(c1, (int)igCircleCenter, LV, (int)igLineMiddle);

  Dimension dimOD = dims.AddCircularDiameter(c1);
  dimOD.Constraint = true;
  dimOD.TrackDistance = 0.015;

  int stat = prof.End(ProfileValidationType.igProfileClosed);
  Debug.Assert(stat == 0);
  prof.Visible = false;

  //Create a Extruded surface
  Profile[] profArr = new Profile[] { prof };

  // ALL arguments are REQUIRED!
  ExtrudedSurface surf = doc.Constructions.ExtrudedSurfaces.Add(
    1, profArr,
    // Extension 1
    FeaturePropertyConstants.igFinite, FeaturePropertyConstants.igRight, height,
    null, 0, null, OffsetSideConstants.seOffsetNone, 0,
    TreatmentTypeConstants.seTreatmentDraft, DraftSideConstants.seDraftInside, angle,
    TreatmentCrownTypeConstants.seTreatmentCrownNone, TreatmentCrownSideConstants.seTreatmentCrownSideNone,
    TreatmentCrownCurvatureSideConstants.seTreatmentCrownCurvatureNone, 0, 0,
    // Extension 2
    FeaturePropertyConstants.igNone, FeaturePropertyConstants.igLeft, 0,
    null, 0, null, OffsetSideConstants.seOffsetNone, 0,
    TreatmentTypeConstants.seTreatmentNone, DraftSideConstants.seDraftNone, 0,
    TreatmentCrownTypeConstants.seTreatmentCrownNone, TreatmentCrownSideConstants.seTreatmentCrownSideNone,
    TreatmentCrownCurvatureSideConstants.seTreatmentCrownCurvatureNone, 0, 0,
    false // Don't want caps => keep surface open
  );

  // Get the single cone face
  Faces fcs = (Faces)surf.Faces[FeatureTopologyQueryTypeConstants.igQueryAll];
  Debug.Assert(fcs.Count == 1);

  // Create the face array (of a single face)
  Face[] faceArr = new Face[] { (Face)fcs.Item(1) };

  //Create a Thicken feature
  Model mdl = doc.Models.AddThickenFeature(FeaturePropertyConstants.igRight, thick, 1, faceArr);

Re: How to use Extruded Draft

Pioneer
Pioneer

Thanks @MartinBernhard Smiley Happy

Passed every argument (almost 32)  is quite lenthy only for  getting draft.

After completion of remaining two commands (Cutout, Flattern) will close this discussion.

 

~VPJ

Re: How to use Extruded Draft

Pioneer
Pioneer

Hi @MartinBernhard .While using "FlatPatternModels. Add" it will consist only single argument. After passing them it is shown only feature name.

 

cone1.PNG

// Create a Cutout feature
double L = 0.850;
double W = 0.0005;

Profs = Pdoc.ProfileSets.Add().Profiles;
Prof = Profs.Add(TopPln);
Line2d L1 = Prof.Lines2d.AddBy2Points(0, 0, 0, W);
Line2d L2 = Prof.Lines2d.AddBy2Points(0,W,L,W);
Line2d L3 = Prof.Lines2d.AddBy2Points(L,W,L,0);
Line2d L4 = Prof.Lines2d.AddBy2Points(L,0,0,0);

Rels.AddKeypoint(L1,(int)igLineEnd,L2,(int)igLineStart);
Rels.AddKeypoint(L2, (int)igLineEnd, L3, (int)igLineStart);
Rels.AddKeypoint(L3, (int)igLineEnd, L4, (int)igLineStart);
Rels.AddKeypoint(L4, (int)igLineEnd, L1, (int)igLineStart);

stat = Prof.End(ProfileValidationType.igProfileClosed);
Debug.Assert(stat == 0);
Prof.Visible = false;

ExtrudedCutout featCut = mdl.ExtrudedCutouts.AddThroughNext(Prof,FeaturePropertyConstants.igRi, FeaturePropertyConstants.igRight); // Create Flatten
FlatPattern fltPattern = (FlatPattern)Pdoc.FlatPatternModels.Add(mdl);

 ~VPJ

Re: How to use Extruded Draft

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

There are two things that you are missing:

  • You have only created a FlatPatternModel, not the flat pattern itself. From the FlatPatternModel, create a new FlatPattern.
  • SE can only flatten a PART, if it has a material assigned. You may need to do this first BEFORE creating the flat pattern.

BTW: In your code, I don't see the initialization of the Rels variable, which should be specific to a profile, so you will have to get it again from the newly created profile!

Re: How to use Extruded Draft

Pioneer
Pioneer

Thanks Martin sir.Actually i am looking Flat pattern API in which we can passed Face object like argument.(Seen in SE flat pattern video).Now first i  will search API for material selection and do it again.Releated to Rels variable it has  initialize in above part of code here i just paste remaining code.

Re: How to use Extruded Draft

Pioneer
Pioneer

After applying material still problem not resolved. I had read the SDK help file which is in VB code and convert into C#. Why below code is not working?

        // Get Material table object handle
                MatTable objMatTable = Appl.GetMaterialTable();

                // Set active document handle
                objMatTable.SetActiveDocument(Pdoc);
                string strMaterial = "Stainless steel";
                string strLibrary = "Materials";
                objMatTable.ApplyMaterialToDoc(Pdoc, strMaterial, strLibrary);
                
                // Create Flatten
                FlatPatternModel flatPatternModel = (FlatPatternModel)Pdoc.FlatPatternModels.Add(mdl);
                Body body = (Body)mdl.Body;
                Faces faces = (Faces)body.Faces[FeatureTopologyQueryTypeConstants.igQueryAll];
                Face face = (Face)faces.Item(1);
                Edges edges = (Edges)face.Edges;
                Edge edge = (Edge)edges.Item(1);
                
                FlatPattern flatPattern = flatPatternModel.FlatPatterns.Add(edge, fcs, edge.EndVertex, FlattenPatternModelTypeConstants.igFlattenPatternModelTypeFlattenAnything);
                

Thanks.

Re: How to use Extruded Draft

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

In order to flatten the model, you have to create a Blank:

// ...

// Apply a material to the design model
MatTable matTable = app.GetMaterialTable();
matTable.ApplyMaterial(doc, "Stainless steel");

// Create a FlatPattern model
FlatPatternModel flatMdl = (FlatPatternModel)doc.FlatPatternModels.Add(mdl);

// Find the face with the greatest area (the outer cone)
Body body = (Body)mdl.Body;
fcs = (Faces)body.Faces[FeatureTopologyQueryTypeConstants.igQueryAll];
double maxArea = 0;
Face refFace = null;
foreach(Face fc in fcs)
{
  if (fc.Area > maxArea)
  {
    refFace = fc;
    maxArea = fc.Area;
  }
}

// To flatten the model, create a Blank
flatMdl.Blanks.Add(1, new Face[] { refFace }, 
  0, 0, 1,  // flatten long z-axis
  thick,    // thickness
  0.2,      // strain hardening exponent
  55*10e6,  // 550 MegaPa
  3,        // accuracy: 3 - coarse
  0,        // no offset
  false);

 

Re: How to use Extruded Draft

Pioneer
Pioneer

Thank you @MartinBernhard.