Пример #1
0
        private void userDAGInstanceRemovedCB(object sender, MParentChildFunctionArgs arg)
        {
            MDagPath child  = arg.child;
            MDagPath parent = arg.parent;
            string   dagStr = userDAGCBHelper("DAG Changed - Unknown Type: ", child, parent);

            MGlobal.displayInfo(dagStr);
        }
        void AddMenuItem(string label, string parentMenuName, string command, int paramInt)
        {
            string cmdStr = "menuItem -l \"" + label + "\" -p \"" + parentMenuName + "\" -c \"" + command + " " + paramInt + "\"";

            //Debug.Log(cmdStr);
            MGlobal.executeCommand(cmdStr);
            //MGlobal.executeCommand(cmdStr);
        }
Пример #3
0
        private void userDAGChildReorderedCB(object sender, MParentChildFunctionArgs arg)
        {
            MDagPath child  = arg.child;
            MDagPath parent = arg.parent;
            string   dagStr = userDAGCBHelper("DAG Changed - Child Reordered: ", child, parent);

            MGlobal.displayInfo(dagStr);
        }
Пример #4
0
        public static void Create(MFnDependencyNode materialDependencyNode)
        {
            // Create Babylon Material dependency node
            string babylonMaterialNodeName;

            MGlobal.executeCommand($"shadingNode -asShader babylonStingrayPBSMaterialNode;", out babylonMaterialNodeName);
            MGlobal.executeCommand($"connectAttr -f {materialDependencyNode.name}.outColor {babylonMaterialNodeName}.outTransparency;");
        }
Пример #5
0
        public static void Select(MSelectionList list, bool selectInComponentMode = false)
        {
            MGlobal.setActiveSelectionList(list);

            if (selectInComponentMode)
            {
                Debug.Log("select in component mode");
                List <MSelectionList> facesListToAdd = new List <MSelectionList>();

                MItSelectionList it_selectionList = new MItSelectionList(list);
                Debug.Log("has components:" + it_selectionList.hasComponents);

                for (; !it_selectionList.isDone; it_selectionList.next())
                {
                    MObject  component = new MObject();
                    MDagPath item      = new MDagPath();
                    it_selectionList.getDagPath(item, component);

                    //Debug.Log(item.fullPathName + " has components:" + it_selectionList.hasComponents);
                    //List<int> selectedIndcies = new List<int>();
                    //MItMeshPolygon it_poly = new MItMeshPolygon(item, component);
                    if (!it_selectionList.hasComponents)
                    {
                        //Debug.Log("没有组件被选择,怀疑是一整个物体:" + item.fullPathName);
                        BasicFunc.SelectComponent(item.fullPathName, ConstantValue.PolySelectType.Facet, true);
                        facesListToAdd.Add(BasicFunc.GetSelectedList());
                    }
                    //else
                    //{
                    //    Debug.Log("有组件被选择:" + it_poly.count());
                    //}
                }
                if (facesListToAdd.Count > 0)
                {
                    MGlobal.setActiveSelectionList(list);
                    for (int i = 0; i < facesListToAdd.Count; i++)
                    {
                        MGlobal.setActiveSelectionList(facesListToAdd[i], MGlobal.ListAdjustment.kAddToList);
                    }
                }
            }
            //bool hasDag = false;

            //if (hasDag)
            //{
            //    Debug.Log("has dag length:" + list.length);
            //    foreach (MDagPath dag in list.DagPaths())
            //    {
            //        Debug.Log(dag.fullPathName);
            //    }
            //    MGlobal.setActiveSelectionList(list);
            //}
            //else
            //{
            //    Debug.Log("no dag but length:" + list.length);
            //    MGlobal.setActiveSelectionList(list);
            //}
        }
Пример #6
0
        //////////////////////////////////////////////////////////////////
        //
        // Overrides from MPxData
        //
        //////////////////////////////////////////////////////////////////

        public override void readASCII(MArgList argList, ref uint index)
        //
        // Description
        //    NOT IMPLEMENTED
        //
        {
            MGlobal.displayInfo("apiMeshData.readASCII is called.");
            return;
        }
Пример #7
0
        public override void doIt(MArgList args)
        {
            MSelectionList list = new MSelectionList();

            MGlobal.getActiveSelectionList(list);

            iter = new MItSelectionList(list, MFn.Type.kInvalid);
            redoIt();
        }
