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] Compart Local WorkAxes to Global WorkAxes

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

[VBA] Compart Local WorkAxes to Global WorkAxes

I am trying to extract part locations from an assembly file.  I've been successful UNTIL I come to a part/subAssembly where the workAxes is orientated differently then the overall assembly axis.  Is it possible to compare the local axis to the global axis?  If the answer is 'yes', can sample code be posted (i.e. dim sameOrientation as bool; sameOrientation = ... )?

 

Also, once I know that "sameOrientation = false," how would one convert local coordinantes to global coordinates?

 

Thank you,

lemensk

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

The component position and orientation relative to the assembly coordinate system is defined by the matrix object that is returned by the ComponentOccurrence.Transformation property.   

Hope the following links could help you to move in the right direction.

 

Examing the Matrix and other Inventor Math and Geometry Objects

http://modthemachine.typepad.com/files/mathgeometry.pdf

 

Occurrences, Contexts, Definitions, Proxies

http://adndevblog.typepad.com/manufacturing/2013/07/occurrences-contexts-definitions-proxies.html

 

Positioning Assembly Occurrences

http://modthemachine.typepad.com/my_weblog/2009/04/positioning-assembly-occurrences.html

 


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, each part is considerded to have the same axis.

 

'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  

Autodesk Design & Make Report