Example #1
0
MStatus linearFrictionCmd::doIt(const MArgList& args)
{
	
	MStatus stat;
	
	MArgDatabase argData(syntax(),args,&stat);
	if(argData.isFlagSet(lfFlag))argData.getFlagArgument(lfFlag,0,linearFriction);

	MSelectionList activeSelect; 
	MGlobal::getActiveSelectionList(activeSelect);

	for(int i=0;i<activeSelect.length();i++)
	{
		MObject tNode; 
		activeSelect.getDependNode(i,tNode);
		MFnDagNode fnDagNode(tNode);
		MObject pNode=fnDagNode.child(0); 
		MFnDependencyNode fnNode(pNode);
			
		//MString name=fnNode1.name().asChar();
		if(fnNode.typeId() == particleNode::typeId)
		{
			//get solver message attribute from particleNode
			MPlug(pNode, particleNode::linearFriction).setValue(linearFriction);
		}
	}
	return dgMod.doIt();	
}
Example #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);

}
Example #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);


	
}
Example #4
0
MObject boingRbCmd::nameToNode( MString name ) {
    MSelectionList selList;
    selList.add( name );
    MObject node;
    selList.getDependNode( 0, node );
    return node;
}
Example #5
0
MStatus sgBDataCmd_key::readData( MString nameFilePath )
{
	MStatus status;

	std::ifstream inFile( nameFilePath.asChar(), ios::binary );

	MString nameTarget;
	readString( nameTarget, inFile );

	MSelectionList selList;
	nameTarget.substitute( ":", "_" );
	MGlobal::getSelectionListByName( nameTarget, selList );
	MObject oTarget;
	selList.getDependNode( 0, oTarget );
	MFnDagNode fnNode( oTarget );

	m_objectKeyDataImport.oTargetNode = oTarget;
	readUnsignedInt( m_objectKeyDataImport.unit, inFile );

	readStringArray( m_objectKeyDataImport.namesAttribute, inFile );
	readDoubleArray( m_objectKeyDataImport.dArrTime, inFile );

	unsigned int lengthValues = m_objectKeyDataImport.namesAttribute.length() * m_objectKeyDataImport.dArrTime.length();
	m_objectKeyDataImport.dArrValuesArray.setLength( lengthValues );
	for( unsigned int j=0; j<lengthValues; j++ )
		inFile.read( ( char* )&m_objectKeyDataImport.dArrValuesArray[j], sizeof( double ) );

	inFile.close();

	return MS::kSuccess;
}
Example #6
0
//
// This callback gets called for the PostToolChanged and SelectionChanged events.
// It checks to see if the current context is the dragAttrContext, which is the context
// applied by default when a custom numeric attribute is selected in the channel box.
// In this case, the customAttrManip context is set.
// 
static void eventCB(void * data)
{
	// This check prevents recursion from happening when overriding the manip.
	if (isSetting)
		return;

	MSelectionList selList;
	MGlobal::getActiveSelectionList(selList);

	MString curCtx = "";
	MGlobal::executeCommand("currentCtx", curCtx);

	MDagPath path;
	MObject dependNode;
	for (unsigned int i=0; i<selList.length(); i++)
	{
        if ((selList.getDependNode(i, dependNode)) == MStatus::kSuccess)
		{
			MFnTransform node;
			if (node.hasObj(dependNode))
				node.setObject(dependNode);
			else
				continue;

			if (node.typeId() == rockingTransformNode::id)
			{
				// If the current context is the dragAttrContext, check to see
				// if the custom channel box attributes are selected.  If so,
				// attach the custom manipulator.
				if ((curCtx == "dragAttrContext") || (curCtx == ""))
				{
					// Make sure that the correct channel box attributes are selected
					// before setting the tool context.
					unsigned int c;
					MStringArray cboxAttrs;
					MGlobal::executeCommand(
							"channelBox -q -selectedMainAttributes $gChannelBoxName", cboxAttrs);
					for (c=0; c<cboxAttrs.length(); c++)
					{
						if (cboxAttrs[c] == customAttributeString)
						{
							isSetting = true;
							MGlobal::executeCommand("setToolTo myCustomAttrContext");
							isSetting = false;
							return;
						}
					}
				}
				if ((curCtx == "moveSuperContext") || (curCtx == "manipMoveContext") ||
					(curCtx == ""))
				{
					isSetting = true;
					MGlobal::executeCommand("setToolTo myCustomTriadContext");
					isSetting = false;
					return;
				}
			}
		}
	}
}
    // ------------------------------------------------------
    // Unlike Maya's default behavior, we want to consider set membership to be inheritable
    bool SetHelper::isMemberOfSet ( const MDagPath& dagPath, MFnSet& Set )
    {
        if ( Set.isMember ( dagPath ) )
        {
            return true;
        }

        else
        {
            MFnDagNode dagNode ( dagPath );
            MSelectionList setMembers;
            Set.getMembers ( setMembers, true );

            for ( unsigned int i = 0; i < setMembers.length(); ++i )
            {
                MObject memberObject;

                if ( setMembers.getDependNode ( i, memberObject ) )
                {
                    if ( dagNode.isChildOf ( memberObject ) )
                    {
                        return true;
                    }
                }
            }
        }

        return false;
    }