Пример #8
0
 public polyPrimitive()
 {
     iarr         = new MFloatPointArray();
     pa           = new MFloatPointArray();
     faceCounts   = new MIntArray();
     faceConnects = new MIntArray();
     dagMod       = new MDagModifier();
     MGlobal.displayInfo("test polyPrimitive.");
 }
Пример #9
0
 public override void readBinary(MIStream stream, uint length)
 //
 // Description
 //     NOT IMPLEMENTED
 //
 {
     MGlobal.displayInfo("apiMeshData.readBinary is called.");
     return;
 }
Пример #10
0
 public override void writeBinary(MOStream stream)
 //
 // Description
 //    NOT IMPLEMENTED
 //
 {
     MGlobal.displayInfo("apiMeshData.writeBinary is called.");
     return;
 }
        string AddSubMenu(string parentMenuName, string labelStr, bool tearOff)
        {
            MGlobal.executePythonCommand("import maya.cmds as cmds");
            string cmdStr = (tearOff ? "cmds.menuItem(tearOff = True, parent='" : "cmds.menuItem(parent='") + parentMenuName + "',subMenu = True, label='" + labelStr + "')";
            //Debug.Log("cmdStr:" + cmdStr);
            string subMenuName = MGlobal.executePythonCommandStringResult(cmdStr);

            return(subMenuName);
        }
Пример #12
0
 public void StartProgress(string Title, int Max)
 {
     if (this.CanProgress)
     {
         MGlobal.executeCommand("progressBar -e -bp -ii 1 $gMainProgressBar");
         MGlobal.executeCommand("progressBar -e -ep $gMainProgressBar");
         MGlobal.executeCommand(string.Format("progressBar -e -bp -ii 1 -st \"{0}\" -max {1} $gMainProgressBar", Title, Max));
     }
 }
Пример #13
0
        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);
        }
Пример #14
0
        private static void postPluginUnloadCallback(object sender, MStringArrayFunctionArgs args)
        {
            MStringArray str = args.strs;

            MGlobal.displayInfo("POST plugin unload callback with " + str.length + " items:");
            for (int i = 0; i < str.length; i++)
            {
                MGlobal.displayInfo("\tCallback item " + i + " is : " + str[i]);
            }
        }
Пример #15
0
        static private void createIK2BsolverAfterNew(object sender, MBasicFunctionArgs arg)
        // This method creates the ik2Bsolver after a File->New.
        //
        {
            MSelectionList selList = new MSelectionList();

            MGlobal.getActiveSelectionList(selList);
            MGlobal.executeCommand("createNode -n ik2BsolverCSharp ik2BsolverCSharp");
            MGlobal.setActiveSelectionList(selList);
        }
Пример #16
0
        private MMatrix GetMMatrix(MFnTransform mFnTransform, double currentFrame = 0)
        {
            // get transformation matrix at this frame
            MDoubleArray mDoubleMatrix = new MDoubleArray();

            MGlobal.executeCommand($"getAttr -t {currentFrame} {mFnTransform.fullPathName}.matrix", mDoubleMatrix);
            mDoubleMatrix.get(out float[] localMatrix);

            return(new MMatrix(localMatrix));
        }
Пример #17
0
        static public Bool32 DebugReportCallback(DebugReportFlagsExt flags, DebugReportObjectTypeExt objectType, ulong objectHandle, IntPtr location, int messageCode, IntPtr layerPrefix, IntPtr message, IntPtr userData)
        {
            string layerString   = Marshal.PtrToStringAnsi(layerPrefix);
            string messageString = Marshal.PtrToStringAnsi(message);

            MGlobal.displayError(string.Format("DebugReport layer: {0} message: {1}", layerString, messageString));
            //Console.WriteLine("DebugReport layer: {0} message: {1}", layerString, messageString);

            return(false);
        }
Пример #18
0
        public static void MakeJointsHairChain(MSelectionList jointDagPaths)
        {
            //begin convert curve to dynamic
            MDagPath curveDagPath = CreateJointsCurve(jointDagPaths);
            string   cmdStr       = "cmds.makeCurveDynamic(0,0,0,1,0)";
            string   resultStr    = MGlobal.executePythonCommandStringResult(cmdStr);

            //string resultStr = MGlobal.executeCommandStringResult("makeCurvesDynamic 2 {\"0\",\"0\",\"0\",\"1\",\"0\"}");
            MGlobal.displayInfo("message" + resultStr);
        }
