Message 1 of 11
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
It seems that the Vector3D.transformBy and Vector2D.transformBy methods are not taking into account the translation component of the transformation matrix.
For example, I expected that by running the following code, the vector2D would become [10, 20], and the vector3D would become [10, 20, 30]. However, they actually become [10, 0] and [10, 20, 0] respectively (please view the image).
import adsk.core, traceback
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
#----- 2D -----
vector2D = adsk.core.Vector2D.create(10, 0)
translation2D = adsk.core.Vector2D.create(0, 20)
matrix2D = adsk.core.Matrix2D.create()
matrix2D.translation = translation2D
success = vector2D.transformBy(matrix2D)
ui.messageBox(f"Vector2D x: {vector2D.x}, y: {vector2D.y}, Success: {success}")
#----- 3D -----
vector3D = adsk.core.Vector3D.create(10, 20, 0)
translation3D = adsk.core.Vector3D.create(0, 0, 30)
matrix3D = adsk.core.Matrix3D.create()
matrix3D.translation = translation3D
success = vector3D.transformBy(matrix3D)
ui.messageBox(f"Vector3D x: {vector3D.x}, y: {vector3D.y}, z: {vector3D.z}, Success: {success}")
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Is this behaviour a bug or by-design? It is interesting that the Autodesk Inventor API behaves the same way.
If it is by-design, I think it would be a good practice to have the documentation inform users about it.
Website: https://perceptino.com
Solved! Go to Solution.