Example #8
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;
}
Example #9
0
MStatus particlePathsCmd::parseArgs( const MArgList& args )
{
	MArgDatabase argData(syntax(), args);

	//
	// Parse the time flags
	//

	if (argData.isFlagSet(startFlag))
	{
		argData.getFlagArgument(startFlag, 0, start);
	}

	if (argData.isFlagSet(finishFlag))
	{
		argData.getFlagArgument(finishFlag, 0, finish);
	}

	if (argData.isFlagSet(incrementFlag))
	{
		argData.getFlagArgument(incrementFlag, 0, increment);
	}

	if (finish <= start || increment <= 0.0)
	{
		MGlobal::displayError( "Invalid time arguments." );
		return MS::kFailure;
	}

	//
	// Get the particle system object
	//

	MSelectionList selectList;
	argData.getObjects(selectList);
	
	if( selectList.length() < 1 )
	{
		MGlobal::displayError( "Missing particle node name argument." );
		return MS::kFailure;
	}
	else if( selectList.length() > 1 )
	{
		MGlobal::displayError( "Too many particle nodes given." );
		return MS::kFailure;
	}

	selectList.getDependNode(0,particleNode);

	if (particleNode.isNull() || !particleNode.hasFn(MFn::kParticle))
	{
		MGlobal::displayError( "Invalid node argument." );
		return MS::kFailure;
	}

	return MS::kSuccess;
}
Example #10
0
	MStatus GetSelectedObjectsOfType(MObjectArray & objects, MTypeId & type) {
		MStatus status;
		MSelectionList selectionList;

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

		if (!(status = objects.clear())) {
			status.perror("MObjectArray::clear");
			return status;
		}

		unsigned int selectionList_length = selectionList.length(&status);

		if (!status) {
			status.perror("MSelectionList::length");
			return status;
		}

		for(unsigned int i = 0; i < selectionList_length; ++i) {
			//MDagPath dagPath;
			MObject object;

			if (!(status = selectionList.getDependNode(i, object))) {
				status.perror("MSelectionList::getDependNode");
				return status;
			}

			MObject relative = GetObjectOrParentsOfType(object, type, status);

			if (!status) {
				status.perror("GetObjectOrParentsOfType");
				return status;
			}

			if (relative != MObject::kNullObj) {
				/*
				 * Make sure it's not already added
				 */

				bool contains = false;
				for(unsigned int i = 0; i < objects.length(); ++i) {
					if (objects[i] == object) {
						contains = true;
						break;
					}
				}

				if (!contains)
					objects.append(relative);
			}
		}

		return MStatus::kSuccess;
	}
	MObject getMObjectByName(const MString& name)
	{
		MSelectionList sList;
		MGlobal::getSelectionListByName(name, sList);
		assert(1==sList.length());
		
		MObject mobj;
		sList.getDependNode(0, mobj);
		return mobj;
	}
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;
}
    //---------------------------------------------------
    MObject DagHelper::getNode ( const MString& name )
    {
        MSelectionList selection;
        selection.add ( name );

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

        return nodeObject;
    }
