Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Place component (ipt) in a assembly (iam) using VB.NET

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
Anonymous
1706 Views, 6 Replies

Place component (ipt) in a assembly (iam) using VB.NET

How can we place a component (ipt) with specific coordonates in a assembly (iam), using VB.NET?

 

Thank's!

6 REPLIES 6
Message 2 of 7
MechMachineMan
in reply to: Anonymous

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!


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 3 of 7
Anonymous
in reply to: MechMachineMan

Can you be more precise?  Exemples will do the job.

 

Thank's!

Message 4 of 7
Owner2229
in reply to: Anonymous

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)

 

 

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
Message 5 of 7
Anonymous
in reply to: Owner2229

Thank's Mike, it work!
Message 6 of 7
jpchaisson
in reply to: Owner2229

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

Message 7 of 7

I'm interested in this too. Placing by Matrix is fine, but having a UI control like the default placement one would be great.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report