Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Export Occurrence iProperties?

17 REPLIES 17
Reply
Message 1 of 18
DaveEno
1800 Views, 17 Replies

Export Occurrence iProperties?

I would like to export the Current Offset from Parent Assembly Origin values (X Offset, Y Offset, Z Offset, X Angle, Y Angle, Z Angle) for each part in an Assembly.  These values are found in each component's iProperties under the Occurrence tab.  Can anyone help?

 

Thanks!

 

Dave E.

 

17 REPLIES 17
Message 2 of 18
tsreagan
in reply to: DaveEno

What do you wnat to export them too?  A text file, with part name and the values perhaps?

 

If so you need an ilogic rule that will cycle through the parts and populate a text document line by line with part name and the offset values.

 

T.S.

Message 3 of 18
DaveEno
in reply to: tsreagan

Yes, a text file id fine.  Do you know where the values are stored / where they can be accessed from?

 

Thanks.

 

D

Message 4 of 18
tsreagan
in reply to: tsreagan

I have a rule that will cycle through all occurances in an assembly, even the parts within sub assemblies,

you will need to add in some lines of code to pull the iproperties you want from each occurance and

pump them into a text file.

 

T.S.

Message 5 of 18
tsreagan
in reply to: DaveEno

Not sure of the exact sysntax to get those properties from an occurance.

If i get time tomorrow I will look into it for ya.

 

 

T.S.

Message 6 of 18
DaveEno
in reply to: tsreagan

Thanks!  I got this to work....except for accessing the data I want.  I can find everything except the XYZ Offsets and Angles from the Occurrence tab of individual parts in assemblies.  Can you help?

 

Thanks again!

 

Dave

Message 7 of 18
tsreagan
in reply to: DaveEno

I have searched and searched for an example that covers what you want, and have found none.

I keep running into examples of how to move your part based on transformation matrices,

But I have no idea how to simply list the values you want.

 

Xoffset is on the occurrence tab,  but I don't know how to get to it from within a component occurrence object.

 

In the programming help documentation Xoffset is listed as a parameter of UserCoordinateSystem and UserCoordinateSystemProxy, but I am not sure if these are related to the values shown under the occurrence tab, or whether those values are calculated by using a transformation matrix in some way.

 

Anyone??

 

 

T.S.

Message 8 of 18
DaveEno
in reply to: DaveEno

T.S.

 

Thanks.  We're in the same boat.  If I figure it out, I'll let you know!

 

D.E.

 

Message 9 of 18
tsreagan
in reply to: DaveEno

It's on the occurance tab,  so it should be easy to get at,  we just don't know the secret.

 

Maybe the dev's could chime in and give us a clue.

 

T.S.

Message 10 of 18
cwhetten
in reply to: tsreagan

Here is how you access the X, Y, and Z offsets:

 

***********

oTransform = ThisDoc.Document.ComponentDefinition.Occurrences.Item(1).Transformation.Translation

xoffset = oTransform.X / 2.54
yoffset = oTransform.Y / 2.54
zoffset = oTransform.Z / 2.54
*************

 

Of course, this is only for one item, but you can add it to your code that iterates through all component occurrences.  Also, I divided each by 2.54 to convert to inches (just remember that the offsets returned by the code will be in centimeters, so you may need to convert to your units of interest).

 

I can't figure out how to get the angle offsets.  It's odd to me that they are always grayed out in the iProperties Occurrence tab.  Also, they don't show up in a debug watch in the VBA editor:

 

Transformation Matrix Debug.png

 

So...?  I think it may have something to do with the matrix method called SetToRotation, but I don't know how it works.

 

Cameron Whetten
Inventor 2012

Message 11 of 18
DaveEno
in reply to: cwhetten

