How can we place a component (ipt) with specific coordonates in a assembly (iam), using VB.NET?
Thank's!
Solved! Go to Solution.
Solved by Owner2229. Go to Solution.
By starting with API help.
"C:\Program Files\Autodesk\Inventor 2016\Local Help\admapi_20_0.chm"
Once you get in there, you will probably see that you need a Transformation matrix to define the position of the part within the context of the assembly. This means that you will have to use UnitsOfMeasure to perform necessary conversions from database units (cm) to your working units.
Also, you will likely need to use TransientGeometry to CreateMatrix for if you plan on using/changing a matrix.
Good luck!
Hi, you can try this. It'll place specified part in currently open assembly.
Red-highlighted values (1, 2, 1) are used to set the position of the placed part. They are in "cm".
' Exit sub if the document isnt assembly
If InventorApplication.ActiveDocument.DocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then Exit Sub
' Specify part to be added
Dim oFile As String = "C:\SomePath\MyPart.ipt"
' Get curently open document Dim oDoc As Inventor.AssemblyDocument = InventorApplication.ActiveDocument
' Create Matrix Dim oTG As Inventor.TransientGeometry = InventorApplication.TransientGeometry Dim oMatrix As Inventor.Matrix = oTG.CreateMatrix Call oMatrix.SetToRotation(3.14159265358979 / 4, oTG.CreateVector(0, 0, 1), oTG.CreatePoint(0, 0, 0)) Call oMatrix.SetTranslation(oTG.CreateVector(1, 2, 1), True)
' Add the part to the assembly
Dim oOcc As Inventor.ComponentOccurrence oOcc = oDoc.ComponentDefinition.Occurrences.Add(oFile, oMatrix)
i know this post is old, but can someone explain the reason for needing a Matrix to place a component?
is there a way to place it by mouse-click like the normal place command?
Thanks,
Jeremy
Can't find what you're looking for? Ask the community or share your knowledge.