Ejemplo n.º 1
0
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
MStatus CVsSkinnerCmd::FindSkinnerNodesInHierarchy(
	const MDagPath &iDagPath,
	MSelectionList &oList )
{
	MStatus retVal( MS::kFailure );

	MDagPath rDagPath( iDagPath );	// Root dag path
	while ( rDagPath.length() > 1U )
	{
		rDagPath.pop();
	}

	MDagPath mDagPath;
	MDagPath sDagPath;

	uint nShapes;

	MItDag dIt;
	if ( rDagPath.length() )
	{
		dIt.reset( rDagPath );
	}

	for ( ; !dIt.isDone(); dIt.next() )
	{
		if ( !dIt.getPath( mDagPath ) )
			continue;

		mDagPath.numberOfShapesDirectlyBelow( nShapes );
		for ( uint i( 0U ); i != nShapes; ++i )
		{
			sDagPath = mDagPath;
			sDagPath.extendToShapeDirectlyBelow( i );
			if ( !IsSkinnerNode( sDagPath ) )
				continue;

			oList.add( sDagPath, MObject::kNullObj, true );
			retVal = MS::kSuccess;
		}

		if ( !ConnectedToSkinnerNode( mDagPath, sDagPath ) )
			continue;

		oList.add( sDagPath, MObject::kNullObj, true );
		retVal = MS::kSuccess;
	}

	return retVal;
}
Ejemplo n.º 2
0
void MeshGitCmd::startUpdateSelectedEdit(MString nodeName){
	cout<< "Starting updating selected edit on Node:  " + nodeName << endl;
	MStatus status;
	if(nodeName == NULL || nodeName ==""){
		cout<< "nodeName == NULL  " + nodeName << endl;
		return;
	}

	//Get Node Object
	MSelectionList nodeList;
	status = nodeList.add(nodeName);
	MObject nodeObject;
	status = nodeList.getDependNode(0, nodeObject);
	reportError(status);

	//Create Node Fn
	MeshGitFn mgFn;
	status = mgFn.setObject(nodeObject);
	reportError(status);

	//Start the diff
	mgFn.findSelectedEditIndex();
	reportError(status);

}
Ejemplo n.º 3
0
void MeshGitCmd::startMergeUnconflicting(MString nodeName){
	MGlobal::displayInfo("Starting diff on Node:  " + nodeName );
	MStatus status;

	//Get Node Object
	MSelectionList nodeList;
	status = nodeList.add(nodeName);
	MObject nodeObject;
	status = nodeList.getDependNode(0, nodeObject);
	reportError(status);

	//Create Node Fn
	MeshGitFn mgFn;
	status = mgFn.setObject(nodeObject);
	reportError(status);

	//Start the diff
	mgFn.startMergeUnconflicting();
	//mgFn.get
	//Get the node plug
	//MPlug nodePlug = mgFn.findPlug("message", true, &status);
	reportError(status);


	
}
Ejemplo n.º 4
0
//this function creates missing animation layers and places it in the correct order
void atomAnimLayers::createMissingAnimLayers(const MStringArray &animLayers)
{
	for(unsigned int k=0; k < animLayers.length(); ++k)
	{
		MSelectionList list;
		list.add(animLayers[k]);
		if(list.length()!=1) //if not in the list then not in the scene so create it, and the previous one WILL be in the scene so attach to it
		{
			MString prevLayerName;
			if(k>0)
				prevLayerName = animLayers[k-1];
			//todo need a better way to handle the root layer
			//this fixes an issue where when you create an animation layer for the base it creates 2 layers the BaseAnimation
			//and a default animLayer1, where if you create the same thing in the UI the second one is named AnimLayer1, with
			//a cap A. So we are getting an extra animLayer1 created, which is a little messy. This stops that
			//but we need to revisit.  Also seems like you can't rename BaseAnimation, but not sure what it is in different
			//languages. It's a node so maybe it never changes?

			if(k > 0 || animLayers[k] != MString("BaseAnimation") || animLayers.length()==0)  //we know we are creating more than 1 so the BaseAnimation will
			{																  //be created next time so dont create it unless only creating a BaseAnimation
				createAnimLayer(animLayers[k],prevLayerName);
			}
		}
	}
}
Ejemplo n.º 5
0
SceneInterfacePtr LiveScene::retrieveScene( const Path &path, MissingBehaviour missingBehaviour ) const
{
	tbb::mutex::scoped_lock l( s_mutex );
	
	if( path.size() == 0 )
	{
		MItDag it;
		MDagPath rootPath;
		it.getPath( rootPath );
		return duplicate( rootPath, true );
	}
	
	MString pathName;
	
	for( Path::const_iterator it=path.begin(); it != path.end(); ++it )
	{
		pathName += "|";
		pathName += std::string( *it ).c_str();
	}
	
	MSelectionList sel;
	MStatus st = sel.add( pathName );
	if( !st )
	{
		if( missingBehaviour == SceneInterface::ThrowIfMissing )
		{
			std::string pathName;
			for( size_t i = 0; i < path.size(); ++i )
			{
				pathName += std::string( path[i] ) + "/";
			}
			
			throw Exception( "IECoreMaya::LiveScene::retrieveScene: Couldn't find transform at specified path " + pathName );
		}
		return 0;
	}
	
	MDagPath dagPath;
	sel.getDagPath( 0, dagPath );
	
	if( dagPath.hasFn( MFn::kTransform ) )
	{
		return duplicate( dagPath );
	}
	else
	{
		if( missingBehaviour == SceneInterface::ThrowIfMissing )
		{
			std::string pathName;
			for( size_t i = 0; i < path.size(); ++i )
			{
				pathName += std::string( path[i] ) + "/";
			}
			
			throw Exception( "IECoreMaya::LiveScene::retrieveScene: Couldn't find transform at specified path " + pathName );
		}
		return 0;
	}
	
}
Ejemplo n.º 6
0
MStatus createClip::parseArgs( const MArgList& args )
//
// No arguments to parse.
//
{
	MStatus     	stat = MS::kSuccess;
	MString     	arg;
	MSelectionList	list;
	bool			charNameUsed = 0;
	MString			charName;
	const MString	charFlag			("-c");
	const MString	charFlagLong		("-char");

	// Parse the arguments.
	for ( unsigned int i = 0; i < args.length(); i++ ) {
		arg = args.asString( i, &stat );
		if (!stat)              
			continue;
				
		if ( arg == charFlag || arg == charFlagLong ) {
			// get the char name
			//
			if (i == args.length()-1) {
				arg += ": must specify a character name";
				displayError(arg);
				return MS::kFailure;
			}
			i++;
			args.get(i, charName);
			list.add(charName);
			charNameUsed = 1;
		}
		else {
			arg += ": unknown argument";
			displayError(arg);
			return MS::kFailure;
		}
	}

	if (charNameUsed) {
		// get the character corresponding to the node name
		//
		MItSelectionList iter (list);
		for ( /* nothing */ ; !iter.isDone(); iter.next() ) {
			MObject node;
			iter.getDependNode(node);
			if (node.apiType() == MFn::kCharacter) {
				fCharacter = node;
				break;
			}
		}
		if (fCharacter.isNull()) {
			MString errMsg("Character flag must specify a character node.");
			displayError(errMsg);
			return MS::kFailure;
		}
	}
	
	return stat;
}
Ejemplo n.º 7
0
AlembicObject::AlembicObject(SceneNodePtr eNode, AlembicWriteJob* in_Job,
                             Abc::OObject oParent)
    : mExoSceneNode(eNode),
      mJob(in_Job),
      mMyParent(oParent),
      mNumSamples(0),
      nodeName(eNode->dccIdentifier.c_str()),
      mHasParent(false)
{
  MSelectionList sl;
  sl.add(nodeName);
  MDagPath dagPath;
  sl.getDagPath(0, dagPath);

  MObject in_Ref = dagPath.node();
  AddRef(in_Ref);

  MFnDagNode dag(in_Ref);
  for (unsigned int i = 0; i < dag.parentCount(); ++i) {
    MObject parentRef = dag.parent(i);
    if (!parentRef.isNull()) {
      mHasParent = in_Job->ObjectExists(parentRef);
      if (mHasParent) {
        break;
      }
    }
  }
}
    // --------------------------------------------------------------------
    MStatus SceneGraph::addInstancedDagPaths ( MSelectionList& selectionList )
    {
        MStatus status;
        int length = selectionList.length ( &status );
        if ( status != MStatus::kSuccess ) return MStatus::kFailure;

        for ( int i=0; i<length; i++ )
        {
            MDagPath dagPath;
            if ( selectionList.getDagPath ( i, dagPath ) != MStatus::kSuccess ) return MStatus::kFailure;

            if ( dagPath.isInstanced() )
            {
                int includedInstance=dagPath.instanceNumber ( &status );
                if ( status != MStatus::kSuccess ) return MStatus::kFailure;

                MObject object=dagPath.node ( &status );
                if ( status != MStatus::kSuccess ) return MStatus::kFailure;

                MDagPathArray paths;
                if ( MDagPath::getAllPathsTo ( object, paths ) != MStatus::kSuccess ) return MStatus::kFailure;

                int numPaths=paths.length();
                for ( int p=0; p<numPaths; p++ )
                    if ( p!=includedInstance )
                        selectionList.add ( paths[p] );
            }
        }

        return MStatus::kSuccess;
    }
