void printTransformData(MDagPath dagPath, bool quiet) { MObject transformNode = null; try { transformNode = dagPath.transform; } catch (System.Exception) { // This node has no transform - i.e., it's the world node // return; } MFnDagNode transform = null; try { transform = new MFnDagNode(transformNode); } catch (System.Exception) { return; } MTransformationMatrix matrix = new MTransformationMatrix(transform.transformationMatrix); if (!quiet) { MGlobal.displayInfo(" translation: " + MVectorToString(matrix.translation(MSpace.Space.kWorld)) + Environment.NewLine); } double[] threeDoubles = new double[3]; int rOrder = 0; matrix.getRotation(threeDoubles, out rOrder, MSpace.Space.kWorld); if (!quiet) { MGlobal.displayInfo(string.Format(" rotation: [%f, %f, %f]\n", threeDoubles[0], threeDoubles[1], threeDoubles[2])); } matrix.getScale(threeDoubles, MSpace.Space.kWorld); if (!quiet) { MGlobal.displayInfo(string.Format(" scale: [%f, %f, %f]\n", threeDoubles[0], threeDoubles[1], threeDoubles[2])); } }
void printTransformData(MDagPath dagPath, bool quiet) { MObject transformNode = null; try { transformNode = dagPath.transform; } catch (System.Exception) { // This node has no transform - i.e., it's the world node // return; } MFnDagNode transform = null; try { transform = new MFnDagNode(transformNode); } catch (System.Exception ) { return; } MTransformationMatrix matrix = new MTransformationMatrix(transform.transformationMatrix); if (!quiet) { MGlobal.displayInfo(" translation: " + MVectorToString(matrix.translation(MSpace.Space.kWorld)) + Environment.NewLine); } double[] threeDoubles = new double[3]; int rOrder = 0; matrix.getRotation (threeDoubles, out rOrder, MSpace.Space.kWorld); if (!quiet) { MGlobal.displayInfo(string.Format(" rotation: [%f, %f, %f]\n", threeDoubles[0], threeDoubles[1], threeDoubles[2])); } matrix.getScale (threeDoubles, MSpace.Space.kWorld); if (!quiet) { MGlobal.displayInfo(string.Format(" scale: [%f, %f, %f]\n", threeDoubles[0], threeDoubles[1], threeDoubles[2])); } }