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 List <string> ExportSheetmetalPartsToDXF(List <SheetmetalPart> sheetmetalPartList, ExportDXFSettings exportDXFSettings) { List <string> exportLog = new List <string>(); string exportString = ExportStringGenerator.GenerateExportString(exportDXFSettings.ImportExportDXFLayers.dXFLayerItems); foreach (SheetmetalPart sheetmetalPart in sheetmetalPartList) { string exportFileName = GenerateExportFileName(sheetmetalPart, exportDXFSettings); try { SheetMetalComponentDefinition sheetMetalCompDef = (SheetMetalComponentDefinition)sheetmetalPart.PartDocument.ComponentDefinition; DataIO dataIO = sheetMetalCompDef.FlatPattern.DataIO; dataIO.WriteDataToFile(exportString, exportFileName); exportLog.Add(sheetmetalPart.Name + " DXF was successfully exported"); EventLogger.CreateLogEntry(sheetmetalPart.Name + " DXF was successfully exported"); } catch (Exception e) { exportLog.Add(sheetmetalPart.Name + " DXF export encountered an error"); exportLog.Add(e.Message + " " + e.StackTrace); EventLogger.CreateLogEntry(sheetmetalPart.Name + " DXF export encountered an error"); EventLogger.CreateLogEntry(e.Message + " " + e.StackTrace); continue; } } return(exportLog); }
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); } } }
static public void addCutDef(SheetMetalComponentDefinition smcd, Double a, Double b, string name = "Паз") { try { SketchBlockDefinition d = smcd.SketchBlockDefinitions[name]; return; } catch (Exception) { } SketchBlockDefinition def = smcd.SketchBlockDefinitions.Add(name); TransientGeometry tg = Macros.StandardAddInServer.m_inventorApplication.TransientGeometry; Point2d pt = tg.CreatePoint2d(); SketchPoint origin = def.SketchPoints.Add(pt, false); def.GeometricConstraints.AddGround((SketchEntity)origin); SketchLine sl1, sl2, sl3; SketchEntitiesEnumerator en = def.SketchLines.AddAsTwoPointRectangle(tg.CreatePoint2d(-b / 2, -a / 2), tg.CreatePoint2d(b / 2, a / 2)); sl1 = (SketchLine)en[2]; sl2 = (SketchLine)en[4]; sl3 = midleLine(sl1, sl2); //foreach (DimensionConstraint item in def.DimensionConstraints) //{ // item.Delete(); //} }
bool check(SheetMetalComponentDefinition smcd1) { if (xDoc == null) { return(false); } if (smcd1 == null) { return(false); } double t = u.convToDouble(smcd1.Thickness.Value.ToString(), 10, 3); string matName = smcd1.Material.Name; XElement el = xDoc.Root.Descendants("Material").FirstOrDefault(e => e.FirstAttribute.Value == matName); if (el == null) { return(false); } //el.Element("MaterialUpLine").Value = el.Element("MaterialUpLine").Value.Replace("t", t.ToString("0.0", System.Globalization.CultureInfo.CreateSpecificCulture("da-DK"))); List <string> vals = new List <string>() { el.Element("MaterialUpLine").Value.Replace("t", t.ToString("0.0", System.Globalization.CultureInfo.CreateSpecificCulture("da-DK"))), el.Element("MaterialDownLine").Value, el.Element("MaterialLine").Value, el.Element("MaterialCenter").Value }; if (base[0] != null) { changed = changes(vals, 3); } return(changed); }
public static IDictionary <Face, List <Lavorazione> > detectLavorazioni(PartDocument oDoc) { IDictionary <Face, List <Lavorazione> > result = new Dictionary <Face, List <Lavorazione> >(); SheetMetalComponentDefinition oCompDef = (SheetMetalComponentDefinition)oDoc.ComponentDefinition; FaceCollection oFaceColl = oCompDef.Bends[1].FrontFaces[1].TangentiallyConnectedFaces; oFaceColl.Add(oCompDef.Bends[1].FrontFaces[1]); foreach (Face f in oFaceColl) { if (f.EdgeLoops.Count > 1) { List <Lavorazione> lavorazione = IdentificazioneEntita.main(f.EdgeLoops, iApp); if (lavorazione.Count > 0) { result.Add(f, lavorazione); } } } return(result); }
public static List <string> createSketchLavorazione(PartDocument oDoc, IDictionary <Face, List <Lavorazione> > lavorazione) { SheetMetalComponentDefinition oCompDef = (SheetMetalComponentDefinition)oDoc.ComponentDefinition; List <string> result = new List <string>(); int index = 1; foreach (var x in lavorazione) { Face oFace = x.Key; List <Lavorazione> lavList = x.Value; foreach (Lavorazione lav in lavList) { PlanarSketch oSketch = oCompDef.Sketches.Add(oFace, false); foreach (Edge oEdge in lav.oEdgeColl_) { oSketch.AddByProjectingEntity(oEdge); oSketch.Visible = false; } string nameSketch = lav.nameLav_ + "_" + index; oSketch.Name = nameSketch; result.Add(nameSketch); index++; } } return(result); }
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 void project(SheetMetalComponentDefinition smcd, string name) { WorkPlane wp = smcd.WorkPlanes["Шип_справа"]; PlanarSketch ps = smcd.Sketches.Add(wp); ps.Name = name; ps.Visible = false; ps.ProjectedCuts.Add(); }
// ! Setta la texture public static void setTexture(PartDocument oDoc) { SheetMetalComponentDefinition oCompDef = (SheetMetalComponentDefinition)oDoc.ComponentDefinition; FaceCollection fcFront = oCompDef.Bends[1].FrontFaces[1].TangentiallyConnectedFaces; fcFront.Add(oCompDef.Bends[1].FrontFaces[1]); FaceCollection fcBack = oCompDef.Bends[1].BackFaces[1].TangentiallyConnectedFaces; fcBack.Add(oCompDef.Bends[1].BackFaces[1]); double area0 = 0; foreach (Face oFace in fcFront) { area0 = area0 + oFace.Evaluator.Area; } double area1 = 0; foreach (Face oFace in fcBack) { area1 = area1 + oFace.Evaluator.Area; } Asset oAsset; try { oAsset = oDoc.Assets["RawSide"]; } catch (System.ArgumentException e) { Assets oAssets = oDoc.Assets; AssetLibrary oAssetsLib = iApp.AssetLibraries["3D_Pisa_Col"]; Asset oAssetLib = oAssetsLib.AppearanceAssets["RawSide"]; oAsset = oAssetLib.CopyTo(oDoc); } FaceCollection fc; if (area0 > area1) { fc = fcBack; } else { fc = fcFront; } foreach (Face f in fc) { f.Appearance = oAsset; } }
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 FlatPattern getFP(Document doc) { SheetMetalComponentDefinition smcd = getSMCD(doc); if (smcd != null && smcd.HasFlatPattern) { return(smcd.FlatPattern); } return(null); }
// ! Aggiunge il piano in mezzo alla lamiera public static WorkPlane addPlaneInTheMiddleOfBox(PartDocument oDoc) { SheetMetalComponentDefinition oComp = (SheetMetalComponentDefinition)oDoc.ComponentDefinition; try { return(oComp.WorkPlanes["Manual"]); } catch { } Box oRb = oComp.SurfaceBodies[1].RangeBox; TransientBRep oTransientBRep = iApp.TransientBRep; SurfaceBody oBody = oTransientBRep.CreateSolidBlock(oRb); NonParametricBaseFeature oBaseFeature = oComp.Features.NonParametricBaseFeatures.Add(oBody); FaceCollection oFaceColl = iApp.TransientObjects.CreateFaceCollection(); foreach (Face f in oBaseFeature.SurfaceBodies[1].Faces) { WorkPlane tmpWp = oComp.WorkPlanes.AddByPlaneAndOffset(f, 0); //if (tmpWp.Plane.IsParallelTo[oComp.WorkPlanes[1].Plane]) if (tmpWp.Plane.IsParallelTo[oComp.WorkPlanes[1].Plane]) { oFaceColl.Add(f); } tmpWp.Delete(); } WorkPlane wpWork = null; if (oFaceColl.Count >= 2) { WorkPlane wp1 = oComp.WorkPlanes.AddByPlaneAndOffset(oFaceColl[1], 0); WorkPlane wp2 = oComp.WorkPlanes.AddByPlaneAndOffset(oFaceColl[2], 0); wpWork = oComp.WorkPlanes.AddByTwoPlanes(wp1, wp2); wpWork.Name = "wpWorkReference"; wpWork.Grounded = true; wpWork.Visible = false; oBaseFeature.Delete(false, true, true); wp1.Delete(); wp2.Delete(); } return(wpWork); }
public SheetmetalPart(PartDocument partDocument) : base(partDocument) { SheetMetalCompDef = (SheetMetalComponentDefinition)partDocument.ComponentDefinition; NumberOfBends = SheetMetalCompDef.Bends.Count; Thickness = SheetMetalCompDef.Thickness.ModelValue; FlatPattern = new FlatPattern(SheetMetalCompDef); GetFlatPatternProperties(); }
// ! Elimina tutti i fillet public static List <string> deleteFillet_(PartDocument oDoc) { SheetMetalComponentDefinition oCompDef = (SheetMetalComponentDefinition)oDoc.ComponentDefinition; List <string> faceCollToKeep = new List <string>(); if (oCompDef.Bends.Count > 0) { Bend oBend = oCompDef.Bends[1]; FaceCollection oFaceColl = oBend.FrontFaces[1].TangentiallyConnectedFaces; oFaceColl.Add(oBend.FrontFaces[1]); foreach (Face oFace in oFaceColl) { faceCollToKeep.Add(oFace.InternalName); } NonParametricBaseFeature oBaseFeature = oCompDef.Features.NonParametricBaseFeatures[1]; oBaseFeature.Edit(); SurfaceBody basebody = oBaseFeature.BaseSolidBody; ObjectCollection oColl = iApp.TransientObjects.CreateObjectCollection(); foreach (Face f in basebody.Faces) { if (faceCollToKeep.Contains(f.InternalName)) { if (f.SurfaceType == SurfaceTypeEnum.kCylinderSurface) { oColl.Add(f); } } } try { oBaseFeature.DeleteFaces(oColl); oBaseFeature.ExitEdit(); } catch { oBaseFeature.ExitEdit(); return(null); } } return(faceCollToKeep); }
public void addProject() { try { m_asmCompDef = asmDoc.ComponentDefinition; invApp = (Inventor.Application)asmDoc.Parent; tg = invApp.TransientGeometry; smcd = (SheetMetalComponentDefinition)m_asmCompDef.Occurrences[1].Definition; SheetMetalComponentDefinition smcd2 = (SheetMetalComponentDefinition)m_asmCompDef.Occurrences[2].Definition; //m_asmCompDef.Occurrences[1].Edit(); CommandManager cmdMgr = ((Inventor.Application)asmDoc.Parent).CommandManager; FaceProxy face; object obj = cmdMgr.Pick(SelectionFilterEnum.kPartFacePlanarFilter, "Выберите плоскость эскиза:"); objCol = invApp.TransientObjects.CreateObjectCollection(); face = (FaceProxy)obj; asmDoc.SelectSet.Select(m_asmCompDef.Occurrences[2]); //((PartDocument)smcd.Document).SelectSet.Select(m_asmCompDef.Occurrences[2].CreateGeometryProxy()); //double[] pts = {face.PointOnFace.X,face.PointOnFace.Y,face.PointOnFace.Z}; //double[] normals = {0,0,0}; //face.Evaluator.GetNormalAtPoint(ref pts, ref normals); //Plane pl = invApp.TransientGeometry.CreatePlane(face.PointOnFace, invApp.TransientGeometry.CreateVector(normals[0], normals[1], normals[2])); //obj = m_asmCompDef.Occurrences[2].Definition.SurfaceBodies[1]; //m_PartDoc.SelectSet.Select() obj = null; WorkPlane wp = smcd2.WorkPlanes[3]; m_asmCompDef.Occurrences[1].CreateGeometryProxy(face, out obj); FaceProxy face2 = (FaceProxy)obj; ps = smcd.Sketches.Add(face2); ProjectedCut cut = ps.ProjectedCuts.Add(); PlanarSketch pls = smcd2.Sketches.Add(smcd2.WorkPlanes[3]); m_asmCompDef.Occurrences[2].CreateGeometryProxy(pls, out obj); psp = (PlanarSketchProxy)obj; foreach (var item in ps.SketchLines) { m_asmCompDef.Occurrences[1].CreateGeometryProxy(item, out obj); psp.AddByProjectingEntity(obj); } //m_asmCompDef.Occurrences[2].CreateGeometryProxy(smcd.WorkPlanes[3],out obj); //m_asmCompDef.Occurrences[1].CreateGeometryProxy(ps,out obj); //psp.ProjectedCuts.Add(); TransientGeometry tr = invApp.TransientGeometry; //cmdMgr.ControlDefinitions["SketchProjectCutEdgesCmd"].Execute(); //enumerat = invApp.TransientGeometry.SurfaceSurfaceIntersection(m_asmCompDef.Occurrences[2].Definition.SurfaceBodies[1], pl); } catch (Exception) { throw; } }
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)); }
public static void createProfile(PartDocument oDoc) { SheetMetalComponentDefinition oCompDef = (SheetMetalComponentDefinition)oDoc.ComponentDefinition; FaceCollection oFaceColl = iApp.TransientObjects.CreateFaceCollection(); foreach (Face f in oCompDef.SurfaceBodies[1].Faces) { oFaceColl.Add(f); } PartFeatures oFeat = oCompDef.Features; oFeat.ThickenFeatures.Add(oFaceColl, Math.Round(oCompDef.Thickness.Value * 100) / 100, PartFeatureExtentDirectionEnum.kNegativeExtentDirection, PartFeatureOperationEnum.kJoinOperation, false); }
// ! Creo lo sviluppo della lamiera public static bool sviluppoLamiera(PartDocument oDoc) { SheetMetalComponentDefinition oCompDef = (SheetMetalComponentDefinition)oDoc.ComponentDefinition; try { oCompDef.Unfold(); return(true); } catch { return(false); } }
public static void setThicknessFisso(PartDocument oDoc, string parametro) { SheetMetalComponentDefinition oCompDef = (SheetMetalComponentDefinition)oDoc.ComponentDefinition; string toSelect = parametro; if (!string.IsNullOrEmpty(toSelect)) { SheetMetalStyle oStyle = oCompDef.SheetMetalStyles[toSelect]; oStyle.Activate(); } else { throw new Exception("Nessuno spessore trovato"); } }
private void button1_Click(object sender, EventArgs e) { a = Convert.ToDouble(this.textBox1.Text.Replace(',', separator)) / 10; b = Convert.ToDouble(this.textBox2.Text.Replace(',', separator)) / 10; this.Hide(); try { invApp = (Inventor.Application)m_PartDoc.Parent; if (m_PartDoc.SubType == "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}") { smcd = (SheetMetalComponentDefinition)m_PartDoc.ComponentDefinition; } tr = invApp.TransactionManager.StartTransaction((_Document)m_PartDoc, "Шипы"); objCol = invApp.TransientObjects.CreateObjectCollection(); if (asmDoc != null) { ComponentOccurrence co = asmDoc.ComponentDefinition.Occurrences.OfType <ComponentOccurrence>().FirstOrDefault(c => c.Name.ToLower().IndexOf("обтекатель") != -1); if (co != null) { //PartDocument pDoc; if (((Document)co.Definition.Document).SubType == "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}") { smcd = (SheetMetalComponentDefinition)((PartDocument)co.Definition.Document).ComponentDefinition; } PlanarSketch plsk = smcd.Sketches.OfType <PlanarSketch>().FirstOrDefault(p => p.Name == "Шип"); if (plsk == null) { project(smcd, "Шип"); } } return; } profiles = selectFromSketch(); //offsetAdaptive(profiles); offset(profiles); tr.End(); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); tr.End(); this.Close(); } }
public static void deleteFace(PartDocument oDoc, List <string> faceCollToKeep) { SheetMetalComponentDefinition oCompDef = (SheetMetalComponentDefinition)oDoc.ComponentDefinition; FaceCollection faceCollToDelete = iApp.TransientObjects.CreateFaceCollection(); foreach (Face oFace in oCompDef.SurfaceBodies[1].Faces) { if (!faceCollToKeep.Contains(oFace.InternalName)) { faceCollToDelete.Add(oFace); } } PartFeatures oFeat = oCompDef.Features; oFeat.DeleteFaceFeatures.Add(faceCollToDelete); }
public static Face getBiggestFace(PartDocument oDoc) { SheetMetalComponentDefinition oCompDef = (SheetMetalComponentDefinition)oDoc.ComponentDefinition; Face biggestFace = null; double area = 0; foreach (Face f in oCompDef.SurfaceBodies[1].Faces) { if (f.Evaluator.Area > area) { area = f.Evaluator.Area; biggestFace = f; } } return(biggestFace); }
public Material(Document doc, string [] arr /*{ "MaterialUpLine", "MaterialDownLine", "MaterialLine", "MaterialCenter" }*/) : base(doc, arr) { pDoc = doc as PartDocument; if (pDoc == null) { return; } string path = doc.pathUtil(); smcd = pDoc.ComponentDefinition as SheetMetalComponentDefinition; if (smcd == null) { return; } xDoc = xDoc ?? XDocument.Load(@"C:\ProgramData\Autodesk\Inventor Addins\Material.xml"); if (System.IO.File.Exists(path + "\\Material.xml")) { xDoc = XDocument.Load(path + "\\Material.xml"); } }
static public ComponentOccurrence findFlange(AssemblyComponentDefinition acd) { foreach (ComponentOccurrence occ1 in acd.Occurrences) { if (((Document)occ1.Definition.Document).SubType == "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}") { SheetMetalComponentDefinition smcd = (SheetMetalComponentDefinition)occ1.Definition; if (smcd.ReferenceComponents.DerivedPartComponents.Count == 1 && (smcd.ReferenceComponents.DerivedPartComponents[1].Definition as DerivedPartUniformScaleDef).Mirror) { continue; } if (smcd.Features[1] is FaceFeature) { return(occ1); } } } return(null); }
public static void main(string path) { // ! prendo instanza Inventor getIstance(); PartDocument oDoc = (PartDocument)iApp.ActiveDocument; // ! Imposto SheetMetalDocument setSheetMetalDocument(oDoc); // ! Imposto thickness setThickness(oDoc); SheetMetalComponentDefinition oComp = (SheetMetalComponentDefinition)oDoc.ComponentDefinition; WorkPlane oWpReference = null; List <string> nameWp = new List <string>(); bool manual = false; foreach (WorkPlane oWp in oComp.WorkPlanes) { nameWp.Add(oWp.Name); if (oWp.Name == "manualPlane") { oWpReference = oWp; manual = true; } } if (!manual) { // ! Elimino raggiature List <string> faceCollToKeep = deleteFillet(oDoc); // ! Elimino facce deleteFace(oDoc, faceCollToKeep); // ! Creo Profilo createProfile(oDoc); // ! Creo Raggiature createFillet(oDoc); // ! Cerco le lavorazioni IDictionary <Face, List <Lavorazione> > lavorazione = detectLavorazioni(oDoc); // ! Creo sketch lavorazioni List <string> nomeSketch = createSketchLavorazione(oDoc, lavorazione); // ! Elimino con direct le lavorazioni deleteLavorazione(oDoc); // ! Cut lavorazione createCutLavorazione(oDoc, nomeSketch); // ! Aggiungo piano nel mezzo oWpReference = addPlaneInTheMiddleOfBox(oDoc); // ! Aggiungo proiezione cut addProjectCut(oDoc, oWpReference, manual); // ! Coloro lato bello } else { addProjectCut(oDoc, oWpReference, manual); } setTexture(oDoc); oDoc.Close(); }
static public PlanarSketch projectAcrosParts(ref AssemblyComponentDefinition acd, string [] nameIn, string nameOut, string sketchName, ref SheetMetalComponentDefinition smcd) { PlanarSketch psIn, psOut; ComponentOccurrence occ2; SheetMetalComponentDefinition smcd1; Profile pr; object sketchLineProxy; object psp; PlanarSketchProxy plsP; SketchEntity se; occ2 = findFlange(acd); PartComponentDefinition def = (PartComponentDefinition)occ2.Definition; psOut = def.Sketches.OfType <PlanarSketch>().FirstOrDefault(s => s.Name == sketchName); if (psOut == null) { psOut = def.Sketches.Add(def.SurfaceBodies[1].Faces.OfType <Face>().Where(f => f.CreatedByFeature is FaceFeature).OrderByDescending(o => o.Evaluator.Area).ElementAt(1)); } occ2.CreateGeometryProxy(psOut, out psp); plsP = (PlanarSketchProxy)psp; if (((Document)occ2.Definition.Document).SubType == "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}") { smcd = (SheetMetalComponentDefinition)occ2.Definition; } foreach (ComponentOccurrence occ1 in acd.Occurrences) { if (occ1 == null) { continue; } if (((Document)occ1.Definition.Document).SubType == "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}") { smcd1 = (SheetMetalComponentDefinition)occ1.Definition; if (!(smcd1.Features[1] is ContourFlangeFeature)) { continue; } } psIn = ((PartComponentDefinition)occ1.Definition).Sketches[sketchName]; pr = psIn.Profiles.AddForSolid(); psIn.Visible = false; //ProjectedCut pc = psIn.ProjectedCuts[1]; occ1.CreateGeometryProxy(pr, out sketchLineProxy); //plsP.AddByProjectingEntity(sketchLineProxy); //foreach (SketchEntity s in ((ProjectedCut)sketchLineProxy).SketchEntities) //{ // if (s.) // plsP.AddByProjectingEntity(s); //} foreach (ProfilePath pp in (Profile)sketchLineProxy) { foreach (ProfileEntity ent in pp) { se = plsP.AddByProjectingEntity(ent.SketchEntity); } } } return(psOut); }
public FlatPattern(SheetMetalComponentDefinition sheetMetalCompDef) { this.sheetMetalCompDef = sheetMetalCompDef; inventorConnection = new InventorConnection(); }
static public void offsetAdaptive(SheetMetalComponentDefinition smcd, string name, double valA, double valB, double valB1) { double a = valA, b = valB; PlanarSketch ps = smcd.Sketches[name]; PlanarSketch newSketch = smcd.Sketches.Add(ps.PlanarEntity); name = newSketch.Name; Profile profiles = ps.Profiles.AddForSolid(); foreach (ProfilePath pr in profiles) { bool flag = cmpLen(pr, valB1 - 0.03); if (flag) { b = valB1;/*Convert.ToDouble(this.textBox3.Text.Replace(',', separator)) / 10;*/ } if (pr.Count == 4) { ProfileEntity pe1 = (ProfileEntity)pr[1]; ProfileEntity pe3 = (ProfileEntity)pr[3]; if (pe1.CurveType != Curve2dTypeEnum.kLineSegmentCurve2d || pe1.EndSketchPoint.Geometry.DistanceTo(pe1.StartSketchPoint.Geometry) > valA * 2) { pe1 = (ProfileEntity)pr[2]; pe3 = (ProfileEntity)pr[4]; } //pe1.SketchEntity.Construction = true; //ProfileEntity pe1 = pr.OfType<ProfileEntity>().FirstOrDefault(e1 => e1.CurveType == Curve2dTypeEnum.kLineCurve2d && // (e1.EndSketchPoint.Geometry.DistanceTo(e1.StartSketchPoint.Geometry) <= 0.1)); //ProfileEntity pe3 = pr.OfType<ProfileEntity>().LastOrDefault(e1 => e1.CurveType == Curve2dTypeEnum.kLineCurve2d && // (e1.EndSketchPoint.Geometry.DistanceTo(e1.StartSketchPoint.Geometry) <= 0.1)); if (pe1 == null || pe3 == null) { continue; } //SketchLine sl1 = (SketchLine)pe1.SketchEntity; //SketchLine sl2 = (SketchLine)pe3.SketchEntity; SketchLine sl1 = (SketchLine)newSketch.AddByProjectingEntity(pe1.SketchEntity); SketchLine sl2 = (SketchLine)newSketch.AddByProjectingEntity(pe3.SketchEntity); //sl2.Construction = true; SketchLine sl3 = midleLine(sl1, sl2); SketchPoint mp = newSketch.SketchPoints.Add(sl3.Geometry.MidPoint, false); MidpointConstraint mpc = newSketch.GeometricConstraints.AddMidpoint(mp, sl3); //SketchBlock sb; //SketchLine newLin; //if (b == valB) //{ // sb = ps.SketchBlocks.AddByDefinition(smcd.SketchBlockDefinitions["Паз"], mp.Geometry); //} //else //{ // sb = ps.SketchBlocks.AddByDefinition(smcd.SketchBlockDefinitions["Паз_замыкающий"], mp.Geometry); //} // newLin = ps.SketchLines.OfType<SketchLine>().LastOrDefault(l => l.Construction == true); // ps.GeometricConstraints.AddCollinear((SketchEntity)newLin, (SketchEntity)sl3); rect(sl3, mp, a, b); } } //foreach (SketchBlock item in ps.SketchBlocks) //{ // item.Explode(); //} //foreach (DimensionConstraint item in newSketch.DimensionConstraints) //{ // item.Delete(); //} //addEqualLength(newSketch, valA); //addEqualLength(newSketch, valB); //addEqualLength(newSketch, valB1); CutFeature cut = addCut(smcd, name); cut.Name = "Пазы"; }