Ejemplo n.º 9
0
IECore::SceneInterfacePtr LiveScene::retrieveChild( const Name &name, MissingBehaviour missingBehaviour ) const
{
	tbb::mutex::scoped_lock l( s_mutex );
	
	if( m_dagPath.length() == 0 && !m_isRoot )
	{
		throw Exception( "IECoreMaya::LiveScene::retrieveChild: Dag path no longer exists!" );
	}
	
	MSelectionList sel;
	sel.add( m_dagPath.fullPathName() + "|" + std::string( name ).c_str() );
	
	MDagPath path;
	sel.getDagPath( 0, path );
	
	if( !path.hasFn( MFn::kTransform ) )
	{
		if( missingBehaviour == SceneInterface::ThrowIfMissing )
		{
			throw Exception( "IECoreMaya::LiveScene::retrieveChild: Couldn't find transform at specified path " + std::string( path.fullPathName().asChar() ) );
		}
		return 0;
	}
	
	return duplicate( path );
}
MStatus SelectRingToolCmd2::finalize()
{
	MArgList command;
	command.addArg( commandString() );

	command.addArg( MString(edgeFlag) );
	MSelectionList sel;
	sel.add( selEdgeObject, selEdgeComp );
	MStringArray edges;
	sel.getSelectionStrings( edges );
	command.addArg( edges[0] );

	command.addArg( MString(selEdgesFlag) );
	command.addArg( selEdges );

	command.addArg( MString(selFacesFlag) );
	command.addArg( selFaces );

	command.addArg( MString(selVerticesFlag) );
	command.addArg( selVertices );

	command.addArg( MString(listAdjustFlag) );
	command.addArg( (int)listAdjust );
	
	command.addArg( MString(selTypeFlag) );
	command.addArg( selType );
	
	return MPxToolCommand::doFinalize( command );
}
MStatus DDConvexHullCmd::doIt(const MArgList& args)
{
    if (args.length() != 1)
    {
        MGlobal::displayError("Needs at least 2 args");
        return MS::kFailure;
    }
    MString input = args.asString(0);
    MString output = args.asString(1);
    
    // Get the mObject for the input
    MSelectionList selList;
    selList.add(input);
    MDagPath inputMesh;
    selList.getDagPath(0, inputMesh);
    
    // Ensure we're looking at the shape
    inputMesh.extendToShape();

    // Create output object
    MDagModifier dm;
    MObject outMeshNode = dm.createNode(MFn::kMesh);
    MFnDependencyNode outMeshDag(outMeshNode);
    outMeshDag.setName("poopShape#");
    DDConvexHullUtils::hullOpts hullOptions;
    return DDConvexHullUtils::generateMayaHull(outMeshNode,
                                               inputMesh.node(), hullOptions);

}
Ejemplo n.º 12
0
MObject boingRbCmd::nameToNode( MString name ) {
    MSelectionList selList;
    selList.add( name );
    MObject node;
    selList.getDependNode( 0, node );
    return node;
}
Ejemplo n.º 13
0
MObject getRefFromFullName(const MString & in_Path)
{
   MSelectionList sl;
   sl.add(in_Path);
   MDagPath dag;
   sl.getDagPath(0,dag);
   return dag.node();
}
static MStatus getDagPathByName(const MString & name, MDagPath & dagPath)
{
  MSelectionList sList;
  MStatus status = sList.add(name);
  if (status == MS::kSuccess)
    status = sList.getDagPath(0, dagPath);
  return status;
}
Ejemplo n.º 15
0
MStatus TransferUV::doIt(const MArgList& args)
{
    MStatus status;

    // if (args.length() != 1)
    // {
    //     MGlobal::displayError("Need 1 arg!");
    //     return MStatus::kFailure;
    // }

    MArgDatabase argData(syntax(), args);

    // arg
    // MString argument = args.asString(0, &status);
    // if (status != MS::kSuccess) {
    //     return MStatus::kFailure;
    // }
    // CHECK_MSTATUS_AND_RETURN_IT(status);

    if (argData.isFlagSet(sourceUvSetFlag)) {
        status = argData.getFlagArgument(sourceUvSetFlag, 0, sourceUvSet);
        CHECK_MSTATUS_AND_RETURN_IT(status);
    }

    if (argData.isFlagSet(targetUvSetFlag)) {
        status = argData.getFlagArgument(targetUvSetFlag, 0, targetUvSet);
        CHECK_MSTATUS_AND_RETURN_IT(status);
    }

    if (argData.isFlagSet(sourceMeshFlag)) {
        status = argData.getFlagArgument(sourceMeshFlag, 0, sourceMesh);
    } else {
        MGlobal::displayError(
            "Source mesh is not specified. -sm flag is required.");
        return MS::kFailure;
    }

    if (argData.isFlagSet(targetMeshFlag)) {
        status = argData.getFlagArgument(targetMeshFlag, 0, targetMesh);
    } else {
        MGlobal::displayError(
            "Target mesh is not specified. -tm flag is required.");
        return MS::kFailure;
    }

    MString info = "Copying uv from " + sourceUvSet + " to " + targetUvSet;
    MGlobal::displayInfo(info);

    MSelectionList mList;
    mList.add(sourceMesh);
    mList.add(targetMesh);

    mList.getDagPath(0, sourceDagPath);
    mList.getDagPath(1, targetDagPath);

    return redoIt();
}
Ejemplo n.º 16
0
bool atomImport::replaceNameAndFindPlug(const MString& origName,
										atomNodeNameReplacer& replacer,
										MPlug& replacedPlug)
{
	bool rtn = false;
	
	// get the node name
	//
	MStringArray nameParts;
	origName.split('.', nameParts);

	// Perform any necessary replacement
	//
	MString tmpName(nameParts[0]);
	// TODO: type & hierarchy info -- does the replacer store enough info
	// to help us find that out since in the case of export edits we don't
	// have that info for sources
	//
	if (replacer.findNode(atomNodeNameReplacer::eDag,tmpName,0,0)) {
		MString newName(tmpName);
		newName += (".");

		// add the attribute name(s) back on again
		//
		unsigned int ii;
		MString attrName;
		for (ii = 1; ii < nameParts.length(); ++ii) {
			if (ii > 1) {
				attrName += (".");
			}
			attrName += nameParts[ii];
		}
		newName += attrName;

		MSelectionList tmpList;
		if (MS::kSuccess == tmpList.add(newName)) {
			tmpList.getPlug(0,replacedPlug);
			rtn = !replacedPlug.isNull();
			if (!rtn) {
				// test for the special case of the pivot component
				//
				MDagPath path;
				MObject component;
				if (MS::kSuccess == tmpList.getDagPath(0,path,component) &&
					component.apiType() == MFn::kPivotComponent)
				{
					MObject node;
					tmpList.getDependNode(0,node);
					MFnDependencyNode fnNode(node);
					replacedPlug = fnNode.findPlug(attrName,false);
					rtn = !replacedPlug.isNull();
				}
			}
		}
	}
	return rtn;
}
Ejemplo n.º 17
0
    //---------------------------------------------------
    MObject DagHelper::getNode ( const MString& name )
    {
        MSelectionList selection;
        selection.add ( name );

        MObject nodeObject;
        selection.getDependNode ( 0, nodeObject );

        return nodeObject;
    }
