////////////////////////////////////////////////////////////////////////////////////////////// // Starts dimension command // ////////////////////////////////////////////////////////////////////////////////////////////// void StartCommand() { Inventor.Application InvApp = AdnInventorUtilities.InvApplication; _Tg = InvApp.TransientGeometry; _TBrep = InvApp.TransientBRep; _interactionManager = new AdnInteractionManager(InvApp); _interactionManager.Initialize(); _interactionManager.OnTerminateEvent += new AdnInteractionManager.OnTerminateHandler(OnTerminateEvent); _interactionManager.AddPreSelectionFilter(ObjectTypeEnum.kVertexObject); _interactionManager.AddPreSelectionFilter(ObjectTypeEnum.kVertexProxyObject); _interactionManager.AddPreSelectionFilter(ObjectTypeEnum.kWorkPointObject); _interactionManager.AddPreSelectionFilter(ObjectTypeEnum.kWorkPointProxyObject); _interactionManager.SelectEvents.SingleSelectEnabled = true; _interactionManager.SelectEvents.OnSelect += new SelectEventsSink_OnSelectEventHandler(SelectEvents_OnSelect); _interactionManager.Start("Select dimension first point: "); _clientGraphicsMng = new AdnClientGraphicsManager( AdnInventorUtilities.InvApplication, AdnInventorUtilities.AddInGuid); _clientGraphicsMng.SetGraphicsSource( _interactionManager.InteractionEvents); }
internal override void DrawGeom(TransientGeometry TG, ref PlanarSketch sketch, ref List <SketchLine> lines) { var pos = lines.FindIndex(x => x == SideLine); lines.RemoveAt(pos); pos += 1; sketch.SketchLines[pos].Delete(); var length = Distance + Width; switch (Side) { case ('r'): var point = sketch.SketchLines[pos - 1].EndSketchPoint; var line = sketch.SketchLines.AddByTwoPoints(point, TG.CreatePoint2d(point.Geometry.X + Distance, point.Geometry.Y)); var line0 = sketch.SketchLines.AddByTwoPoints(line.EndSketchPoint, TG.CreatePoint2d(line.EndSketchPoint.Geometry.X, Radius)); var line1 = sketch.SketchLines.AddByTwoPoints(line0.EndSketchPoint, TG.CreatePoint2d(line0.EndSketchPoint.Geometry.X + Width, line0.EndSketchPoint.Geometry.Y)); var line2 = sketch.SketchLines.AddByTwoPoints(line1.EndSketchPoint, TG.CreatePoint2d(line.EndSketchPoint.Geometry.X + Width, line.EndSketchPoint.Geometry.Y)); sketch.SketchLines.AddByTwoPoints(line2.EndSketchPoint, sketch.SketchLines[pos].StartSketchPoint); break; case ('l'): point = sketch.SketchLines[pos].StartSketchPoint; line = sketch.SketchLines.AddByTwoPoints(sketch.SketchLines[pos - 1].EndSketchPoint, TG.CreatePoint2d(point.Geometry.X - length, point.Geometry.Y)); line0 = sketch.SketchLines.AddByTwoPoints(line.EndSketchPoint, TG.CreatePoint2d(line.EndSketchPoint.Geometry.X, Radius)); line1 = sketch.SketchLines.AddByTwoPoints(line0.EndSketchPoint, TG.CreatePoint2d(line0.EndSketchPoint.Geometry.X + Width, line0.EndSketchPoint.Geometry.Y)); line2 = sketch.SketchLines.AddByTwoPoints(line1.EndSketchPoint, TG.CreatePoint2d(line.EndSketchPoint.Geometry.X + Width, line.EndSketchPoint.Geometry.Y)); sketch.SketchLines.AddByTwoPoints(line2.EndSketchPoint, point); break; } }
/// <summary> /// insert a sketched symbol by the definition above /// </summary> /// <remarks></remarks> public void InsertSketchedSymbolOnSheet() { // Set a reference to the drawing document. // This assumes a drawing document is active. DrawingDocument oDrawDoc = (DrawingDocument)_InvApplication.ActiveDocument; // Obtain a reference to the desired sketched symbol definition. SketchedSymbolDefinition oSketchedSymbolDef = default(SketchedSymbolDefinition); oSketchedSymbolDef = oDrawDoc.SketchedSymbolDefinitions["Circular Callout"]; Sheet oSheet = oDrawDoc.ActiveSheet; // This sketched symbol definition contains one prompted string input. An array // must be input that contains the strings for the prompted strings. string[] sPromptStrings = new string[1]; sPromptStrings[0] = "A"; TransientGeometry oTG = _InvApplication.TransientGeometry; // Add an instance of the sketched symbol definition to the sheet. // Rotate the instance by 45 degrees and scale by .75 when adding. // The symbol will be inserted at (0,0) on the sheet. Since the // start point of the line was marked as the insertion point, the // start point should end up at (0,0). SketchedSymbol oSketchedSymbol = oSheet.SketchedSymbols.Add(oSketchedSymbolDef, oTG.CreatePoint2d(0, 0), (3.14159 / 4), 0.75, sPromptStrings); }
public void AssemblyFeature() { AssemblyDocument oAssDoc = (AssemblyDocument)_InvApplication.ActiveDocument; AssemblyComponentDefinition oAsmDef = oAssDoc.ComponentDefinition; // Create a sketch on the XY workplane. PlanarSketch oSketch = default(PlanarSketch); oSketch = oAsmDef.Sketches.Add(oAsmDef.WorkPlanes[3]); TransientGeometry oTG = default(TransientGeometry); oTG = _InvApplication.TransientGeometry; // Draw a rectangle. oSketch.SketchLines.AddAsTwoPointRectangle(oTG.CreatePoint2d(0.1, 0.1), oTG.CreatePoint2d(1, 0.5)); // Create a profile Profile oProfile = default(Profile); oProfile = oSketch.Profiles.AddForSolid(); // Create the extrusion. ExtrudeDefinition oExtrudeDef = default(ExtrudeDefinition); oExtrudeDef = oAsmDef.Features.ExtrudeFeatures.CreateExtrudeDefinition(oProfile, PartFeatureOperationEnum.kCutOperation); oExtrudeDef.SetDistanceExtent("2 cm", PartFeatureExtentDirectionEnum.kSymmetricExtentDirection); oAsmDef.Features.ExtrudeFeatures.Add(oExtrudeDef); }
internal override void DrawGeom(TransientGeometry TG, ref PlanarSketch sketch, ref List<SketchLine> lines) { try { _length = 0; for (int i = 0; i < index; i++) { _length += var_es._list[i].Length; } switch (Side) { case ('r'): _length += var_es._list[index].Length; sketch.SketchLines.AddAsTwoPointRectangle(TG.CreatePoint2d(_length - Distance - Width, Radius), TG.CreatePoint2d(_length - Distance, var_es._list[index].Radius)); break; case ('l'): sketch.SketchLines.AddAsTwoPointRectangle(TG.CreatePoint2d(_length + Distance, Radius), TG.CreatePoint2d(_length + Distance + Width, var_es._list[index].Radius)); break; } } catch (Exception e1) { MessageBox.Show(e1.ToString()); } }
public EditCoordinate() { InitializeComponent(); oTG = StandardAddInServer.m_inventorApplication.TransientGeometry; oTranslationMatrix = oTG.CreateMatrix(); oMatrix = oTG.CreateMatrix(); }
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(); //} }
internal override void Create_BR(TransientGeometry TG, ref PlanarSketch sketch, EdgeCollection eColl, ref Face B_face, ref Face E_face, ref PartComponentDefinition partDef) { ChamferFeature chamf_Feature; switch (Side) { case ('r'): try { eColl.Add(B_face.Edges[1]); } catch { MessageBox.Show("Catch r"); //eColl.Add(B_face.Edges[2]); } chamf_Feature = partDef.Features.ChamferFeatures.AddUsingDistance(eColl, Distance); break; case ('l'): try { eColl.Add(E_face.Edges[2]); } catch { MessageBox.Show("Catch l"); //eColl.Add(E_face.Edges[1]); } chamf_Feature = partDef.Features.ChamferFeatures.AddUsingDistance(eColl, Distance); break; } }
} //Main form closing private void assemble() { try { path = var_es._Doc.FullFileName.Remove(var_es._Doc.FullFileName.Length - 4); //создаём новый AssemblyDocument assemb_doc = (AssemblyDocument)var_es.InventorApp.Documents.Add(DocumentTypeEnum.kAssemblyDocumentObject, var_es.InventorApp.FileManager.GetTemplateFile(DocumentTypeEnum.kAssemblyDocumentObject), false); AssemblyComponentDefinition assemb_doc_Comp = assemb_doc.ComponentDefinition; //сохраняем созданий AssemblyDocument assemb_doc.SaveAs(path + @"/Shaft.iam", true); //Создаём матрицу TransientGeometry TG = var_es.InventorApp.TransientGeometry; Matrix matrix = TG.CreateMatrix(); //привязываем наш AssemblyDocument в браузере к AssemblyDocument, который открыл пользователь var_es.part_doc = (PartDocument)var_es.InventorApp.Documents.Add(DocumentTypeEnum.kPartDocumentObject, var_es.InventorApp.FileManager.GetTemplateFile(DocumentTypeEnum.kPartDocumentObject), true); PartComponentDefinition doc_def = var_es.part_doc.ComponentDefinition; } catch (Exception e3) { MessageBox.Show(e3.ToString()); } }
///////////////////////////////////////////////////////////// //use: Initialize the Toolkit library // ///////////////////////////////////////////////////////////// public static void Initialize( Inventor.Application Application) { _Application = Application; _Tg = _Application.TransientGeometry; }
internal override void DrawGeom(TransientGeometry TG, ref PlanarSketch sketch, ref List <SketchLine> lines) { Hord = 2 * Math.Sqrt(Depth * (2 * Radius - Depth)); //(2 * Math.Sqrt(Depth * (2 * Radius - Depth))) to calculate hord distance var length = Distance + Hord; _length = 0; for (int i = 0; i < index; i++) { _length += var_es._list[i].Length; } switch (Side) { case ('r'): _length += var_es._list[index].Length; var arc = sketch.SketchArcs.AddByThreePoints(TG.CreatePoint2d(_length - Distance + 0.5 * Hord, var_es._list[index].Radius), TG.CreatePoint2d(_length - Distance, var_es._list[index].Radius - Depth), TG.CreatePoint2d(_length - Distance - 0.5 * Hord, var_es._list[index].Radius)); sketch.SketchLines.AddByTwoPoints(arc.EndSketchPoint, arc.StartSketchPoint); break; case ('l'): arc = sketch.SketchArcs.AddByThreePoints(TG.CreatePoint2d(_length + Distance - 0.5 * Hord, var_es._list[index].Radius), TG.CreatePoint2d(_length + Distance, var_es._list[index].Radius - Depth), TG.CreatePoint2d(_length + Distance + 0.5 * Hord, var_es._list[index].Radius)); sketch.SketchLines.AddByTwoPoints(arc.EndSketchPoint, arc.StartSketchPoint); break; } }
public InventorCamera() { if (invApp == null) { try { invApp = (Inventor.Application)Marshal.GetActiveObject("Inventor.Application"); started = true; } catch (Exception ex) { started = false; invApp = null; return; } } if (invApp.Documents.Count == 0) { opened = false; return; } if (invApp.ActiveDocument.DocumentType == DocumentTypeEnum.kAssemblyDocumentObject || invApp.ActiveDocument.DocumentType == DocumentTypeEnum.kPartDocumentObject || invApp.ActiveDocument.DocumentType == DocumentTypeEnum.kPresentationDocumentObject) { FindType(); opened = true; oView = invApp.ActiveView; oTG = invApp.TransientGeometry; ReturnHome(); oCamera = oView.Camera; } }
private void CreatePart_Click(object sender, EventArgs e) { if (inventor == null) { MessageBox.Show("No inventor instance detected", "error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } PartDocument doc = inventor.Documents.Add(DocumentTypeEnum.kPartDocumentObject, null, true) as PartDocument; doc.PropertySets["{F29F85E0-4FF9-1068-AB91-08002B27B3D9}"]["Author"].Value = "Vladyslav Romanchuk"; //User-defined property doc.PropertySets["{D5CDD505-2E9C-101B-9397-08002B2CF9AE}"].Add("Parts R Us", "Supplier"); PartComponentDefinition partDefinition = (PartComponentDefinition)doc.ComponentDefinition; // Create a 2D sketch on the X-Y plane. PlanarSketch sketch1 = (PlanarSketch)partDefinition.Sketches.Add(partDefinition.WorkPlanes[3]); TransientGeometry tg = inventor.TransientGeometry; Point2d[] points = new Point2d[5] { tg.CreatePoint2d(0, 0), tg.CreatePoint2d(0, 20), tg.CreatePoint2d(20, 20), tg.CreatePoint2d(20, -10), tg.CreatePoint2d(10, -10) }; SketchLine[] lines = new SketchLine[5]; lines[0] = sketch1.SketchLines.AddByTwoPoints(points[0], points[1]); for (int i = 1; i < lines.Length - 1; i++) { lines[i] = sketch1.SketchLines.AddByTwoPoints(lines[i - 1].EndSketchPoint, points[i + 1]); } sketch1.SketchArcs.AddByCenterStartEndPoint(tg.CreatePoint2d(10, 0), lines[3].EndSketchPoint, lines[0].StartSketchPoint, false); //Extrude Profile profile = sketch1.Profiles.AddForSolid(); ExtrudeDefinition extrudeDefinition = partDefinition.Features.ExtrudeFeatures.CreateExtrudeDefinition(profile, PartFeatureOperationEnum.kNewBodyOperation); extrudeDefinition.SetDistanceExtent(6, PartFeatureExtentDirectionEnum.kSymmetricExtentDirection); ExtrudeFeature extrude = (ExtrudeFeature)partDefinition.Features.ExtrudeFeatures.Add(extrudeDefinition); //second scatch Face topCap = extrude.EndFaces[1]; sketch1 = partDefinition.Sketches.Add(topCap, false); Point2d center = sketch1.ModelToSketchSpace(tg.CreatePoint(2.5, 1.5, 1.5)); SketchCircle Circle = sketch1.SketchCircles.AddByCenterRadius(center, 1); profile = sketch1.Profiles.AddForSolid(true, null, null); extrudeDefinition = partDefinition.Features.ExtrudeFeatures.CreateExtrudeDefinition(profile, PartFeatureOperationEnum.kJoinOperation); extrudeDefinition.SetDistanceExtent(4, PartFeatureExtentDirectionEnum.kSymmetricExtentDirection); extrude = (ExtrudeFeature)partDefinition.Features.ExtrudeFeatures.Add(extrudeDefinition); Edges cylinderEdges = extrude.SideFaces[1].Edges; EdgeCollection filletEdges = inventor.TransientObjects.CreateEdgeCollection(null); //foreach (var el in cylinderEdges) // filletEdges.Add(el); filletEdges.Add(cylinderEdges[2]); //adding fillet partDefinition.Features.FilletFeatures.AddSimple(filletEdges, 0.25, false, false, false, false, false, true); //doc.SaveAs("D:\\SaveTest2.ipt", false); }
// create a feature private void createFeature() { PartDocument oDoc = mApp.Documents.Add(DocumentTypeEnum.kPartDocumentObject, mApp.FileManager.GetTemplateFile(DocumentTypeEnum.kPartDocumentObject, SystemOfMeasureEnum.kDefaultSystemOfMeasure, DraftingStandardEnum.kDefault_DraftingStandard, null), true) as PartDocument; // Get the XZ Plane WorkPlane oWorkPlane = oDoc.ComponentDefinition.WorkPlanes[2]; PlanarSketch oSketch = oDoc.ComponentDefinition.Sketches.Add(oWorkPlane, false); TransientGeometry oTG = mApp.TransientGeometry; //Create some transient points used for defining the lines (see BRep Module) Point2d[] oPoints = new Point2d[5]; oPoints[0] = oTG.CreatePoint2d(0, 0); oPoints[1] = oTG.CreatePoint2d(-10, 0); oPoints[2] = oTG.CreatePoint2d(-10, -10); oPoints[3] = oTG.CreatePoint2d(5, -10); oPoints[4] = oTG.CreatePoint2d(5, -5); //Add the sketchlines, coincident constraints will be created automatically //since the "Line.EndSketchPoint" are provided each time we create a new line SketchLine[] oLines = new SketchLine[5]; oLines[0] = oSketch.SketchLines.AddByTwoPoints(oPoints[0], oPoints[1]); oLines[1] = oSketch.SketchLines.AddByTwoPoints(oLines[0].EndSketchPoint, oPoints[2]); oLines[2] = oSketch.SketchLines.AddByTwoPoints(oLines[1].EndSketchPoint, oPoints[3]); oLines[3] = oSketch.SketchLines.AddByTwoPoints(oLines[2].EndSketchPoint, oPoints[4]); oSketch.SketchArcs.AddByCenterStartEndPoint(oTG.CreatePoint2d(0, -5), oLines[3].EndSketchPoint, oLines[0].StartSketchPoint, true); //Create a profile for the extrusion, here no need to worry since there is only //a single profile that is possible Profile oProfile = oSketch.Profiles.AddForSolid(true, null, null); // Definition Way: PartComponentDefinition oPartDocDef = oDoc.ComponentDefinition; // get ExtrudeFeatures collection ExtrudeFeatures extrudes = oPartDocDef.Features.ExtrudeFeatures; // Create an extrude definition in the new surface body ExtrudeDefinition extrudeDef = extrudes.CreateExtrudeDefinition(oProfile, PartFeatureOperationEnum.kJoinOperation); // Modify the extent extrudeDef.SetDistanceExtent(1, PartFeatureExtentDirectionEnum.kPositiveExtentDirection); // Create the extrusion. ExtrudeFeature extrude = extrudes.Add(extrudeDef); }
/// <summary> /// Generate drawing document with input model document /// </summary> /// <param name="filePath">File path for the generated drawing document</param> /// <param name="doc">The Inventor document.</param> private void SaveAsIDW(string filePath, Document doc) { LogTrace("Create a new drawing document"); DrawingDocument drawDoc = (DrawingDocument)inventorApplication.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject); Inventor.Sheet sheet; LogTrace("Get or create a new drawing sheet"); try { if (drawDoc.Sheets.Count > 0) { sheet = drawDoc.Sheets[1]; sheet.Size = DrawingSheetSizeEnum.kA2DrawingSheetSize; } else { sheet = drawDoc.Sheets.Add(DrawingSheetSizeEnum.kA2DrawingSheetSize); } TransientGeometry oTG = inventorApplication.TransientGeometry; Inventor.Point2d pt = oTG.CreatePoint2d(10, 10); LogTrace("Create a base view"); Inventor.DrawingView dv = sheet.DrawingViews.AddBaseView((_Document)doc, pt, 1, ViewOrientationTypeEnum.kIsoTopLeftViewOrientation, DrawingViewStyleEnum.kShadedDrawingViewStyle, "", null, null); LogTrace("Change scale of base drawing view"); dv.Scale = CalculateViewSize(sheet, dv); LogTrace("Create projected view"); Inventor.Point2d pt2 = oTG.CreatePoint2d(dv.Position.X, dv.Position.Y + dv.Height * 1.2); Inventor.DrawingView projView = sheet.DrawingViews.AddProjectedView(dv, pt2, DrawingViewStyleEnum.kShadedDrawingViewStyle); Inventor.Point2d pt3 = oTG.CreatePoint2d(sheet.Width - 5, sheet.Height / 3); LogTrace("Create part list"); Inventor.PartsList pl = sheet.PartsLists.Add(dv, pt3, PartsListLevelEnum.kPartsOnly); Inventor.Point2d pt4 = oTG.CreatePoint2d(sheet.Width / 2, sheet.Height / 4); LogTrace("Create Revision table"); Inventor.RevisionTable rtable = sheet.RevisionTables.Add(pt4); rtable.ShowTitle = true; rtable.Title = "Revision Table Test"; rtable.RevisionTableRows[1][1].Text = "Inventor IO"; rtable.RevisionTableRows[1][3].Text = "Test revision table in drawing"; rtable.RevisionTableRows[1][4].Text = "Autodesk"; LogTrace("Done:Create Revision table"); LogTrace($"Saving IDW {filePath}"); drawDoc.SaveAs(filePath, false); drawDoc.Close(); LogTrace($"Saved IDW as {filePath}"); } catch (Exception e) { drawDoc.Close(); LogError($"Generate IDW fails: {e.Message}"); } }
/// <summary> /// Converts a Point object (which is a 3D Inventor point) into a Point2d object (which is a /// 2D point used in sketches). /// </summary> /// <param name="modelPosition"></param> /// <param name="translatedPoint2d"></param> protected void PointToPoint2d(Point modelPosition, out Point2d translatedPoint2d) { TransientGeometry tG = _inventorApplication.TransientGeometry; Point2d tempPoint2d = tG.CreatePoint2d(); tempPoint2d.X = modelPosition.X; tempPoint2d.Y = modelPosition.Y; translatedPoint2d = tempPoint2d; }
//function to draw shaft with all features public static void Shaft() { partDef = var_es.part_doc.ComponentDefinition; tg = var_es.InventorApp.TransientGeometry; sketch = partDef.Sketches.Add(partDef.WorkPlanes[3]); Edges = default(EdgeCollection); Edges = var_es.InventorApp.TransientObjects.CreateEdgeCollection(); S_Face = null; E_Face = null; Side_F = null; int i = 0, j = 1; foreach (var part in var_es.list) { S_Face = null; E_Face = null; var obj = part; if (obj != null) { obj.Create_BR(tg, ref sketch, Edges, ref S_Face, ref E_Face, ref partDef); } try { if (var_es.chamfer_list.Count != 0) { S_Face = obj.Start_face; E_Face = obj.End_face; if (part is Pol) { Side_F = obj.Side_faces; } Edges = var_es.InventorApp.TransientObjects.CreateEdgeCollection(); if (var_es.chamfer_list[i] != null) { Create feature = var_es.chamfer_list[i]; feature.Create_BR(tg, ref sketch, Edges, ref S_Face, ref E_Face, ref partDef); } Edges = var_es.InventorApp.TransientObjects.CreateEdgeCollection(); S_Face = obj.Start_face; E_Face = obj.End_face; if (var_es.chamfer_list[j] != null) { Create feature = var_es.chamfer_list[j]; feature.Create_BR(tg, ref sketch, Edges, ref S_Face, ref E_Face, ref partDef); } } } catch (Exception e) { MessageBox.Show(e.ToString()); } i += 2; j += 2; } }
/// <summary> /// Sherlock lets you Read all relevant Information for the jsCad processing from a PartDocument Inventor File /// </summary> /// <param name="suspect">your PartDocument you want to get information about</param> public Sherlock(PartDocument suspect, TransientGeometry transGeometry) { Partypart = new MasterM(suspect, transGeometry); #if DEBUG //ShowTestDialoges(); //Partypart.GetExtrudeFeatures(); //List<RevolveFeature> toReturn = Partypart.GetRevolveFeatures(); #endif }
static I() { app = Macros.StandardAddInServer.m_inventorApplication; tg = app.TransientGeometry; objs = app.TransientObjects; nvm = objs.CreateNameValueMap(); nvmDrw = objs.CreateNameValueMap(); nvm.Add("SkipAllUnresolvedFiles", true); nvmDrw.Add("SkipAllUnresolvedFiles", true); nvmDrw.Add("DeferUpdates", true); }
public void GetDistance() { PartComponentDefinition partComponentDefinition = InventorDocument.ComponentDefinition; /*Inventor.WorkPlane*/ int countWorkPlanes = partComponentDefinition.WorkPlanes.Count; foreach (WorkPlane workPlane in partComponentDefinition.WorkPlanes) { var origin = TransientGeometry.CreatePoint(0, 0, 0); var distance = workPlane.Plane.DistanceTo(origin); } }
////////////////////////////////////////////////////////////////////////////////////////////// // Description: Displays PointGraphics with various RenderStyles // ////////////////////////////////////////////////////////////////////////////////////////////// static public void PointGraphicsRenderDemo() { PartDocument doc = AdnInventorUtilities.InvApplication.ActiveDocument as PartDocument; string clientId = "{Add-in Guid}"; ClientGraphics graphics = null; GraphicsDataSets dataSets = null; try { graphics = doc.ComponentDefinition.ClientGraphicsCollection[clientId]; dataSets = doc.GraphicsDataSetsCollection[clientId]; } catch { graphics = doc.ComponentDefinition.ClientGraphicsCollection.Add(clientId); dataSets = doc.GraphicsDataSetsCollection.Add(clientId); } TransientGeometry Tg = AdnInventorUtilities.InvApplication.TransientGeometry; GraphicsNode node = graphics.AddNode(graphics.Count + 1); PointGraphics[] pointGraphics = new PointGraphics[4]; pointGraphics[0] = node.AddPointGraphics(); pointGraphics[1] = node.AddPointGraphics(); pointGraphics[2] = node.AddPointGraphics(); pointGraphics[3] = node.AddPointGraphics(); pointGraphics[0].PointRenderStyle = PointRenderStyleEnum.kCirclePointStyle; pointGraphics[0].CoordinateSet = dataSets.CreateCoordinateSet(dataSets.Count + 1); pointGraphics[0].CoordinateSet.Add(1, Tg.CreatePoint(5, 5, 0)); pointGraphics[1].PointRenderStyle = PointRenderStyleEnum.kCrossPointStyle; pointGraphics[1].CoordinateSet = dataSets.CreateCoordinateSet(dataSets.Count + 1); pointGraphics[1].CoordinateSet.Add(1, Tg.CreatePoint(10, 0, 0)); pointGraphics[2].PointRenderStyle = PointRenderStyleEnum.kXPointStyle; pointGraphics[2].CoordinateSet = dataSets.CreateCoordinateSet(dataSets.Count + 1); pointGraphics[2].CoordinateSet.Add(1, Tg.CreatePoint(5, -5, 0)); pointGraphics[3].PointRenderStyle = PointRenderStyleEnum.kFilledCircleSelectPointStyle; pointGraphics[3].CoordinateSet = dataSets.CreateCoordinateSet(dataSets.Count + 1); pointGraphics[3].CoordinateSet.Add(1, Tg.CreatePoint(0, 0, 0)); doc.Views[1].Update(); }
public PartDocument CreatePartDocument(string DetailName, UnitsTypeEnum LengthUnits, UnitsTypeEnum AngleUnits) { InventorApplication = (Inventor.Application) System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application"); PartDocument part = InventorApplication.Documents.Add(DocumentTypeEnum.kPartDocumentObject, "", true) as PartDocument; part.DisplayName = DetailName; part.UnitsOfMeasure.LengthUnits = LengthUnits; part.UnitsOfMeasure.AngleUnits = AngleUnits; partCompDef = part.ComponentDefinition; transGeom = InventorApplication.TransientGeometry; return(part); }
void DoDemo() { Inventor.Application InvApp = AdnInventorUtilities.InvApplication; if (InvApp.ActiveDocument == null || !(InvApp.ActiveDocument is DrawingDocument)) { System.Windows.Forms.MessageBox.Show( "A Drawing Document must be active...", "Invalid Document Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); return; } _Tg = InvApp.TransientGeometry; _interactionManager = new AdnInteractionManager(InvApp); _interactionManager.Initialize(); _interactionManager.OnTerminateEvent += new AdnInteractionManager.OnTerminateHandler(OnTerminateEvent); _interactionManager.MouseEvents.MouseMoveEnabled = true; _interactionManager.MouseEvents.OnMouseDown += new MouseEventsSink_OnMouseDownEventHandler(MouseEvents_OnMouseDown); _interactionManager.MouseEvents.OnMouseMove += new MouseEventsSink_OnMouseMoveEventHandler(MouseEvents_OnMouseMove); _interactionManager.Start("Place Symbol: "); _clientGraphicsMng = new AdnClientGraphicsManager( AdnInventorUtilities.InvApplication, AdnInventorUtilities.AddInGuid); _clientGraphicsMng.Transacting = true; _clientGraphicsMng.SetGraphicsSource( _interactionManager.InteractionEvents); _symbolNode = null; DrawingDocument document = InvApp.ActiveDocument as DrawingDocument; _sheet = document.ActiveSheet; _symbolNode = null; }
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; } }
/// <summary> /// creating leader text on a sheet. /// Before running this sample, open a drawing document and select a linear drawing edge. /// </summary> /// <remarks></remarks> public void AddLeaderNote() { // Set a reference to the drawing document. // This assumes a drawing document is active. DrawingDocument oDrawDoc = (DrawingDocument)_InvApplication.ActiveDocument; // Set a reference to the active sheet. Sheet oActiveSheet = oDrawDoc.ActiveSheet; // Set a reference to the drawing curve segment. // This assumes that a drawing curve is selected. DrawingCurveSegment oDrawingCurveSegment = oDrawDoc.SelectSet[1]; // Set a reference to the drawing curve. DrawingCurve oDrawingCurve = oDrawingCurveSegment.Parent; // Get the mid point of the selected curve // assuming that the selected curve is linear Point2d oMidPoint = oDrawingCurve.MidPoint; // Set a reference to the TransientGeometry object. TransientGeometry oTG = _InvApplication.TransientGeometry; ObjectCollection oLeaderPoints = _InvApplication.TransientObjects.CreateObjectCollection(); // Create a few leader points. oLeaderPoints.Add(oTG.CreatePoint2d(oMidPoint.X + 10, oMidPoint.Y + 10)); oLeaderPoints.Add(oTG.CreatePoint2d(oMidPoint.X + 10, oMidPoint.Y + 5)); // Create an intent and add to the leader points collection. // This is the geometry that the leader text will attach to. GeometryIntent oGeometryIntent = oActiveSheet.CreateGeometryIntent(oDrawingCurve); oLeaderPoints.Add(oGeometryIntent); // Create text with simple string as input. Since this doesn't use // any text overrides, it will default to the active text style. string sText = null; sText = "API Leader Note"; LeaderNote oLeaderNote = oActiveSheet.DrawingNotes.LeaderNotes.Add(oLeaderPoints, sText); // Insert a node. LeaderNode oFirstNode = oLeaderNote.Leader.RootNode.ChildNodes[1]; LeaderNode oSecondNode = oFirstNode.ChildNodes[1]; oFirstNode.InsertNode(oSecondNode, oTG.CreatePoint2d(oMidPoint.X + 5, oMidPoint.Y + 5)); }
protected BoreEdgeFeatureParamsValidator(TEdgeFeature edgeFeature) { var invApp = Shaft.Application; this.EdgeFeature = edgeFeature; this.BoreFromEdge = edgeFeature.LinkedSection.BoreFromEdge.Value; this.PartDocument = (PartDocument)invApp.Documents.Add(DocumentTypeEnum.kPartDocumentObject, CreateVisible: false); this.ComponentDefinition = this.PartDocument.ComponentDefinition; this.TransientGeometry = invApp.TransientGeometry; BuildTestSections(edgeFeature.LinkedSection); }
internal override void Create_BR(TransientGeometry TG, ref PlanarSketch sketch, EdgeCollection eColl, ref Face B_face, ref Face E_face, ref PartComponentDefinition partDef) { sketch.SketchCircles.AddByCenterRadius(TG.CreatePoint2d(), Radius); Profile profile = sketch.Profiles.AddForSolid(); ExtrudeDefinition extrude = partDef.Features.ExtrudeFeatures.CreateExtrudeDefinition(profile, PartFeatureOperationEnum.kNewBodyOperation); extrude.SetDistanceExtent(Length, PartFeatureExtentDirectionEnum.kPositiveExtentDirection); ExtrudeFeature extrudeFeature = partDef.Features.ExtrudeFeatures.Add(extrude); sketch = partDef.Sketches.Add(extrudeFeature.EndFaces[1]); Start_face = extrudeFeature.StartFaces[1]; End_face = extrudeFeature.EndFaces[1]; Side_face = extrudeFeature.SideFaces[1]; }
//Main form Buttons #region Buttons //ok button private void button2_Click(object sender, EventArgs e) { try { var_es.part_doc.SaveAs(path + @"/Shaft.ipt", true); TransientGeometry TG = var_es.InventorApp.TransientGeometry; Matrix matrix = TG.CreateMatrix(); ComponentOccurrence Shaft1 = var_es._Doc.ComponentDefinition.Occurrences.Add(path + @"/Shaft.ipt", matrix); //ComponentOccurrence Shaft = var_es._Doc.ComponentDefinition.Occurrences.Add(path + @"/Shaft.iam", matrix); var_es.part_doc.Close(true); Close(); } catch { } }
private Inventor.ExtrudeFeature CreateFlangeExtrustion(ref Inventor.PartDocument PartDocument, string FlangeDiaOD, string FlangeDiaID, string FlangeThickness) { Inventor.UnitsOfMeasure UnitsOfMeasure; Inventor.PlanarSketch Sketch; Inventor.TransientGeometry TransientGeometry; Inventor.SketchCircle SketchCircle; Inventor.WorkPoint WorkPoint; Inventor.WorkPlane BaseWorkPlane; Inventor.RadiusDimConstraint RadiusDimConstraint = null; Inventor.SketchEntity SketchEntity; Inventor.ObjectCollection SketchObjectCollection; Inventor.Profile Profile; Inventor.ExtrudeDefinition ExtrudeDefinition; Inventor.ExtrudeFeature ExtrudeFeature = null; SketchObjectCollection = InvApp.TransientObjects.CreateObjectCollection(); UnitsOfMeasure = PartDocument.UnitsOfMeasure; double DiaOD = 0, DiaID = 0, Thickness = 0; DiaOD = UnitsOfMeasure.GetValueFromExpression(FlangeDiaOD, Inventor.UnitsTypeEnum.kMillimeterLengthUnits); DiaID = UnitsOfMeasure.GetValueFromExpression(FlangeDiaID, Inventor.UnitsTypeEnum.kMillimeterLengthUnits); Thickness = UnitsOfMeasure.GetValueFromExpression(FlangeThickness, Inventor.UnitsTypeEnum.kMillimeterLengthUnits); TransientGeometry = InvApp.TransientGeometry; WorkPoint = PartDocument.ComponentDefinition.WorkPoints[1]; BaseWorkPlane = GetPartDocumentWorkPlane(ref PartDocument, "XY"); Sketch = PartDocument.ComponentDefinition.Sketches.Add(BaseWorkPlane, false); SketchEntity = Sketch.AddByProjectingEntity(WorkPoint); SketchCircle = Sketch.SketchCircles.AddByCenterRadius(TransientGeometry.CreatePoint2d(0, 0), DiaOD / 2); RadiusDimConstraint = Sketch.DimensionConstraints.AddRadius((Inventor.SketchEntity)SketchCircle, TransientGeometry.CreatePoint2d(0, 0), false); Sketch.GeometricConstraints.AddCoincident(SketchEntity, (Inventor.SketchEntity)SketchCircle.CenterSketchPoint); RadiusDimConstraint = null; SketchCircle = null; SketchCircle = Sketch.SketchCircles.AddByCenterRadius(TransientGeometry.CreatePoint2d(0, 0), DiaID / 2); RadiusDimConstraint = Sketch.DimensionConstraints.AddRadius((Inventor.SketchEntity)SketchCircle, TransientGeometry.CreatePoint2d(0, 0), false); Sketch.GeometricConstraints.AddCoincident(SketchEntity, (Inventor.SketchEntity)SketchCircle.CenterSketchPoint); SketchObjectCollection.Add(SketchCircle); Profile = Sketch.Profiles.AddForSolid(true, SketchObjectCollection); ExtrudeDefinition = PartDocument.ComponentDefinition.Features.ExtrudeFeatures.CreateExtrudeDefinition(Profile, Inventor.PartFeatureOperationEnum.kNewBodyOperation); ExtrudeDefinition.SetDistanceExtent(Thickness, Inventor.PartFeatureExtentDirectionEnum.kPositiveExtentDirection); ExtrudeFeature = PartDocument.ComponentDefinition.Features.ExtrudeFeatures.Add(ExtrudeDefinition); ExtrudeFeature.Name = "FlangeBase"; return(ExtrudeFeature); }
/// <summary> /// Inserts a member (part/Subassembly or 3D model) in assembly and returns the created occurance /// </summary> /// <param name="assy"></param> /// <param name="inventor">inventor assembly</param> /// <param name="member">any of the supported <see cref="Document"/> types to insert into assembly</param> /// <param name="position">position of the member relative to assembly's origin</param> /// <param name="rotation">rotation about the X and Y and Z axis</param> /// <returns><see cref="ComponentOccurrence"/> that is created inside the assembly</returns> /// <remarks>remeber that Inventors internal units for length are centimeters</remarks> public static ComponentOccurrence AddMemeber(this AssemblyDocument assy, Application inventor, Document member, double[] position, double[] rotation) { if (member.DocumentType == DocumentTypeEnum.kDrawingDocumentObject || member.DocumentType == DocumentTypeEnum.kNoDocument || member.DocumentType == DocumentTypeEnum.kPresentationDocumentObject || member.DocumentType == DocumentTypeEnum.kUnknownDocumentObject) { throw new ArgumentException("documnet type is not supported", nameof(member)); } if (member.FullFileName == "") { throw new Exception("FullFileName of the part object was null, you need to save the part before passing to this method"); } if (position.Length > 3 || rotation.Length > 3) { throw new ArgumentOutOfRangeException("position or rotaion array cannot have more than three memebers"); } // Set a reference to the assembly component definition. AssemblyComponentDefinition oAsmCompDef = assy.ComponentDefinition; // Set a reference to the transient geometry object. TransientGeometry oTG = inventor.TransientGeometry; // Create a matrix. A new matrix is initialized with an identity matrix. Matrix tempMatrix = oTG.CreateMatrix(); Matrix transMatrix = oTG.CreateMatrix(); //for all rotational directions . . . for (int i = 0; i < rotation.Length; i++) { var index = new List <int>(new[] { 0, 0, 0 }); index[i] = 1; var origin = oTG.CreatePoint(0, 0, 0); //rotate about an axis that goeas through origin point and is along the rotaional direction tempMatrix.SetToRotation(MathHelper.ToRadian(rotation[i]), oTG.CreateVector(index[0], index[1], index[2]), origin); transMatrix.TransformBy(tempMatrix); tempMatrix.SetToIdentity(); } //move the object to the position transMatrix.SetTranslation(oTG.CreateVector(position[0], position[1], position[2])); // Add the occurrence. return(oAsmCompDef.Occurrences.Add(member.FullFileName, transMatrix)); }
private void CreateShaft3dmodel(object sender, EventArgs e) { if (listViewShaftElements.Items.Count > 0) { if ((!ModelCreated) & (HeightOfNeighbourElementsIsDifferent())) { PlanarSketch oSketch = default(PlanarSketch); SketchPoints oSkPnts = default(SketchPoints); Object actObj = ThisApplication.ActiveEditObject; oSketch = (PlanarSketch)actObj; oSkPnts = oSketch.SketchPoints; oTransGeom = ThisApplication.TransientGeometry; partDoc = (Inventor.PartDocument)ThisApplication.ActiveDocument; oPartCompDef = partDoc.ComponentDefinition; int TotalLenght2 = 0; foreach (ListViewItem eachItem in listViewShaftElements.Items) { PartOfShaft POShaft = new PartOfShaft(); POShaft.PartHeight = Convert.ToInt32(eachItem.SubItems[1].Text); POShaft.PartWidth = Convert.ToInt32(eachItem.SubItems[2].Text); POShaft.CRectangle(POShaft.PartWidth, POShaft.PartHeight, TotalLenght2); TotalLenght2 = TotalLenght2 + POShaft.PartWidth; tbLenghtOfShaft.Text = Convert.ToString(TotalLenght2); } // Создание центральной оси для будущего вращения прямоугольников вокруг нее. Point2d CentralLine_StartPoint = oTransGeom.CreatePoint2d(0, 0); Point2d CentralLine_EndPoint = oTransGeom.CreatePoint2d(TotalLenght2, 0); SketchLine CentralLineForRevolveAround = default(SketchLine); CentralLineForRevolveAround = oSketch.SketchLines.AddByTwoPoints(CentralLine_StartPoint, CentralLine_EndPoint); // Вращение. oProfile0 = oSketch.Profiles.AddForSolid(); RevolveFeature oRevFeature = default(RevolveFeature); oRevFeature = partDoc.ComponentDefinition.Features.RevolveFeatures.AddFull(oProfile0, CentralLineForRevolveAround, PartFeatureOperationEnum.kNewBodyOperation); // Добавление фасок и кромок. int StartPoint_X = 0, EndPoint_X = 0; double MiddlePoint_X1 = 0, MiddlePoint_X2 = 0; double SizeOfTypeStart = 0, SizeOfTypeEnd = 0; double AngleStart, AngleEnd, SizeOfTypeEnd1, SizeOfTypeEnd2, SizeOfTypeStart1, SizeOfTypeStart2; foreach (ListViewItem eachItem in listViewShaftElements.Items) { Point oPointStart = default(Point); oPointStart = oTransGeom.CreatePoint(StartPoint_X, Convert.ToInt32(eachItem.SubItems[1].Text)); MiddlePoint_X1 = StartPoint_X + Convert.ToDouble(eachItem.SubItems[2].Text) / 2 - 0.02; MiddlePoint_X2 = StartPoint_X + Convert.ToDouble(eachItem.SubItems[2].Text) / 2 + 0.02; StartPoint_X = StartPoint_X + Convert.ToInt32(eachItem.SubItems[2].Text); Point oPointEnd = default(Point); EndPoint_X = StartPoint_X; oPointEnd = oTransGeom.CreatePoint(EndPoint_X, Convert.ToInt32(eachItem.SubItems[1].Text)); Point oPointMiddle = default(Point); oPointMiddle = oTransGeom.CreatePoint(MiddlePoint_X1, Convert.ToInt32(eachItem.SubItems[1].Text)); Face objFaceMiddle = (Face)partDoc.ComponentDefinition.SurfaceBodies[1].LocateUsingPoint(ObjectTypeEnum.kFaceObject, oPointMiddle, 0.01); Object objStart = partDoc.ComponentDefinition.SurfaceBodies[1].LocateUsingPoint(ObjectTypeEnum.kEdgeObject, oPointStart, 0.01); partDoc.SelectSet.Select(objStart); // Определение коллекции начальных углов. EdgeCollection oEdgesStart = default(EdgeCollection); oEdgesStart = ThisApplication.TransientObjects.CreateEdgeCollection(); oEdgesStart.Add(objStart); try { switch (eachItem.SubItems[3].Text) { case "Standart": partDoc.SelectSet.Clear(); break; case "Fillet": SizeOfTypeStart = Convert.ToDouble(eachItem.SubItems[4].Text); FilletFeature oFilletStart = default(FilletFeature); oFilletStart = oPartCompDef.Features.FilletFeatures.AddSimple(oEdgesStart, SizeOfTypeStart); break; case "Chamfer (Distance)": SizeOfTypeStart = Convert.ToDouble(eachItem.SubItems[4].Text); ChamferFeature oChamferStart_D = default(ChamferFeature); oChamferStart_D = oPartCompDef.Features.ChamferFeatures.AddUsingDistance(oEdgesStart, SizeOfTypeStart); break; case "Chamfer (Distance And Angle)": SizeOfTypeStart = Convert.ToDouble(eachItem.SubItems[4].Text); AngleStart = Convert.ToDouble(eachItem.SubItems[6].Text); ChamferFeature oChamferStart_DaA = default(ChamferFeature); oChamferStart_DaA = oPartCompDef.Features.ChamferFeatures.AddUsingDistanceAndAngle(oEdgesStart, objFaceMiddle, SizeOfTypeStart, AngleStart); break; case "Chamfer (Two Distances)": SizeOfTypeStart1 = Convert.ToDouble(eachItem.SubItems[4].Text); SizeOfTypeStart2 = Convert.ToDouble(eachItem.SubItems[5].Text); ChamferFeature oChamferStart_DD = default(ChamferFeature); oChamferStart_DD = oPartCompDef.Features.ChamferFeatures.AddUsingTwoDistances(oEdgesStart, objFaceMiddle, SizeOfTypeStart1, SizeOfTypeStart2); break; } } catch { MessageBox.Show(eachItem.SubItems[3].Text + " " + eachItem.SubItems[4].Text + " " + eachItem.SubItems[5].Text + " " + eachItem.SubItems[6].Text); } Point oPointMiddle2 = default(Point); oPointMiddle2 = oTransGeom.CreatePoint(MiddlePoint_X2, Convert.ToInt32(eachItem.SubItems[1].Text)); Face objFaceMiddle2 = (Face)partDoc.ComponentDefinition.SurfaceBodies[1].LocateUsingPoint(ObjectTypeEnum.kFaceObject, oPointMiddle2, 0.01); Object objEnd = partDoc.ComponentDefinition.SurfaceBodies[1].LocateUsingPoint(ObjectTypeEnum.kEdgeObject, oPointEnd, 0.01); partDoc.SelectSet.Select(objEnd); // Определение коллекции конечных углов. EdgeCollection oEdgesEnd = default(EdgeCollection); oEdgesEnd = ThisApplication.TransientObjects.CreateEdgeCollection(); oEdgesEnd.Add(objEnd); switch (eachItem.SubItems[7].Text) { case "Standart": partDoc.SelectSet.Clear(); break; case "Fillet": SizeOfTypeEnd = Convert.ToDouble(eachItem.SubItems[8].Text); FilletFeature oFilletEnd = default(FilletFeature); oFilletEnd = oPartCompDef.Features.FilletFeatures.AddSimple(oEdgesEnd, SizeOfTypeEnd); break; case "Chamfer (Distance)": SizeOfTypeEnd = Convert.ToDouble(eachItem.SubItems[8].Text); ChamferFeature oChamferEnd_D = default(ChamferFeature); oChamferEnd_D = oPartCompDef.Features.ChamferFeatures.AddUsingDistance(oEdgesEnd, SizeOfTypeEnd); break; case "Chamfer (Distance And Angle)": SizeOfTypeEnd = Convert.ToDouble(eachItem.SubItems[8].Text); AngleEnd = Convert.ToDouble(eachItem.SubItems[10].Text); ChamferFeature oChamferEnd_DaA = default(ChamferFeature); oChamferEnd_DaA = oPartCompDef.Features.ChamferFeatures.AddUsingDistanceAndAngle(oEdgesEnd, objFaceMiddle2, SizeOfTypeEnd, AngleEnd); break; case "Chamfer (Two Distances)": SizeOfTypeEnd1 = Convert.ToDouble(eachItem.SubItems[8].Text); SizeOfTypeEnd2 = Convert.ToDouble(eachItem.SubItems[9].Text); ChamferFeature oChamferEnd_DD = default(ChamferFeature); oChamferEnd_DD = oPartCompDef.Features.ChamferFeatures.AddUsingTwoDistances(oEdgesEnd, objFaceMiddle2, SizeOfTypeEnd1, SizeOfTypeEnd2); break; } } ThisApplication.ActiveView.GoHome(); ModelCreated = true; } else if (ModelCreated) { MessageBox.Show("The 3d model was already created!"); } } }
/// <summary> /// Инициализация приложения /// </summary> public void Initialization(Application InventorApplication) { if (InventorApplication == null) throw new AccessingNullException(); // В открытом приложении создаем метрическуюсборку _partDoc = (PartDocument)InventorApplication.Documents.Add (DocumentTypeEnum.kPartDocumentObject, InventorApplication.FileManager.GetTemplateFile (DocumentTypeEnum.kPartDocumentObject, SystemOfMeasureEnum.kMetricSystemOfMeasure)); //Описание документа _partDef = _partDoc.ComponentDefinition; //инициализация метода геометрии _transGeometry = InventorApplication.TransientGeometry; }