diff --git a/MeshExporter.py b/MeshExporter.py index 40947cd..f483486 100644 --- a/MeshExporter.py +++ b/MeshExporter.py @@ -169,10 +169,10 @@ def runMesh(wheelNames): # Leave this here in case I need to debug again # Create a graphics group on the root component. - #graphics = rootComp.customGraphicsGroups.add() + # graphics = rootComp.customGraphicsGroups.add() # Adds Point Graphic - #coord = adsk.fusion.CustomGraphicsCoordinates.create(point.asArray()) - #point = graphics.addPointSet(coord, [0], adsk.fusion.CustomGraphicsPointTypes.UserDefinedCustomGraphicsPointType, + # coord = adsk.fusion.CustomGraphicsCoordinates.create(point.asArray()) + # point = graphics.addPointSet(coord, [0], adsk.fusion.CustomGraphicsPointTypes.UserDefinedCustomGraphicsPointType, # 'SelectJoint.png') @@ -184,17 +184,25 @@ def runMesh(wheelNames): originalCam = app.activeViewport.camera # Move to Up cam = app.activeViewport.camera - cam.viewOrientation = 10 + cam.viewOrientation = adsk.core.ViewOrientations.TopViewOrientation cam.isSmoothTransition = False app.activeViewport.camera = cam + + adsk.doEvents() + app.activeViewport.refresh() + app.activeViewport.fit() # Capture Up cam = app.activeViewport.camera yVector = returnNormalVector(cam.eye) # Move to Forward - cam.viewOrientation = 3 + cam.viewOrientation = adsk.core.ViewOrientations.FrontViewOrientation cam.isSmoothTransition = False app.activeViewport.camera = cam + + adsk.doEvents() + app.activeViewport.refresh() + app.activeViewport.fit() # Capture Forward cam = app.activeViewport.camera @@ -206,6 +214,12 @@ def runMesh(wheelNames): global newTransform, inverseTransform newTransform = adsk.core.Matrix3D.create() origin = adsk.core.Point3D.create(0, 0, 0) + xVector = yVector.crossProduct(zVector) + if xVector.length < 1e-6: + ui.messageBox(f"Invalid coordinate system.\n" + f"yVector: {yVector.x}, {yVector.y}, {yVector.z}\n" + f"zVector: {zVector.x}, {zVector.y}, {zVector.z}") + return False newTransform.setToAlignCoordinateSystems(origin, yVector.crossProduct(zVector), yVector, zVector, origin, adsk.core.Vector3D.create(-1, 0, 0), adsk.core.Vector3D.create(0, 1, 0), adsk.core.Vector3D.create(0, 0, -1)) # Adds on origin as well