Message 1 of 7
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am getting this error when trying to perform a transform on a sketch.
RuntimeError: 2 : InternalValidationError : xlMat->isValidNonScaledTransformMatrix()
I made this to try and force the matrix to by valid
def forcePlanar(matrix:adsk.core.Matrix3D):
o,x,y,z = matrix.getAsCoordinateSystem()
app.log("Original Matrix")
app.log(f'asArray: {matrix.asArray()}')
app.log(f'X length = {x.length}')
app.log(f'Y length = {y.length}')
app.log(f'Z length = {z.length}')
app.log(f'XY Angle = {math.degrees(x.angleTo(y))}')
app.log(f'XZ Angle = {math.degrees(x.angleTo(z))}')
app.log(f'YZ Angle = {math.degrees(y.angleTo(z))}')
app.log(" ")
x.normalize()
y.normalize()
z.normalize()
xVec = y.crossProduct(z)
if math.degrees(xVec.angleTo(x)) > 90:
xVec.scaleBy(-1)
xVec.normalize()
yVec = xVec.crossProduct(z)
if math.degrees(yVec.angleTo(y)) > 90:
yVec.scaleBy(-1)
yVec.normalize()
zVec = xVec.crossProduct(yVec)
if math.degrees(zVec.angleTo(z)) > 90:
zVec.scaleBy(-1)
zVec.normalize()
xVec.normalize()
yVec.normalize()
zVec.normalize()
matrix = adsk.core.Matrix3D.create()
matrix.setWithCoordinateSystem(o,xVec,yVec,zVec)
app.log("Fixed Matrix")
app.log(f'asArray: {matrix.asArray()}')
app.log(f'X length = {xVec.length}')
app.log(f'Y length = {yVec.length}')
app.log(f'Z length = {zVec.length}')
app.log(f'XY Angle = {math.degrees(xVec.angleTo(yVec))}')
app.log(f'XZ Angle = {math.degrees(xVec.angleTo(zVec))}')
app.log(f'YZ Angle = {math.degrees(yVec.angleTo(zVec))}')
return matrix
But I am still getting this error:
Original Matrix
asArray: (-0.9866242022022309, 0.1492357286775443, -0.06558491377514467, 2.5736278824387266, 0.15800404365975573, 0.9744559705989259, -0.15959412129295647, -0.7649845830225152, -0.040092465825598715, 0.16782210417637858, 0.9850016931629284, 1.7089296320501064, 0.0, 0.0, 0.0, 1.0)
X length = 0.9999999999999997
Y length = 0.9999999999999998
Z length = 0.9999999999999999
XY Angle = 90.0
XZ Angle = 90.0
YZ Angle = 90.0
Fixed Matrix
asArray: (-0.9866242022022313, 0.14923572867754434, -0.06558491377514467, 2.5736278824387266, 0.15800404365975573, 0.9744559705989261, -0.1595941212929565, -0.7649845830225152, -0.04009246582559872, 0.1678221041763786, 0.9850016931629284, 1.7089296320501064, 0.0, 0.0, 0.0, 1.0)
X length = 1.0
Y length = 1.0
Z length = 0.9999999999999999
XY Angle = 90.0
XZ Angle = 90.0
YZ Angle = 90.0
Failed:
Traceback (most recent call last):
line 346, in transformSketch:
sketch.transform = matrix
^^^^^^^^^^^^^^^^
File "C:\......\adsk\fusion.py", line 45318, in _set_transform
return _fusion.Sketch__set_transform(self, value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: 2 : InternalValidationError : xlMat->isValidNonScaledTransformMatrix()
Am I doing something wrong here? I am not sure how to stop the vectors from being ever so slightly not unit length.
Solved! Go to Solution.