static MStatus getObjectByName(const MString & name, MObject & object)
{
  object = MObject::kNullObj;

  MSelectionList sList;
  MStatus status = sList.add(name);
  if (status == MS::kSuccess)
    status = sList.getDependNode(0, object);
  return status;
}
Ejemplo n.º 19
0
void EntityInstanceNode::SelectionChangedCallback( void* clientData )
{
    MAYA_START_EXCEPTION_HANDLING();

    if( !s_ReplaceSelection )
    {
        return;
    }

    static bool inFunc = false;

    if( inFunc )
        return;
    else
        inFunc = true;

    MSelectionList list;
    MGlobal::getActiveSelectionList( list );

    MStatus stat;

    MSelectionList addList;
    bool added = false;
    u32 len = list.length();
    for( u32 i = 0; i < len; )
    {
        MDagPath path;
        list.getDagPath( i, path );

        MObject entityNode = EntityNodeParent( path );
        if( entityNode != MObject::kNullObj )
        {
            added = true;
            MFnDagNode nodeFn( entityNode );
            MDagPath instancePath;
            nodeFn.getPath( instancePath );
            addList.add( instancePath );
            list.remove( i );
        }
        else
        {
            ++i;
        }
    }

    if( added )
    {
        MGlobal::setActiveSelectionList( list, MGlobal::kReplaceList );
        MGlobal::setActiveSelectionList( addList, MGlobal::kAddToList );
    }

    inFunc = false;

    MAYA_FINISH_EXCEPTION_HANDLING();
}
MStatus SelectRingToolCmd2::doIt( const MArgList &args )
{
	//MGlobal::displayInfo( "doIt" );
	
	MStatus stat;

	MGlobal::getActiveSelectionList( prevSel );	

	// Initialize to default values
	selEdges = true;
	selFaces = false;
	selVertices = false;
	selEdgeObject = MDagPath();
	selEdgeComp = MObject::kNullObj;
	listAdjust = MGlobal::kReplaceList;
	selType = RING;
		
	// Get the options from the command line
	MArgDatabase argData( syntax(), args, &stat );
	if( !stat )
		return stat;

	if( argData.isFlagSet( edgeFlag ) )
	{
		MString edgeSpec;
		argData.getFlagArgument( edgeFlag, 0, edgeSpec );
		
		MSelectionList sel;
		sel.add( edgeSpec );
		sel.getDagPath( 0, selEdgeObject, selEdgeComp );
		//MFnSingleIndexedComponent si( selEdgeComp );
		//MGlobal::displayInfo( MString("doing stuff on ") + selEdgeObject.fullPathName() + " " + si.element(0) );
	}

	if( argData.isFlagSet( selEdgesFlag ) )
		argData.getFlagArgument( selEdgesFlag, 0, selEdges );
	
	if( argData.isFlagSet( selFacesFlag ) )
		argData.getFlagArgument( selFacesFlag, 0, selFaces );

	if( argData.isFlagSet( selVerticesFlag ) )
		argData.getFlagArgument( selVerticesFlag, 0, selVertices );

	if( argData.isFlagSet( listAdjustFlag ) )
	{
		unsigned value;
		argData.getFlagArgument( listAdjustFlag, 0, value );
		listAdjust = MGlobal::ListAdjustment( value );
	}

	if( argData.isFlagSet( selTypeFlag ) )
		argData.getFlagArgument( selTypeFlag, 0, selType );
	
	return redoIt();
}
Ejemplo n.º 21
0
void MeshGitCmd::connectNodes(MString nodeName, MString locatorName){
	MGlobal::displayInfo("Connecting " + nodeName + " and " + locatorName);
	MStatus status;

	//Get Node Object
	MSelectionList nodeList;
	status = nodeList.add(nodeName);
	MObject nodeObject;
	status = nodeList.getDependNode(0, nodeObject);
	reportError(status);

	//Get Viz Object
	MSelectionList vizList;
	status = vizList.add(locatorName);
	MObject vizObject;
	status = vizList.getDependNode(0, vizObject);
	reportError(status);

	//Create Node Fn
	MeshGitFn mgFn;
	status = mgFn.setObject(nodeObject);
	reportError(status);
	
	//Create viz fn
	MFnDependencyNode vizFn(vizObject, &status);

	//Get the node plug
	MPlug nodePlug = mgFn.findPlug("message", true, &status);
	reportError(status);

	//Get the viz plug 
	MPlug vizPlug = vizFn.findPlug(MeshGitLocatorNode::meshGitNodeConnection, true,
            &status);

	//Connect the plugs 
	
	MDagModifier modifier;
	status = modifier.connect(nodePlug,vizPlug);
	reportError(status);
	status = modifier.doIt();

}
Ejemplo n.º 22
0
	MSelectionList convertMIntArrToMselList( MIntArray& intArr, MDagPath& dPath, MFn::Type kCompType )
	{
		MFnSingleIndexedComponent singleIndexCompFn;
			// create MObjet componenet by sigleIndexComponent
		MObject components = singleIndexCompFn.create(kCompType);
		singleIndexCompFn.addElements( intArr );

		MSelectionList compSelList;
		compSelList.add( dPath, components );
		return compSelList;
	}