It appears that ComponentOccurrence.Transformation is a 4x4 homogeneous Matrix that performs the rotation and translation of the part.  The Matrix elements are ComponentOccurrence.Transformation.Cell(1,1) thru ComponentOccurrence.Transformation.Cell(4,4).  The rotational angles can be computed from (Cell(1,1) thru Cell(3,3).

 

Thank you for all your help.

 

DE

 

Message 12 of 18
cwhetten
in reply to: DaveEno

Yes, I think you're right.  If this is the case, then the Translation property conveniently extracts the origin coordinates from the matrix.  Unfortunately, it doesn't look like the X, Y, and Z angles shown in the occurrences tab are as conveniently accessible from a simple property.  I think it will require few extra operations involving dot products to get the values shown in the occurrences tab.

 

I am investigating further to see if this is the case.

 

Cameron Whetten
Inventor 2012

Message 13 of 18
cwhetten
in reply to: cwhetten

Here is what I came up with:

 

Spoiler

oTransform = ThisDoc.Document.ComponentDefinition.Occurrences.Item(1).Transformation

xoffset = oTransform.Translation.X / 2.54
yoffset = oTransform.Translation.Y / 2.54
zoffset = oTransform.Translation.Z / 2.54

Dim oTG As TransientGeometry
oTG = ThisApplication.TransientGeometry

oXAxis = oTG.CreateVector(1,0,0)
oYAxis = oTG.CreateVector(0,1,0)
oZAxis = oTG.CreateVector(0,0,1)

oPartX = oTG.CreateVector(oTransform.Cell(1,1),oTransform.Cell(2,1),oTransform.Cell(3,1))
oPartY = oTG.CreateVector(oTransform.Cell(1,2),oTransform.Cell(2,2),oTransform.Cell(3,2))
oPartZ = oTG.CreateVector(oTransform.Cell(1,3),oTransform.Cell(2,3),oTransform.Cell(3,3))

xAngleOffset = ArcCos(oPartX.DotProduct(oXAxis))*180/PI 'Angular offset between component X-axis and assembly X-axis
yAngleOffset = ArcCos(oPartY.DotProduct(oYAxis))*180/PI 'Angular offset between component Y-axis and assembly Y-axis
zAngleOffset = ArcCos(oPartZ.DotProduct(oZAxis))*180/PI 'Angular offset between component Z-axis and assembly Z-axis

 

Here is what I get from running this rule:

 

Rule Output.PNG

 

And here is what is shown on the occurrence tab:

 

Occurrence tab.PNG

 

I can't figure out exactly how the values on the occurrence tab are calculated...  Between which entities are the reported angles computed?

 

Cameron Whetten
Inventor 2012

Message 14 of 18
DaveEno
in reply to: cwhetten

I was going to use Euler Angles to compute the rotation matrix from the given angles.  Since the rotation matrix is given, I don't have to do that anymore.  For "fun", I might use the matrix values and work backwards to get the angles.  If I do, I'll post it here.

 

Thank you for all the help!  This is good stuff!

 

Dave E.

 

Message 15 of 18
cwhetten
in reply to: cwhetten

Just wanted to post a quick correction.  The last three lines of code should be like so:

 

xAngleOffset = Acos(oPartX.DotProduct(oXAxis))*180/PI 'Angular offset between component X-axis and assembly X-axis
yAngleOffset = Acos(oPartY.DotProduct(oYAxis))*180/PI 'Angular offset between component Y-axis and assembly Y-axis
zAngleOffset = Acos(oPartZ.DotProduct(oZAxis))*180/PI 'Angular offset between component Z-axis and assembly Z-axis

 

The difference is that it should be Acos( ) and not ArcCos( ) as I had before.

 

Cameron Whetten
Inventor 2012

Message 16 of 18
tsreagan
in reply to: cwhetten

Knowing what the dot product is doing helps understand it a bit better.

 

In mathematics, the dot product, or scalar product (or sometimes inner product in the context of Euclidean space), is an algebraic operation that takes two equal-length sequences of numbers (usually coordinate vectors) and returns a single number. This operation can be defined either algebraically or geometrically. Algebraically, it is the sum of the products of the corresponding entries of the two sequences of numbers. Geometrically, it is the product of the magnitudes of the two vectors and the cosine of the angle between them. The name "dot product" is derived from the centered dot\cdot " that is often used to designate this operation; the alternative name "scalar product" emphasizes the scalar (rather than vectorial) nature of the result.

 

Special thanks to Wikipedia.

 

T.S.

Message 17 of 18
cwhetten
in reply to: tsreagan

Thanks.  As you state, the dot product is taken between two vectors.  My question is which two vectors are being considered by Inventor when it reports the angle offsets in the iProperties > Occurrence tab?

 

Occurrence tab angles.png

 

My first assumption (and the assumption I took when I wrote the code I posted earlier) was that the reported X Angle would be the angle between the part x-axis and the assembly x-axis (and so forth for the Y and Z Angles).  In the code I posted earlier, I used the dot product between a unit vector representing the assembly x-axis (1,0,0) and the unit vector extracted from the tranformation matrix (the first column) that I assume is parallel with the component x-axis (this assumption comes from my interpretation of the description of the transformation matrix in the Inventor API reference document--see below).

 

API article on matrices.PNG

 

However, while it appears that my code does indeed give the correct angles between the axes like I assumed, these are not the same values reported on the occurrence tab.  So I am still trying to figure out what entities the reported angles are between.

 

Cameron Whetten
Inventor 2012

Message 18 of 18
bharath_hs
in reply to: cwhetten

Hi, Thanks for all the information shared. Could you please share the code that is the 'Spoiler' link? and did you find a way to get the Angle Offsets for the occurrence? I'm also working on the same. Thanks in advance.

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

Post to forums  

Autodesk Design & Make Report