Example #1
0
		protected void __action (MoveToolAction flag) {


			//- Do the actual work here to move the objects	by vector
			MVector vector = __delta;
			if ( flag == MoveToolAction.kUndoIt ) { 
				vector =-vector ;
			} else {
				// all other cases identical
			}

			//- Create a selection list iterator
			MSelectionList slist = MGlobal.activeSelectionList;

            foreach (MDagPath mdagPath in slist.DagPaths())
			{
				MObject mComponent = mdagPath.node;

				try {
					MFnTransform transFn =new MFnTransform(mdagPath);
					try {
					transFn.translateBy (vector, MSpace.Space.kWorld) ;
					continue ;
					} catch (Exception) {
						MGlobal.displayInfo("Error doing translate on transform");
				}
				} catch (Exception) {
					//- Not a transform
				}

                try
                {
                    var CVs = new MCCurveCV(mdagPath, mComponent);
                    try
                    {
                        foreach (MItCurveCV cvFn2 in CVs)
                            cvFn2.translateBy(vector, MSpace.Space.kWorld);
                        CVs.iter.updateCurve();
                    }
                    catch (System.Exception)
                    {
                        MGlobal.displayInfo("Error setting Curve CV");
                    }
                }
                catch (System.Exception )
                {
                    //- No Curve CV
                }

				try {
				MItSurfaceCV sCvFn =new MItSurfaceCV (mdagPath, mComponent, true) ;
					try {
				while ( !sCvFn.isDone  ) {
					while ( !sCvFn.isRowDone ) {
						sCvFn.translateBy (vector, MSpace.Space.kWorld) ;
						sCvFn.next () ;
					}
					sCvFn.nextRow () ;
				}
				sCvFn.updateSurface () ;
					} catch (Exception) {
						MGlobal.displayInfo("Error setting Surface CV");
					}
				} catch (Exception) {
					//- No Surface CV
				}

				try {
                    var meshVertexEnum = new MCMeshVertex(mdagPath, mComponent);
					try {
                        foreach (MItMeshVertex vtxFn in meshVertexEnum)
                            vtxFn.translateBy(vector, MSpace.Space.kWorld);
                        meshVertexEnum.iter.updateSurface();
                    }
                    catch (Exception)
                    {
						MGlobal.displayInfo("Error setting Mesh Vertex");
					}
				} catch (Exception) {
					//- No Mesh Vertex
				}
			}

		}
Example #2
0
        protected void __action(MoveToolAction flag)
        {
            //- Do the actual work here to move the objects	by vector
            MVector vector = __delta;

            if (flag == MoveToolAction.kUndoIt)
            {
                vector = -vector;
            }
            else
            {
                // all other cases identical
            }

            //- Create a selection list iterator
            MSelectionList slist = MGlobal.activeSelectionList;

            foreach (MDagPath mdagPath in slist.DagPaths())
            {
                MObject mComponent = mdagPath.node;

                try {
                    MFnTransform transFn = new MFnTransform(mdagPath);
                    try {
                        transFn.translateBy(vector, MSpace.Space.kWorld);
                        continue;
                    } catch (Exception) {
                        MGlobal.displayInfo("Error doing translate on transform");
                    }
                } catch (Exception) {
                    //- Not a transform
                }

                try
                {
                    var CVs = new MCCurveCV(mdagPath, mComponent);
                    try
                    {
                        foreach (MItCurveCV cvFn2 in CVs)
                        {
                            cvFn2.translateBy(vector, MSpace.Space.kWorld);
                        }
                        CVs.iter.updateCurve();
                    }
                    catch (System.Exception)
                    {
                        MGlobal.displayInfo("Error setting Curve CV");
                    }
                }
                catch (System.Exception)
                {
                    //- No Curve CV
                }

                try {
                    MItSurfaceCV sCvFn = new MItSurfaceCV(mdagPath, mComponent, true);
                    try {
                        while (!sCvFn.isDone)
                        {
                            while (!sCvFn.isRowDone)
                            {
                                sCvFn.translateBy(vector, MSpace.Space.kWorld);
                                sCvFn.next();
                            }
                            sCvFn.nextRow();
                        }
                        sCvFn.updateSurface();
                    } catch (Exception) {
                        MGlobal.displayInfo("Error setting Surface CV");
                    }
                } catch (Exception) {
                    //- No Surface CV
                }

                try {
                    var meshVertexEnum = new MCMeshVertex(mdagPath, mComponent);
                    try {
                        foreach (MItMeshVertex vtxFn in meshVertexEnum)
                        {
                            vtxFn.translateBy(vector, MSpace.Space.kWorld);
                        }
                        meshVertexEnum.iter.updateSurface();
                    }
                    catch (Exception)
                    {
                        MGlobal.displayInfo("Error setting Mesh Vertex");
                    }
                } catch (Exception) {
                    //- No Mesh Vertex
                }
            }
        }