08-30-2018 05:29 AM
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
Solved! Go to Solution.
08-30-2018 07:13 AM
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);
08-30-2018 08:29 AM
Thanks @MartinBernhard
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
08-31-2018 05:32 AM
Hi @MartinBernhard .While using "FlatPatternModels. Add" it will consist only single argument. After passing them it is shown only feature name.
// 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
08-31-2018 06:04 AM
There are two things that you are missing:
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!
08-31-2018 06:27 AM
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.
09-01-2018 02:51 AM
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.
09-03-2018 06:10 AM - edited 09-04-2018 04:02 AM
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);
09-04-2018 12:56 AM
Thank you @MartinBernhard.