Пример #19
0
        bool IExtensionPlugin.InitializePlugin()
        {
            // Add menu to main menu bar
            MenuPath = MGlobal.executeCommandStringResult($@"menu - parent MayaWindow - label ""Babylon"";");
            // Add item to this menu
            MGlobal.executeCommand($@"menuItem - label ""Babylon File Exporter..."" - command ""toBabylon"";");

            MGlobal.displayInfo("Babylon plug-in initialized");
            return(true);
        }
Пример #20
0
        internal static bool createLocator(double x, double y, double z, double rx, double ry, double rz, string name)
        {
            MStringArray moveResult   = new MStringArray();
            MStringArray rotateResult = new MStringArray();

            MGlobal.executeCommand(string.Format("spaceLocator -a -p {0} {1} {2} -n {3}", x, y, z, name), moveResult);
            MGlobal.executeCommand(string.Format("rotate {0} {1} {2} {3}", rx, ry, rz, name), rotateResult);

            return(true);
        }
Пример #21
0
        /// <summary>
        /// Entry point of the plug in
        /// Write "toBabylon" in the Maya console to start it
        /// </summary>
        /// <param name="argl"></param>
        public override void doIt(MArgList argl)
        {
            MGlobal.displayInfo("Start Maya Plugin\n");
            ExporterForm BabylonExport = new ExporterForm();

            BabylonExport.Show();
            BabylonExport.BringToFront();
            BabylonExport.WindowState = FormWindowState.Normal;
            // DoExport();
        }
Пример #22
0
        public static void ConnectAttr(string from, string to, bool force = true, bool showInIdle = false)
        {
            string cmdStr = string.Format("connectAttr {0} {1}", from, to);

            if (force)
            {
                cmdStr += " -f";
            }
            MGlobal.executeCommand(cmdStr, showInIdle);
        }
Пример #23
0
        public static void Select(List <MObject> list)
        {
            MSelectionList sl = new MSelectionList();

            foreach (MObject mo in list)
            {
                sl.add(mo);
            }
            MGlobal.setActiveSelectionList(sl);
        }
Пример #24
0
        public static string[] AddIKHandle(MDagPath startJointDagPath, MDagPath endJointDagPath, IKSolverType solverType = IKSolverType.RotatePlane, string curveName = "")
        {
            //string typeStr = "";
            string resultStr = "";

            CmdStrConstructor csc = new CmdStrConstructor("ikHandle", CmdStrConstructor.CmdType.Python);

            csc.UpdateParm("sj", startJointDagPath.fullPathName);
            csc.UpdateParm("ee", endJointDagPath.fullPathName);

            string ikMainName = startJointDagPath.partialPathName + "_" + endJointDagPath.partialPathName;

            switch (solverType)
            {
            case IKSolverType.SingleChain:
            {
                csc.UpdateParm("sol", "ikSCsolver");
                csc.UpdateParm("n", "ik_" + ikMainName);
                string excuteStr = csc.ToString();
                resultStr = MGlobal.executePythonCommandStringResult(excuteStr);
                //typeStr = "ikSCsolver";
                //resultStr = MGlobal.executePythonCommandStringResult("cmds.ikHandle(sj='" + startJointDagPath.fullPathName + "',ee='" + endJointDagPath.fullPathName + "',sol='" + typeStr + "',n='ik_" + ikMainName + "')");
                break;
            }

            case IKSolverType.RotatePlane:
            {
                csc.UpdateParm("sol", "ikRPsolver");
                csc.UpdateParm("n", "ik_" + ikMainName);
                string excuteStr = csc.ToString();
                resultStr = MGlobal.executePythonCommandStringResult(excuteStr);
                //typeStr = "ikRPsolver";
                //resultStr = MGlobal.executePythonCommandStringResult("cmds.ikHandle(sj='" + startJointDagPath.fullPathName + "',ee='" + endJointDagPath.fullPathName + "',sol='" + typeStr + "',n='ik_" + ikMainName + "')");
                break;
            }

            case IKSolverType.Spline:
            {
                csc.UpdateParm("sol", "ikSplineSolver");
                csc.UpdateParm("n", "ik_" + ikMainName);
                csc.UpdateParm("ccv", curveName == null || curveName.Length == 0);
                csc.UpdateParm("c", curveName);
                csc.UpdateParm("pcv", false);
                string excuteStr = csc.ToString();
                resultStr = MGlobal.executePythonCommandStringResult(excuteStr);
                //resultStr = MGlobal.executePythonCommandStringResult("cmds.ikHandle(sj='" + startJointDagPath.fullPathName + "',ee='" + endJointDagPath.fullPathName + "',sol='" + typeStr + "',c='" + curveName + "',n='ik_" + ikMainName + "')",true);
                break;
            }
            }
            //[u'ik_joint1_joint4', u'effector1']
            string[] resultArr = BasicFunc.SplitPythonResultStr(resultStr);

            return(resultArr);
        }
