public CutOp(Inventor.Document newDoc) { if (newDoc.DocumentType == DocumentTypeEnum.kAssemblyDocumentObject) { m_PartDoc = (PartDocument)newDoc.ActivatedObject; } if (newDoc.DocumentType == DocumentTypeEnum.kPartDocumentObject) { m_PartDoc = (PartDocument)newDoc; } if (m_PartDoc.SubType == "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}") { smcd = (SheetMetalComponentDefinition)m_PartDoc.ComponentDefinition; } smf = (SheetMetalFeatures)smcd.Features; CutDefinition cd = smf.CutFeatures.CreateCutDefinition(selectFromSketch()); try { cd.SetCutAcrossBendsExtent("Толщина"); } catch (Exception) { cd.SetCutAcrossBendsExtent("Thickness"); } smf.CutFeatures.Add(cd); }
public static void createCutLavorazione(PartDocument oDoc, List <string> nomeSketch) { SheetMetalComponentDefinition oCompDef = (SheetMetalComponentDefinition)oDoc.ComponentDefinition; foreach (string nameS in nomeSketch) { try { PlanarSketch oSketch = oCompDef.Sketches[nameS]; SheetMetalFeatures oSheetMetalFeatures = (SheetMetalFeatures)oCompDef.Features; Profile oProfile = oSketch.Profiles.AddForSolid(); CutDefinition oCutDefinition = oSheetMetalFeatures.CutFeatures.CreateCutDefinition(oProfile); //oCutDefinition.SetThroughAllExtent(PartFeatureExtentDirectionEnum.kNegativeExtentDirection); CutFeature oCutFeature = oSheetMetalFeatures.CutFeatures.Add(oCutDefinition); } catch { throw new Exception("Nome sketch non esiste: " + nameS); } } }
public static void createFillet(PartDocument oDoc) { SheetMetalComponentDefinition oCompDef = (SheetMetalComponentDefinition)oDoc.ComponentDefinition; SheetMetalFeatures sFeatures = (SheetMetalFeatures)oCompDef.Features; foreach (Edge oEdge in oCompDef.SurfaceBodies[1].ConcaveEdges) { int tmpCount = oCompDef.SurfaceBodies[1].ConcaveEdges.Count; coloroEntita(oDoc, 255, 0, 0, oEdge); try { EdgeCollection oBendEdges = iApp.TransientObjects.CreateEdgeCollection(); oBendEdges.Add(oEdge); BendDefinition oBendDef = sFeatures.BendFeatures.CreateBendDefinition(oBendEdges); BendFeature oBendFeature = sFeatures.BendFeatures.Add(oBendDef); //if (tmpCount != oCompDef.SurfaceBodies[1].ConcaveEdges.Count) //{ createFillet(oDoc); break; //} } catch { } } }
static public MirrorFeature addMirror(SheetMetalComponentDefinition smcd, ObjectCollection objs, string name, UnitVector vec) { SheetMetalFeatures smf = (SheetMetalFeatures)smcd.Features; WorkPlane wp = smcd.WorkPlanes.OfType <WorkPlane>().First(e => InvDoc.u.eq(vec, e.Plane.Normal)); MirrorFeature mir = smf.MirrorFeatures.Add(objs, wp, false, PatternComputeTypeEnum.kAdjustToModelCompute); mir.Name = name; return(mir); }
public FeaturesInv() : base(entTypes.Features) { if (doc.SubType == "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}") { def = doc.ComponentDefinition as SheetMetalComponentDefinition; smf = def.Features as SheetMetalFeatures; thick = def.Thickness; sms = def.SheetMetalStyles; } }
static public void createCut(PlanarSketch ps) { SheetMetalFeatures smf = getSMF(); CutDefinition cd = smf.CutFeatures.CreateCutDefinition(ps.Profiles.AddForSolid(false)); try { cd.SetCutAcrossBendsExtent("Толщина"); } catch (Exception) { cd.SetCutAcrossBendsExtent("Thickness"); } smf.CutFeatures.Add(cd); }
static public CutFeature addCut(SheetMetalComponentDefinition smcd, string name) { SheetMetalFeatures smf = (SheetMetalFeatures)smcd.Features; PlanarSketch ps = smcd.Sketches[name]; CutDefinition cd = smf.CutFeatures.CreateCutDefinition(ps.Profiles.AddForSolid()); try { cd.SetCutAcrossBendsExtent("Толщина"); } catch (Exception) { cd.SetCutAcrossBendsExtent("Thickness"); } return(smf.CutFeatures.Add(cd)); }
static public void createPunch(string name, PlanarSketch ps, Dictionary <string, double> dic, double ang = 0) { string path = app.iFeatureOptions.RootPath; SheetMetalFeatures smf = getSMF(); iFeatureDefinition ifd = smf.PunchToolFeatures.CreateiFeatureDefinition(path + name); foreach (iFeatureInput input in ifd.iFeatureInputs) { if (dic.ContainsKey(input.Name)) { ((iFeatureParameterInput)input).Value = dic[input.Name] / 10; } } smf.PunchToolFeatures.Add(getPoints(ps), ifd, ang); }
private void offset(Profile profiles) { foreach (ProfilePath pr in profiles) { flag = cmpLen(pr); if (!flag) { b = Convert.ToDouble(this.textBox2.Text.Replace(',', separator)) / 10; } else { b = Convert.ToDouble(this.textBox3.Text.Replace(',', separator)) / 10; } if (pr.Count == 4) { ProfileEntity pe1 = (ProfileEntity)pr[1]; ProfileEntity pe3 = (ProfileEntity)pr[3]; if (pe1.SketchEntity.Type == ObjectTypeEnum.kSketchLineObject || pe1.SketchEntity.Type == ObjectTypeEnum.kSketchLineProxyObject) { ((SketchLine)pe1.SketchEntity).Construction = true; pt1 = ((SketchLine)pe1.SketchEntity).StartSketchPoint; pt3 = ((SketchLine)pe1.SketchEntity).EndSketchPoint; } else if (pe1.SketchEntity.Type == ObjectTypeEnum.kSketchArcObject || pe1.SketchEntity.Type == ObjectTypeEnum.kSketchArcProxyObject) { ((SketchArc)pe1.SketchEntity).Construction = true; pt1 = ((SketchArc)pe1.SketchEntity).StartSketchPoint; pt3 = ((SketchArc)pe1.SketchEntity).EndSketchPoint; } else if (pe1.SketchEntity.Type == ObjectTypeEnum.kSketchSplineObject || pe1.SketchEntity.Type == ObjectTypeEnum.kSketchSplineProxyObject) { ((SketchSpline)pe1.SketchEntity).Construction = true; pt1 = ((SketchSpline)pe1.SketchEntity).StartSketchPoint; pt3 = ((SketchSpline)pe1.SketchEntity).EndSketchPoint; } if (pe3.SketchEntity.Type == ObjectTypeEnum.kSketchLineObject || pe3.SketchEntity.Type == ObjectTypeEnum.kSketchLineProxyObject) { pt2 = ((SketchLine)pe3.SketchEntity).StartSketchPoint; if (pt2.Geometry.VectorTo(pt1.Geometry).Length < pt2.Geometry.VectorTo(pt3.Geometry).Length) { pt2 = ((SketchLine)pe3.SketchEntity).EndSketchPoint; } //pt3 = ((SketchLine)pe3.SketchEntity).Geometry.EndPoint; } else if (pe3.SketchEntity.Type == ObjectTypeEnum.kSketchArcObject || pe3.SketchEntity.Type == ObjectTypeEnum.kSketchArcProxyObject) { pt2 = ((SketchArc)pe3.SketchEntity).StartSketchPoint; if (pt2.Geometry.VectorTo(pt1.Geometry).Length < pt2.Geometry.VectorTo(pt3.Geometry).Length) { pt2 = ((SketchArc)pe3.SketchEntity).EndSketchPoint; } //pt3 = ((SketchArc)pe3.SketchEntity).Geometry.EndPoint; } else if (pe3.SketchEntity.Type == ObjectTypeEnum.kSketchSplineObject || pe3.SketchEntity.Type == ObjectTypeEnum.kSketchSplineProxyObject) { pt2 = ((SketchSpline)pe3.SketchEntity).StartSketchPoint; if (pt2.Geometry.VectorTo(pt1.Geometry).Length < pt2.Geometry.VectorTo(pt3.Geometry).Length) { pt2 = ((SketchSpline)pe3.SketchEntity).EndSketchPoint; } //pt3 = ((SketchSpline)pe3.SketchEntity).EndSketchPoint.Geometry; } //ps.Edit(); rect(pt1.Geometry, pt2.Geometry, pt3.Geometry); //ps.ExitEdit(); } } smf = (SheetMetalFeatures)smcd.Features; ps = smcd.Sketches[name]; CutDefinition cd = smf.CutFeatures.CreateCutDefinition(ps.Profiles.AddForSolid()); try { cd.SetCutAcrossBendsExtent("Толщина"); } catch (Exception) { cd.SetCutAcrossBendsExtent("Thickness"); } smf.CutFeatures.Add(cd); }