First and simple question

First and simple question

Anonymous
Not applicable
653 Views
7 Replies
Message 1 of 8

First and simple question

Anonymous
Not applicable

Hy to all,

 

Like to extract the angles of an occurrence.

Can get the values of the transformations, but not from the angles, i only need this simple string of code, but I can not find it anywhere.

 

Like the Picture attached, but for the angles of the oOcc

Angles.JPG

Quite the: "OOcc.Transformation." for the angles

 

Any Ideas?

 

Thanks in advance

 

0 Likes
654 Views
7 Replies
Replies (7)
Message 2 of 8

JelteDeJong
Mentor
Mentor

Im not aware of a simple function that can tell you the angles. But the occ.Transformation is a Matrix object that holds all the information about: Translation, Rotation, Reflection, scaling and shearing.

Depending on what you want to do this is can be all the information that you need. But because all information is compressed in a 4x4 matrix can it be a bit difficult to get the specific information out. (like the rotation around the x-axis) Anyway these matrices are a very important in the computer science especially in 3D software. (Also graphical cards are build to be very good and fast in doing matrices calculations. Better than your CPU for example) So it's very interesting topic. But maybe not what you are looking for.

I would suggest to read a paper by "Brian Ekins": "How Deep is the Rabbit Hole?" (on page 18 he starts talking about matrices)

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 3 of 8

dutt.thakar
Collaborator
Collaborator

@Anonymous 

 

As per my knowledge, It is not directly accessible, I think but what you can do is, get the Transformation Matrix for an occurrence and then write your program to do the math operations with first 3 columns and rows, In a 4 x 4 matrix (specifically transformation matrix) the first 3 rows and first 3 columns are part of rotation matrix (respectively for X, Y and Z Axis), what you can do is you can get that data and then do the trig operations (generally cos and sin inverses) and use it to get the angle value.

 

As @JelteDeJong mentioned try reading the paper by Brian, but I think you need to write some math in your program to get the desired results.

 

Hope this will help you.

If this answer has solved your problem please ACCEPT SOLUTION and hit like if you found it helpful..!


Regards,
Dutt Thakar
LinkedIn
Message 4 of 8

Anonymous
Not applicable

Hy @JelteDeJong @dutt.thakar 


Thank you for the hints and resources. Appreciate that!

I also read the paper, quite complex topic.

 

I also found posts that deal with the same problem, or in other words, they all like to manipulate the Matrix (Values)

Thats not what I like to do, I "only" need the current values of each component.

So in the latheral axes (XYZ) this works fine and i can get the data of each part. But not for the Angles.

The Values should already be there- they are saved in the iProperty for each part:

Angles.JPG

So my question, do I have to make all this matrix readouts, or is there a other way?
As you see, the values exists.

 

Thank you for your help

 

Simon

0 Likes
Message 5 of 8

dutt.thakar
Collaborator
Collaborator

@Anonymous 

I was able to get the values of rotation angle with respect to principle axis that you can see in iProperties(physical tab) with below code, but not able to find the angles from this tab. If you are interested in that check the below code.

 

I am just testing it on first occurrence inside an assembly and extracting those values and popping them out in a message box.

 

Dim oDoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim oOcc As ComponentOccurrence = oDoc.ComponentDefinition.Occurrences.Item(1)
Dim Rx As Double 						' About X Axis Angle of rotation
Dim Ry As Double 						' About Y Axis Angle of rotation 
Dim Rz As Double 						' About Z Axis Angle of rotation
Dim oConvert As Double = 180/PI 		' To convert Radians in degrees
oOcc.MassProperties.RotationToPrincipal(Rx, Ry, Rz)
MessageBox.Show("X = " & Rx  * oConvert & vbCr & "Y = " & Ry * oConvert & vbCr & "Z = " & Rz * oConvert)

 

Not sure whether this will help you or not.

If this answer has solved your problem please ACCEPT SOLUTION and hit like if you found it helpful..!


Regards,
Dutt Thakar
LinkedIn
Message 6 of 8

Anonymous
Not applicable

@dutt.thakar @JelteDeJong 

 

Thanks for the try, but this does not work for me it seems.

Get Numbers but far not what i want, the Angles in the part should be 90 0 -90 or something like that.

What I get is:

Angles 2.JPG

I wonder why I have no direct access.

You can write:

iProperties.Value("part1:1", "Project", "Part Number")

And you will end up with the part number.

I found a reference for the IProperty sets, but it seems only reference to a part file.

https://modthemachine.typepad.com/files/ipropertiesandparameters.pdf

On page 13 you find the reference.

With the same set of reference for Assembly it should be possible I think.

Can t find it.

 

Thanks for help!!!

 

Simon

 

0 Likes
Message 7 of 8

JelteDeJong
Mentor
Mentor

you can try this code. I tried to make something from this and this Wikipedia pages. And it seems to work as long as you rotate only over 1 axis. If you rotate over 2 or 3 axis then it gives a different result then Inventor. Probably i have a bug in my calculations. Maybe some one else could improve it.

Dim oDoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim oOcc As ComponentOccurrence = oDoc.ComponentDefinition.Occurrences.Item(1)
Dim t As Matrix = oOcc.Transformation

Dim b = t.Cell(1, 2)
Dim d = t.Cell(2, 1)

Dim c = t.Cell(1, 3)
Dim g = t.Cell(3, 1)

Dim h = t.Cell(3, 2)
Dim f = t.Cell(2, 3)

Dim oConvert As Double = 180 / Math.PI
Dim rX = Math.Round(Math.Asin((f - h) / 2) * oConvert)
Dim rY = Math.Round(Math.Asin((g - c) / 2) * oConvert)
Dim rZ = Math.Round(Math.Asin((b - d) / 2) * oConvert)
MsgBox(rX & " | " & rY & " | " & rZ)

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 8 of 8

Anonymous
Not applicable

@JelteDeJong @dutt.thakar 

 

Seems to work at the first try!

Thank you very much, highly appreciate it!

Angle_3.JPG

I implement the function into my code, to cycle through the whole assembly, and send the coordinates to each part.

Hope this will work, otherwise I would be happy to come back to you!

Will hit the solution button if I am through the process.

 

I have to write code for a customer application/ Add in

 

Thanks a lot!

 

Regards

 

Simon

0 Likes