Ejemplo n.º 23
0
MStatus particleSystemInfoCmd::nodeFromName(MString name, MObject & obj)
{
	MSelectionList tempList;
	tempList.add( name );
	if ( tempList.length() > 0 ) 
	{
		tempList.getDependNode( 0, obj );
		return MS::kSuccess;
	}
	return MS::kFailure;
}
void
VertexPolyColourCommand::CreateJobListFromPaint()
{
	MSelectionList selection;
	MString selectStr = m_paintObjectName;
	selectStr += ".vtx[";
	selectStr += (int)m_paintVertexIndex;
	selectStr += "]";
	selection.add(selectStr);

	CreateJobListFromSelection(selection);
};
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
void CVstSelectCoincidentFacesCmd::GetSpecifiedMeshes(
	MSelectionList &meshList )
{
	meshList.clear();

	MSelectionList optSelectionList;
	m_undo.ArgDatabase().getObjects( optSelectionList );

	MDagPath mDagPath;
	MObject cObj;
	for ( MItSelectionList sIt( optSelectionList ); !sIt.isDone(); sIt.next() )
	{
		if ( sIt.itemType() == MItSelectionList::kDagSelectionItem && sIt.getDagPath( mDagPath, cObj ) )
		{
			if ( mDagPath.hasFn( MFn::kMesh ) )
			{
				if ( sIt.hasComponents() || !cObj.isNull() )
				{
					meshList.add( mDagPath, cObj );
				}
				else
				{
					mDagPath.extendToShapeDirectlyBelow( 0U );
					meshList.add( mDagPath, MObject::kNullObj, true );
				}
			}
		}
	}

	if ( meshList.isEmpty() )
	{
		for ( MItDag dIt( MItDag::kDepthFirst, MFn::kMesh ); !dIt.isDone(); dIt.next() )
		{
			if ( dIt.getPath( mDagPath ) )
			{
				meshList.add( mDagPath, MObject::kNullObj, true );
			}
		}
	}
}
Ejemplo n.º 26
0
		MStatus CreateCurves::createCurves(std::list<Model::Helix> & helices, std::list<Model::Strand> & strands) {
			MStatus status;

			/*
			 * As some curves are circular, we must check every base and what strand it belongs to
			 */

			std::list<Model::Strand> added_strands;

			for(std::list<Model::Helix>::iterator it = helices.begin(); it != helices.end(); ++it) {
				for(Model::Helix::BaseIterator bit = it->begin(); bit != it->end(); ++bit) {
					Model::Strand strand(*bit);

					if (find_nonconst(added_strands.begin(), added_strands.end(), strand) == added_strands.end()) {
						if (!(status = createCurve(strand))) {
							status.perror("createCurve");
							return status;
						}

						added_strands.push_back(strand);

						onProgressStep();
					}
				}
			}

			for(std::list<Model::Strand>::iterator it = strands.begin(); it != strands.end(); ++it) {
				if (find_nonconst(added_strands.begin(), added_strands.end(), *it) == strands.end()) {
					if (!(status = createCurve(*it))) {
						status.perror("createCurve");
						return status;
					}
				}
			}

			/*
			 * Select the created curves
			 */

			MSelectionList selectionList;

			//std::for_each(&m_curves[0], &m_curves[0] + m_curves.length(), SelectionListAddFunctor(selectionList));
			for(unsigned int i = 0; i < m_curves.length(); ++i)
				selectionList.add(m_curves[i]);

			if (!(status = MGlobal::setActiveSelectionList(selectionList))) {
				status.perror("MGlobal::setActiveSelectionList");
				return status;
			}

			return MStatus::kSuccess;
		}
