public static List <List <Curve> > getSmothMeshEdgesPerFace(MFnMesh mayaMesh, bool createInMaya = false) { MCommandResult ptcResult = new MCommandResult(); MCommandResult teResult = new MCommandResult(); int numPoly = mayaMesh.numPolygons; List <List <Curve> > curveObjects = new List <List <Curve> >(numPoly); MStringArray ptcResultStr = new MStringArray(); MStringArray teResultStr = new MStringArray(); MStringArray teResultStrFlat = new MStringArray(); List <Curve> tempCurveArray = null; if (createInMaya) { } else { for (int i = 0; i < numPoly; i++) { MGlobal.executeCommand($"polyListComponentConversion -te {mayaMesh.name}.f[{i}]", teResult); teResult.getResult(teResultStr); MGlobal.clearSelectionList(); foreach (var ters in teResultStr) { MGlobal.selectByName(ters, MGlobal.ListAdjustment.kAddToList); } MGlobal.executeCommand($"ls -sl -fl", teResult); teResult.getResult(teResultStrFlat); tempCurveArray = new List <Curve>((int)teResultStrFlat.length); foreach (var e in teResultStrFlat) { MGlobal.executeCommand($"polyToCurve -name deleteMe11232204332AA -form 2 -degree 3 -conformToSmoothMeshPreview 1 {e}", ptcResult); ptcResult.getResult(ptcResultStr); tempCurveArray.Add(DMCurve.CurveFromMfnNurbsCurveFromName(ptcResultStr[0], MSpace.Space.kPostTransform.ToString())); try { MGlobal.deleteNode(DMInterop.getDependNode(ptcResultStr[0])); } catch { MGlobal.displayWarning("getSmothMeshEdges: unable to delete temp object"); } } curveObjects.Add(tempCurveArray); } } return(curveObjects); }
public static List <object> MelCommand(string MelCommand) { MStringArray stringResults = new MStringArray(); MIntArray intResults = new MIntArray(); MDoubleArray doubleResults = new MDoubleArray(); MVectorArray vectorResults = new MVectorArray(); List <object> results = new List <object>(); MCommandResult mcr = new MCommandResult(); MDagPath dag = new MDagPath(); try { MGlobal.executeCommand(MelCommand, mcr); // MGlobal.executeCommand(MelCommand, stringResults); } catch (MemberAccessException e) { MGlobal.displayWarning(e.Message); } switch (mcr.resultType) { case MCommandResult.Type.kStringArray: mcr.getResult(stringResults); results.AddRange(stringResults); break; case MCommandResult.Type.kIntArray: mcr.getResult(intResults); results.AddRange(intResults.Cast <object>()); break; case MCommandResult.Type.kDoubleArray: mcr.getResult(doubleResults); results.AddRange(doubleResults.Cast <object>()); break; case MCommandResult.Type.kVectorArray: mcr.getResult(vectorResults); results.AddRange(vectorResults.Cast <object>()); break; default: mcr.getResult(stringResults); results.AddRange(stringResults); break; } mcr.Dispose(); return(results); }
public static List <Curve> getSmothMeshEdges(MFnMesh mayaMesh, bool createInMaya = false) { //MCommandResult result = new MCommandResult(); int ne = mayaMesh.numEdges; MFnTransform group = new MFnTransform(); List <Curve> curveObjects = new List <Curve>(ne); MStringArray resultStr = new MStringArray(); var fullName = mayaMesh.fullPathName.Split('|'); string transformName = fullName[fullName.Length - 2]; if (createInMaya) { for (int i = 0; i < ne; i++) { using (MCommandResult result = new MCommandResult()) { MGlobal.executeCommand( $"polyToCurve -name {transformName}Curves -form 2 -degree 3 -conformToSmoothMeshPreview 1 {transformName}.e[{i}]", result); result.getResult(resultStr); curveObjects.Add( DMCurve.CurveFromMfnNurbsCurveFromName(resultStr[0], MSpace.Space.kPostTransform.ToString())); } } } else { //Parallel.For(0, ne, i => { for (int i = 0; i < ne; i++) { using (MCommandResult result = new MCommandResult()) { MGlobal.executeCommand( $"polyToCurve -name deleteMe11232204332AA -form 2 -degree 3 -conformToSmoothMeshPreview 1 {transformName}.e[{i}]", result); result.getResult(resultStr); curveObjects.Add( DMCurve.CurveFromMfnNurbsCurveFromName(resultStr[0], MSpace.Space.kPostTransform.ToString())); try { MGlobal.deleteNode(DMInterop.getDependNode(resultStr[0])); } catch { MGlobal.displayWarning("getSmothMeshEdges: unable to delete temp object"); } } } // }); } return(curveObjects); }
internal static bool GetBoolProperty(string property, bool defaultValue = false) { bool value = defaultValue; MCommandResult result = new MCommandResult(); MGlobal.executeCommand($"fileInfo -q \"{property}\"", result); if (result.resultType == MCommandResult.Type.kStringArray) { MStringArray stringArray = new MStringArray(); result.getResult(stringArray); value = string.Join("", stringArray.ToArray()).Equals(true.ToString()); } return(value); }
internal static bool GetUserPropString(string property, ref string value) { MCommandResult result = new MCommandResult(); MGlobal.executeCommand($"fileInfo -q \"{property}\"", result); if (result.resultType == MCommandResult.Type.kStringArray) { MStringArray stringArray = new MStringArray(); result.getResult(stringArray); value = string.Join("", stringArray.ToArray()); } else { value = null; } return(!string.IsNullOrEmpty(value)); }