
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I have been given the task to export some key information from Inventor to a different 3D software (Blender).
I do not know much about Inventor as it is not my main field of work. I have been reading solutions on the forum but I don't understand the results I get.
I am testing with a simple assembly representing a cylinder. There are 2 parts: the cylinder main body, and the piston.
I need to get the data on the ORIGINS of each part, as an offset to the main assembly's origin (0,0,0).
I have tried using Occurrence.Transformation.Translation to get the Vector from the Origin, but the results don't match what I see in the IProperties window!!! at least, the Y and Z coordinates.
The code:
Public Sub getObjectsOrigins() ' Get the active assembly. Dim oAsmDoc As Document Set oAsmDoc = ThisApplication.ActiveDocument ' Get the assembly component definition. Dim oAsmDef As AssemblyComponentDefinition Set oAsmDef = oAsmDoc.ComponentDefinition 'Loop through scene assemblies Dim oOcc As ComponentOccurrence For Each oOcc In oAsmDef.Occurrences Debug.Print oOcc.Name & " - has " & CStr(oOcc.Definition.Occurrences.Count) & " children" 'Iterate through parts If (oOcc.Definition.Occurrences.Count > 0) Then Dim oChild As ComponentOccurrence For Each oChild In oOcc.Definition.Occurrences Debug.Print (vbTab & vbTab & "Part: " & oChild.Name) Debug.Print (vbTab & "Origin: " & CStr(oChild.Transformation.Cell(1, 4)) & ", " & CStr(oChild.Transformation.Cell(2, 4)) & ", " & CStr(oChild.Transformation.Cell(3, 4))) 'This gives the same result as above 'Debug.Print (vbTab & "Origin: " & CStr(oChild.Transformation.Translation.X) & ", " & CStr(oChild.Transformation.Translation.Y) & ", " & CStr(oChild.Transformation.Translation.Z)) Next End If Next Set oOcc = Nothing Set oAsmDef = Nothing Set oAsmDoc = Nothing End Sub
The output from the code. If you compare element X, the results are very different.
cilinder:1 - has 4 children
Part: cilinder:1
Origin: 0, 0, 0
Part: gaffel cilinder:1
Origin: -6.9, -2.88657986402541E-15, 0
Part: gec40-01:1
Origin: -6.9, -2.28215382142666E-15, -4.44089209850063E-16
Part: gec40-02:1
Origin: -6.9, -2.06010921650163E-15, -4.44089209850063E-16
zuiger:1 - has 4 children
Part: zuiger:1
Origin: 0, 0, 0
Part: stangkop:1
Origin: 113, 5.32222989921713E-15, -3.19933921501746E-17
Part: gec40-01:1
Origin: 121.5, 5.540951718455E-15, -4.74410459210098E-16
Part: gec40-02:1
Origin: 121.5, 5.5409517184549E-15, -4.74410459210112E-16
Comparing IProperties of "stangkop:1" element with the output from the vba script:
IProperties:
Offset X = 1130.000 mm
Offset Y = 0.000 mm
Offset Z = -0.000 mm
Vba output:
Origin X = 113
Origin Y = 5.32222989921713E-15
Origin Z = -3.19933921501746E-17
What am I missing?
thank you in advance
Solved! Go to Solution.