Ejemplo n.º 27
0
MStatus cvExpand::doIt( const MArgList& args )
{

	MSelectionList list;
	MSelectionList newList;

	// Get the geometry list from what is currently selected in the 
	// model
	//
	MGlobal::getActiveSelectionList( list );

	MDagPath path;
	MObject  component;
 
	// Make expanded Selection List
	//
	for ( MItSelectionList iter( list ); !iter.isDone(); iter.next() ) {
		iter.getDagPath( path, component );
		
		if ( path.hasFn( MFn::kNurbsSurfaceGeom ) && 
			 !component.isNull() ) {
			for ( MItSurfaceCV cvIter( path, component ); 
				  !cvIter.isDone(); cvIter.next() ) {
				newList.add( path, cvIter.cv() );
			}
		} else {
			newList.add( path, component );
		}
	}

	// Return expanded selection list as an array of strings
	//
	MStringArray returnArray;
	newList.getSelectionStrings( returnArray );

	MPxCommand::setResult( returnArray );

	return MS::kSuccess;
}
MStatus lrutils::getObjFromName(MString name, MObject & obj) {
    MStatus status;

    MSelectionList selection;
    status = selection.add( name, true );
    MyCheckStatusReturn(status, "add node \""+name+"\" to selection failed.");

    if(selection.length() ) {
        selection.getDependNode(0, obj);
        status = MS::kSuccess;
    }

    return status;
}
Ejemplo n.º 29
0
//this function adds the layer objects in mAnimLayers to the start of the selection list.
//this is used when exporting to make sure the animationlayers come first
void atomAnimLayers::addLayersToStartOfSelectionList(MSelectionList &list)
{
	if(mAnimLayers.length() > 0 )
	{
		MSelectionList layers;
		for(unsigned int i =0; i<mAnimLayers.length();++i)
		{
			layers.add(mAnimLayers[i], true);
		}
		layers.merge(list);
		list = layers;
		
	}

}
Ejemplo n.º 30
0
/* override */
bool apiSimpleShapeUI::select( MSelectInfo &selectInfo, MSelectionList &selectionList,
					MPointArray &worldSpaceSelectPts ) const
//
// Description:
//
//     Main selection routine
//
// Arguments:
//
//     selectInfo           - the selection state information
//     selectionList        - the list of selected items to add to
//     worldSpaceSelectPts  -
//
{
	bool selected = false;
	bool componentSelected = false;
	bool hilited = false;

	hilited = (selectInfo.displayStatus() == M3dView::kHilite);
	if ( hilited ) {
		componentSelected = selectVertices( selectInfo, selectionList, worldSpaceSelectPts );
		selected = selected || componentSelected;
	}

	if ( !selected ) 
	{
		// NOTE: If the geometry has an intersect routine it should
		// be called here with the selection ray to determine if the
		// the object was selected.

		selected = true;
		MSelectionMask priorityMask( MSelectionMask::kSelectNurbsSurfaces );
		MSelectionList item;
		item.add( selectInfo.selectPath() );
		MPoint xformedPt;
		if ( selectInfo.singleSelection() ) {
			MPoint center = surfaceShape()->boundingBox().center();
			xformedPt = center;
			xformedPt *= selectInfo.selectPath().inclusiveMatrix();
		}

		selectInfo.addSelection( item, xformedPt, selectionList,
								 worldSpaceSelectPts, priorityMask, false );
	}

	return selected;
}