Пример #25
0
        public override void doIt(MArgList args)
        {
            MGlobal.displayInfo("Garbage Collection begin.");

            GC.Collect();
            GC.WaitForPendingFinalizers();

            MGlobal.displayInfo("Garbage Collection complete.");

            return;
        }
Пример #26
0
        public bool UninitializePlugin()
        {
            try
            {
                // Clear UI if available
                MGlobal.executeCommand("catchQuiet(deleteUI(\"CODTools\"));");
            }
            catch { }

            return(true);
        }
        public override void doIt(MArgList argl)
        {
            MGlobal.displayInfo("Hello World\n");

            _dagModifier = new MDagModifier();

            _transform = _dagModifier.createNode("camera");
            _dagModifier.renameNode(_transform, "motionCamera");

            redoIt();
        }
Пример #28
0
        bool IExtensionPlugin.UninitializePlugin()
        {
            // Remove menu from main menu bar and close the form
            MGlobal.executeCommand($@"deleteUI -menu ""{MenuPath}"";");

            MGlobal.displayInfo("Babylon plug-in uninitialized");

            toBabylon.disposeForm();

            return(true);
        }
Пример #29
0
        private void View_Closed(object sender, EventArgs e)
        {
            //DynamoView dv = (DynamoView)sender;
            if (!dynStartUp.DynViewModel.PerformShutdownSequence(new DynamoViewModel.ShutdownParams(false, true, true)))
            {
                MGlobal.displayWarning("Could not shut down");
            }

            dynStartUp.DynView.Close();
            dynStartUp = null;
        }
Пример #30
0
        public void sendCurveToMaya(string node_name, Point3DCollection controlVertices, List <double> knots, int degree,
                                    MFnNurbsCurveForm form)
        {
            var dn             = new MFnDagNode(getDagNode(node_name));
            var plCreate       = dn.findPlug("create");
            var plDynamoCreate = new MPlug();

            try
            {
                plDynamoCreate = dn.findPlug("dynamoCreate");
            }
            catch
            {
                var tAttr           = new MFnTypedAttribute();
                var ldaDynamoCreate = tAttr.create("dynamoCreate", "dc", MFnData.Type.kNurbsCurve, MObject.kNullObj);
                try
                {
                    dn.addAttribute(ldaDynamoCreate, MFnDependencyNode.MAttrClass.kLocalDynamicAttr);
                    plDynamoCreate = dn.findPlug(ldaDynamoCreate);
                    var dagm = new MDagModifier();
                    dagm.connect(plDynamoCreate, plCreate);
                    dagm.doIt();
                }
                catch
                {
                    return;
                }
            }

            var ncd    = new MFnNurbsCurveData();
            var oOwner = ncd.create();
            var nc     = new MFnNurbsCurve();

            var p_aControlVertices = new MPointArray();

            foreach (var p in controlVertices)
            {
                p_aControlVertices.Add(new MPoint(p.X, p.Y, p.Z));
            }

            var d_aKnots = new MDoubleArray();

            for (var i = 1; i < knots.Count - 1; ++i)
            {
                d_aKnots.Add(knots[i]);
            }

            nc.create(p_aControlVertices, d_aKnots, (uint)degree, (MFnNurbsCurve.Form)form, false, true, oOwner);

            plDynamoCreate.setMObject(oOwner);

            MGlobal.executeCommandOnIdle(string.Format("dgdirty {0}.create;", node_name));
        }