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: 

[VBA] Location of a part in an assembly file

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
lemensk
1327 Views, 2 Replies

[VBA] Location of a part in an assembly file

Is it possible to identify the location of a part in an assembly file?

 

I cannot access (or find access to) global locations, just local.  You may ask, whats the problem?  Well, right now, I have 10 subAssemblies and they are all "located" at (0,0,0), which means I have 10 solids sharing the exact same space. This problem can be easily fixed if I can compare the Global Origin to a Local Origin, but I can only find the "work axes origin" which is worthless to me.

 

Any assistence/material would be appriciated.

 

Thank you,

-lemensk

2 REPLIES 2
Message 2 of 3
Vladimir.Ananyev
in reply to: lemensk

Location and orientation of the component in the assembly coordinate system is controlled by component’s matrix object.

Could you please look at this thread

http://forums.autodesk.com/t5/Inventor-Customization/VBA-Compart-Local-WorkAxes-to-Global-WorkAxes/m...


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Message 3 of 3
lemensk
in reply to: Vladimir.Ananyev

Below is the answer to my question.  Surprised how hard it was to get such simple code:

 

'CODE START ---------------------------------

Sub printParts()
   Dim inventDoc As Inventor.AssemblyDocument
   Dim deltaX, deltaY, deltaZ, avgX, avgY, avgZ, minX, minY, minZ, maxX, maxY, maxZ As Double
   Dim fileName, strg As String

   Dim partOccur As Inventor.ComponentOccurrence

   Set inventDoc = ThisApplication.ActiveDocument
   fileName = inventDoc.DisplayName

   For Each partOccur In inventDoc.ComponentDefinition.Occurrences.AllLeafOccurrences   'For each part included in the assembly
       strg = partOccur.Name & ";" & partOccur.RangeBox.minPoint.X & ";" & partOccur.RangeBox.minPoint.Y & _

                 ";" & partOccur.RangeBox.minPoint.Z


      Open "C:\Temp\" & fileName & ".txt" For Append As #1 'Open txt file and Append
      Print #1, strg                                                                         'Print String
      Close #1                                                                                'Close txt file
   Next
   
End Sub


 

'CODE STOP ---------------------------------

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

Post to forums