Hello together,
how could I move a part to given position including the angles?
To get the position and angles:
Thank you
Georg
Solved! Go to Solution.
Solved by adam.nagy. Go to Solution.
Well, you almost have the answer in full in front of you. Where you can GET the position you can also SET it. I never attempted to do this but the answer is surely in the page below. ( to use links please find the page in the API help file )
Name | Description |
Copy | Creates a copy of this Matrix object. The result is entirely independent and can be edited without affecting the original Matrix object. |
GetCoordinateSystem | Get the coordinate system that this matrix maps to from the standard coordinate system. |
GetMatrixData | Get the data defining this matrix. |
Invert | Invert this matrix. |
IsEqualTo | Compares this matrix for equality with the specified matrix. |
PostMultiplyBy | Method that post-multiplies this matrix by the specified matrix, setting this matrix to the result. |
PreMultiplyBy | Method that post-multiplies this matrix by the specified matrix, setting this matrix to the result. |
PutMatrixData | Method that sets the data defining this matrix. |
SetCoordinateSystem | Sets this matrix to be the matrix that maps from the standard coordinate system to the specified coordinate system. |
SetToAlignCoordinateSystems | Sets this matrix to be the matrix that maps from the 'from' coordinate system to the 'to' coordinate system. |
SetToIdentity | Sets this matrix to the identity matrix. |
SetToRotateTo | Sets to the matrix of rotation that would align the 'from' vector with the 'to' vector. The optional Axis argument may be used when the two vectors are perpendicular and in opposite directions to specify a specific solution, but is otherwise ignored. |
SetToRotation | Sets this matrix to the matrix of rotation by the specified angle, through the specified origin, around the specified axis. |
SetTranslation | Sets the translation portion of the matrix. If the optional ResetRotation flag is True, the rotation portion of the matrix is reset to identity. |
TransformBy | Method that sets this matrix to the result of this transformation followed by the specified transformation (a pre-multiplication of this matrix by the specified matrix). |
Name | Description |
Cell | Property that returns the cell defined by row/col. |
Determinant | Get the determinant of this matrix. |
Translation | Get the translation portion of the matrix. |
Name | Description |
Adding iAssembly occurrences | This sample demonstrates adding iAssembly occurrences to an assembly. |
Adding iPart occurrences to an assembly | This sample demonstrates adding iPart occurrences to an assembly. |
Assembly Add Occurrence | This sample demonstrates placing an assembly occurrence. |
iMate Creation During Occurrence Placement | This sample demonstrates creating multiple iMate results when adding an occurrence into an assembly. This uses the AddUsingiMate method which is the equivalent of using the Place Component command and checking the Use iMate check box on the dialog. |
Demote occurence | This sample demonstrates how to demote a top level occurrence in an assembly into a new sub-assembly occurrence. |
SurfaceBody Copy | This sample demonstrates copying a surface body from one part to another. This is equivalent to the Promote command, but the API is much more flexible. In order for the sample to be self-contained, it creates two parts on the fly that will be used to demonstrate copying a body from one part to another. When copying a body into a part, you provide the surface body and a matrix to define its position in the new part. This sample creates a matrix based on the position of these parts within an assembly. |
Derived Parts and Assemblies | This sample demonstrates the use of the API to create derived parts and assemblies. |
Client Graphics - Line | This sample demonstrates the creation of custom graphics using LineGraphics and LineStripGraphics. The same set of coordinate data is used for both types of graphics. Line graphics use two coordinates to define a line, and then the next two coordinates to define the next line, and so on through the defined coordinates. For the data provided, this results in gaps in the drawn curve. Line strips use the first two coordinates to define the first line and then the last point of the first line becomes the first point of the second line and the next coordinate is used as the end point of the second line. This results in the set of points being connected by a continuous set of lines, drawing a continuous curve. This sample also demonstrates two methods of defining the color for client graphics. In one case it uses an existing rendering style, and in the other, it explicitly defines a color and assigns it. To use the sample you need to have an assembly or part document open. The program has two behaviors: the first time it is run it will draw the graphics. The second time it is run it deletes the previously drawn graphics. |
Create assembly occurrence with representations | This sample demonstrates how to create an assembly occurrence by specifying various representations. |
Assembly Move Occurrence | This sample demonstrates moving a component occurrence. This sample performs a translate, but a rotate can also be performed since the transform is defined using a matrix. |
UCS by transformation matrix | This sample demonstrates the creation of a user coordinate system (UCS) by specifying a transformation matrix. |
' Have the occurrence that will be moved selected. Dim occ As ComponentOccurrence occ = m_invApp.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter, "Select an occurrence.") ' Get the current grounded state of the selected occurrence. Dim groundState As Boolean groundState = occ.Grounded ' Ground the occurrence. occ.Grounded = True ' Get the current transformation matrix from the occurrence. Dim oTransform As Matrix oTransform = occ.Transformation ' Move the occurrence honoring any existing constraints. oTransform.SetTranslation(m_invApp.TransientGeometry.CreateVector(txtbox_X.Text / 10, txtbox_Y.Text / 10, txtbox_Z.Text / 10)) occ.Transformation = oTransform ' Reset the grounded state of the occurrence back to ' its original state. occ.Grounded = groundState
But how could I rotate it around the 3 angels?
Georg
Eurmmm I don't know I bet with one of these 2 methods
Name | Description |
Angle | Input Double that specifies the angle of rotation. |
Axis | Input Vector object. |
Center | Input Point object that specifies the origin. |
Name | Description |
Assembly Add Occurrence | This sample demonstrates placing an assembly occurrence. |
UCS by transformation matrix | This sample demonstrates the creation of a user coordinate system (UCS) by specifying a transformation matrix. |
Name | Description |
From | Input Vector object to align from. |
To | Input Vector object to align to. |
Axis | Input Vector object. |
Also should the grounded state be occ.grounded = false before the move?
A 4x4 matrix is used in computer graphics to specify the position and orientation of objects in 3D space. It's not something specific to Inventor but is common in most all CAD and computer graphics applications. However, that doesn't mean that it's very intuitive to use. I think the best way to understand it is to visualize the matrix as defining a coordinate system in 3D space and the occurrence will be positioned to align with that coordinate system. Here's a link to a paper I presented at AU a few years ago that discusses this, along with a few other topics. Hopefully it will help.
http://modthemachine.typepad.com/files/mathgeometry.pdf
-Brian
Hello Brian,
thank you very much for the PDF. Do you have an example for the transformation and rotation arount all axis?
I could move the part and rotate it arounf one axis.
Georg
Sorry about the slow reply. There's actually an example of rotating around multiple angles in the paper. It's at the end of page 23. The way it works is that you create a matrix that defines the rotation around either the x, y, or z axis and apply that rotation and then you can create another matrix that defines a rotation around one of the primary axes and then you apply that to the existing matrix to create a final matrix that defines both rotations.
To tell you the truth, I don't know what the angles in the Occurrence Properties dialog even represent. What are those angles measuring? Think about a part that has it's own x, y, and z axes and then you rotate that part 45 degrees around the z axis. That's simple and everything makes sense. But now rotate the part 30 degree around the x axis. Where are the axes of the part pointing and how would you define that with three angle values?
If you can describe exactly what it is that you're trying to do I can probably put together some code that does that.
Hello Brian,
to rotate the parts is not the problem. I have an robot arm with 6 axis. From the last arm I would like to store the position including the pitch. After I move the robot I would like to drive the arm to this position (start position) including the stored pitch.
I hope it is clear now.
Thanks
Georg
I would store the position by storing the matrix. Since the bottom row is always [0,0,0,1] you just need to store the other 12 values. You can then use these values to construct a matrix and use it to set the position of the occurrence.
I'll put together a sample. Where do you plane to store the last position? In the assembly file or in an external document of some type?
Here is an example from one I did a while ago:
Hi Georg,
Any particular reason for wanting to store the position in an external file?
You could just simply store it directly in the assembly as well:
http://modthemachine.typepad.com/my_weblog/2017/01/store-and-restore-occurrence-position.html
Cheers,
Hi Georg,
It should be relatively easy to transform the code to save the double values into a file instead.
You just have to figure out how you to identify the "similar" parts in similar models.
Maybe the name of the component is good enough?
Cheers,
Can't find what you're looking for? Ask the community or share your knowledge.