Example #14
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();

}
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;
}
Example #16
0
MStatus pbdSolverCmd::redoIt()
{
	//create solver node
	MStatus stat;
	MObject transform = dgMod.createNode("transform");
    MObject solver= dgMod.createNode(pbdSolverNode::typeId, transform, &stat);
	//connect time attribute
	MPlug plgInTime(solver,pbdSolverNode::time);
	MItDependencyNodes dnTime(MFn::kTime);
	MObject time = dnTime.thisNode();
	MPlug plgOutTime = MFnDependencyNode(time).findPlug("outTime", false);
	dgMod.connect(plgOutTime, plgInTime);
	
	//connect msattr
	MSelectionList activeSelect; 
	MGlobal::getActiveSelectionList(activeSelect);

	int pnum = 0, mnum = 0;
	for(int i = 0;i < activeSelect.length(); ++i)
	{
		MObject tNode; 
		activeSelect.getDependNode(i,tNode);
		MFnDagNode fnDagNode(tNode);
		MObject pNode=fnDagNode.child(0); 
		MFnDependencyNode fnNode(pNode);
			
		//MString name=fnNode1.name().asChar();
		if(fnNode.typeId() == OParticleNode::typeId)
		{
			//get solver message attribute from particleNode
			MPlug s_msg(pNode,OParticleNode::pbd_solver);
			//get particle message attribute from solverNode
			MPlug o_msg(solver,pbdSolverNode::orientedParticle);
			dgMod.connect(o_msg,s_msg);
			++pnum;
		}
		else if(pNode.apiType()==MFn::kMesh)
		{
			MString name=MFnDependencyNode(pNode).name().asChar();
			MPlug m_vs=fnNode.findPlug("ogc",false);
			MPlug s_vs(solver,pbdSolverNode::inMesh);

			dgMod.connect(m_vs,s_vs);
			++mnum;
		}
	}
	if( pnum == 0 )
		MGlobal::displayError(" No oriented particles are selected");
	if( mnum == 0 )
		MGlobal::displayError(" No mesh is selected");

	MGlobal::displayInfo("PBD solver is created");
	return dgMod.doIt();	
}
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;
}
Example #18
0
	MStatus FillStrandGaps::doIt(const MArgList & args) {
		std::list<MObject> targets;
		MStatus status = ArgList_GetModelObjects(args, syntax(), "-t", targets);
		if (status != MStatus::kNotFound && status != MStatus::kSuccess) {
			HMEVALUATE_RETURN_DESCRIPTION("ArgList_GetModelObjects", status);
		}

		if (targets.empty()) {
			MSelectionList activeSelectionList;
			HMEVALUATE_RETURN(status = MGlobal::getActiveSelectionList(activeSelectionList), status);

			if (activeSelectionList.length() > 0) {
				for (unsigned int i = 0; i < activeSelectionList.length(); ++i) {
					MObject object;

					HMEVALUATE_RETURN(status = activeSelectionList.getDependNode(i, object), status);

					MFnDagNode dagNode(object);
					MTypeId typeId;
					HMEVALUATE_RETURN(typeId = dagNode.typeId(&status), status);

					if (typeId == HelixBase::id || typeId == Helix::id)
						targets.push_back(object);
					else
						MGlobal::displayWarning(MString("Ignoring unknown object \"") + dagNode.fullPathName() + "\"");
				}
			}
			else {
				/*
				 * Extract all helices
				 */

				MItDag itDag(MItDag::kDepthFirst, MFn::kPluginTransformNode, &status);
				HMEVALUATE_RETURN_DESCRIPTION("MItDag::#ctor", status);

				for (; !itDag.isDone(); itDag.next()) {
					MObject object;
					HMEVALUATE_RETURN(object = itDag.currentItem(&status), status);

					bool is_helix;
					HMEVALUATE_RETURN(is_helix = MFnDagNode(object).typeId(&status) == Helix::id, status);
					if (is_helix)
						targets.push_back(object);
				}
			}
		}

		return m_operation.fill(targets);
	}
Example #19
0
MStatus polyMessageCmd::doIt( const MArgList& )
//
// Takes the  nodes that are on the active selection list and adds an
// attriubte changed callback to each one.
//
{
    MStatus 		stat;
    MObject 		node;
    MSelectionList 	list;
    MCallbackId     id;

    // Register node callbacks for all nodes on the active list.
    //
    MGlobal::getActiveSelectionList( list );

    for ( unsigned int i=0; i<list.length(); i++ )
    {
        list.getDependNode( i, node );

        MDagPath dp;
        MObject shapeNode = node;
        if ( MS::kSuccess == MDagPath::getAPathTo( node, dp ) )
            if ( MS::kSuccess == dp.extendToShape() )
                shapeNode = dp.node();

        bool wantIdChanges[3];
        wantIdChanges[MPolyMessage::kVertexIndex] = true;
        wantIdChanges[MPolyMessage::kEdgeIndex] = true;
        wantIdChanges[MPolyMessage::kFaceIndex] = true;

        id = MPolyMessage::addPolyComponentIdChangedCallback( shapeNode,
                wantIdChanges, 3,
                userCB,
                NULL,
                &stat);

        // If the callback was successfully added then add the
        // callback id to our callback table so it can be removed
        // when the plugin is unloaded.
        //
        if ( stat ) {
            callbackIds.append( id );
        } else {
            cout << "MPolyMessage.addCallback failed\n";
        }
    }

    return stat;
}
MStatus NeuronForMayaCmd::doIt( const MArgList& args )
{
    MStatus status;

    status = parseArgs( args ); 
    if( status != MStatus::kSuccess)
    {
        MGlobal::displayError( "parameters are not correct." );
        return status;
    }

    MSelectionList sl;
    sl.add( mDeviceName );
    MObject deviceObj;
    status = sl.getDependNode(0, deviceObj );
    if(status != MStatus::kSuccess )
    {
        MGlobal::displayError("Please create your device first.");
        return status;
    }
    MFnDependencyNode fnDevice(deviceObj);
    MString ip = fnDevice.findPlug( "inputIp", &status ).asString();
    int     port = fnDevice.findPlug("inputPort", &status).asInt();


    if( mStart ){
        // to register the 3 callback to fetch data from Neuron
        BRRegisterFrameDataCallback(NULL, NeuronForMayaDevice::myFrameDataReceived );
        //BRRegisterCommandDataCallback(NULL, NeuronForMayaDevice::myCommandDataReceived );
        BRRegisterSocketStatusCallback (NULL, NeuronForMayaDevice::mySocketStatusChanged );

        socketInfo = BRConnectTo(const_cast<char*> (ip.asChar()), port);
        if(socketInfo == NULL )
            MGlobal::displayError("Failed to connect to device.");
    }
    else
    {
        // stop socket
        BRCloseSocket( socketInfo);
    }
    
    return MStatus::kSuccess;
}
Example #21
0
void ShapeMonitor::watch(MString mayaNodeName, MonitoredObject* pMon)
//
// Description:
//
//    Start watching the specified mayaNodeName for changes. (If the node is part of the DAG, that
// should be a fully-specified DAG name). This function will store all available information
// inside a MonitorObject for future reference.
//
// Arguments:
//		mayaNodeName: DG (or fully-qualified DAG) name.
//		uniqueTextureName: The corresponding texture name. This texture should correspond
//						   directly to an IFX texture resource.
{
	// Check if, per chance, this monitored object already exists.
	// If it does, no need to create a new one.
	if (retrieveMonitorObject(mayaNodeName))
		return;

	MStatus stat;

	//
	// Get the node.
	//
	MObject node;
	MSelectionList selList;
	selList.add(mayaNodeName);
	selList.getDependNode(0, node);

	//
	//	Attach the callbacks (dirty or renamed node)
	//
	pMon->mayaNodeName = mayaNodeName;

	pMon->dirtyCallbackId = MNodeMessage::addNodeDirtyCallback(node, watchedObjectDirtyCallback, pMon, &stat ); 
	assert(stat);

	pMon->renamedCallbackId = MNodeMessage::addNameChangedCallback ( node, watchedObjectRenamedCallback, pMon, &stat); 
	assert(stat);

	// Store the pertinent information in the Monitored Objects Array.
	monitoredObjectsPtrArray.append(pMon);
}
inline static MObject getNode(MString name,MStatus *returnStatus)
{
	MObject node;
	MSelectionList list;

	*returnStatus=MGlobal::getSelectionListByName(name,list);

	if(MS::kSuccess!=*returnStatus){
		ERROR("[raytraceMayaRenderView] Cound't get node :"+ name +". There might be multiple nodes called "+name);
		return node;
	}

	*returnStatus=list.getDependNode(0,node);

	if(MS::kSuccess!=*returnStatus){
		ERROR("[raytraceMayaRenderView] Cound't get node :"+ name +". There might be multiple nodes called "+name);
		return MObject::kNullObj;
	}
	return node;
}
Example #23
0
MObject getObjFromName(MString name, MStatus& stat)
{
	MObject obj;
	
	MSelectionList list;
	
	// Attempt to add the given name to the selection list,
	// then get the corresponding dependency node handle.
	if (!list.add(name) ||
		!list.getDependNode(0, obj))
	{
		// Failed.
		stat = MStatus::kInvalidParameter;
		return obj;
	}

	// Successful.
	stat = MStatus::kSuccess;
	return obj;
}
MStatus	liqGetAttr::doIt( const MArgList& args )
{
	CM_TRACE_FUNC("liqGetAttr::doIt(args)");

	MStatus					status;
	unsigned				i;
	MString					nodeName, attrName;
	MSelectionList				nodeList;

	for ( i = 0; i < args.length(); i++ ) 
  {
		if ( MString( "-debug" ) == args.asString( i, &status) ) 
    {
		} 
    else if ( MString( "-node" ) == args.asString( i, &status) ) 
    {
			i++;
			nodeName = args.asString( i, &status ) ;
		} 
    else if ( MString( "-attr" ) == args.asString( i, &status) ) 
    {
			i++;
			attrName = args.asString( i, &status );
		}
	}
	nodeList.add( nodeName );
	MObject depNodeObj;
	nodeList.getDependNode(0, depNodeObj);
	MFnDependencyNode depNode( depNodeObj );
	MPlug attrPlug = depNode.findPlug( attrName );
	MObject plugObj;
	attrPlug.getValue( plugObj );
	if( plugObj.apiType() == MFn::kDoubleArrayData ) 
  {
	  MFnDoubleArrayData fnDoubleArrayData( plugObj );
	  const MDoubleArray& doubleArrayData( fnDoubleArrayData.array( &status ) );
	  for ( i = 0; i < doubleArrayData.length(); i++ ) 
		  appendToResult( doubleArrayData[i] );
	}
	return MS::kSuccess;
};
Example #25
0
MStatus deletedMessage::doIt( const MArgList& args )
{
	MStatus status = MS::kSuccess;

	MArgDatabase argData(syntax(), args);
	MSelectionList objects;
	argData.getObjects(objects);

	for (unsigned int i = 0; i < objects.length(); i++) {
		MObject node;
		objects.getDependNode(i, node);
		
		callbackIds.append(
			MNodeMessage::addNodeAboutToDeleteCallback (node, aboutToDeleteCB, NULL, &status)
		);
		if (!status) {
			MGlobal::displayWarning("Could not attach about to delete callback for node.");
			continue;
		}
		callbackIds.append(
			MNodeMessage::addNodePreRemovalCallback (node, preRemovalCB, NULL, &status)
		);
		if (!status) {
			MGlobal::displayWarning("Could not attach pre-removal callback for node.");
			continue;
		}
		if (!nodeRemovedCBRegistered)
		{
			callbackIds.append(
				MDGMessage::addNodeRemovedCallback(removeCB, "dependNode", NULL, &status)
			);
			if (!status) {
				MGlobal::displayWarning("Could not attach node removal callback.");
				continue;
			}
			nodeRemovedCBRegistered = true;
		}
	}
	
	return status;
}
Example #26
0
void MeshGitCmd::manualResolveConflict(MString resolution, MString nodeName)
{
	MStatus status;
	if(nodeName == NULL || nodeName =="") 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);

	//Resolve conflict with resolution
	int rc = resolution.asInt();
	mgFn.manualResolveConflict(rc);

	reportError(status);
}
Example #27
0
MStatus PRTAttrs::doIt(const MArgList& args) {
	MStatus stat;

	MString prtNodeName = args.asString(0, &stat);
	MCHECK(stat);

	MSelectionList tempList;
	tempList.add(prtNodeName);
	MObject prtNode;
	MCHECK(tempList.getDependNode(0, prtNode));
	MFnDependencyNode fNode(prtNode, &stat);
	MCHECK(stat);

	if(fNode.typeId().id() != PRT_TYPE_ID)
		return MS::kFailure;

	MString sRulePkg;
	updateRuleFiles(fNode, getStringParameter(prtNode, ((PRTNode*)fNode.userNode())->rulePkg, sRulePkg));

	MGlobal::executeCommand(MString("refreshEditorTemplates"));

	return MS::kSuccess;
}
Example #28
0
MStatus nodeMessageCmd::doIt( const MArgList& )
//
// Takes the  nodes that are on the active selection list and adds an
// attriubte changed callback to each one.
//
{
	MStatus 		stat;
	MObject 		node;
	MSelectionList 	list;
    MCallbackId     id;
    
	// Register node callbacks for all nodes on the active list.
	//
	MGlobal::getActiveSelectionList( list );

    for ( unsigned int i=0; i<list.length(); i++ )
    {
        list.getDependNode( i, node );
        
	    id = MNodeMessage::addAttributeChangedCallback( node,
                                                        userCB,
                                                        NULL,
                                                        &stat);

    	// If the callback was successfully added then add the
        // callback id to our callback table so it can be removed
        // when the plugin is unloaded.
	    //
	    if ( stat ) {
		    callbackIds.append( id );
    	} else {
	    	cout << "MNodeMessage.addCallback failed\n";
    	}
    }
        
	return stat;
}
MStatus clusterWeightFunctionCmd::doIt(const MArgList &argList)
{
	MStatus status;

	MSelectionList list;
	MGlobal::getActiveSelectionList(list);
	
	// Get the cluster
	MFnWeightGeometryFilter cluster;
	MObject dgNode;
	list.getDependNode(0, dgNode);
	if (!cluster.setObject(dgNode))
		return MS::kFailure;

	// Get the object
	MDagPath dagPath;
	MObject component;
	list.getDagPath(1, dagPath, component);

	status = parseArgs(argList);
	if (MS::kSuccess == status)
		status = performWeighting(cluster, dagPath, component);
	return status;
}
Example #30
0
int tm_polygon::removeTweaks_Func( MSelectionList &selectionList)
{
   MStatus status;
   MObject object;
   status = selectionList.getDependNode( 0, object);
   if(!status)
   {
      MGlobal::displayError("***### tm_polygon: Can't find object.");
      return 0;
   }
   MFnMesh mesh( object, &status);
   if(!status)
   {
      MGlobal::displayError("***### tm_polygon: Can't find mesh.");
      return 0;
   }

   int pntsCount = 0;
   MPlug pntsPlug = mesh.findPlug( "pnts" );
   if( !pntsPlug.isNull() )
   {
      MPlug tweakPlug;
      MObject nullVector_object;
      MFnNumericData numDataFn( nullVector_object );
//      numDataFn.setData3Double( 0.0, 0.0, 0.0 );
      numDataFn.setData( 0.0, 0.0, 0.0 );
      pntsCount = pntsPlug.numElements();
      for( int i = 0; i < pntsCount; i++ )
      {
         tweakPlug = pntsPlug.elementByPhysicalIndex( (unsigned int)i, &status );
         if( status == MS::kSuccess && !tweakPlug.isNull() )
            tweakPlug.setValue( nullVector_object );
      }
   }
   return pntsCount;
}