当前位置: 首页>>代码示例>>C++>>正文


C++ MFnDependencyNode::addAttribute方法代码示例

本文整理汇总了C++中MFnDependencyNode::addAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ MFnDependencyNode::addAttribute方法的具体用法?C++ MFnDependencyNode::addAttribute怎么用?C++ MFnDependencyNode::addAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MFnDependencyNode的用法示例。


在下文中一共展示了MFnDependencyNode::addAttribute方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: addParameter

MStatus PRTAttrs::addParameter(MFnDependencyNode & node, MObject & attr, MFnAttribute& tAttr) {
	if(!(node.hasAttribute(tAttr.shortName()))) {
		MCHECK(tAttr.setKeyable (true));
		MCHECK(tAttr.setHidden(false));
		MCHECK(tAttr.setStorable(true));
		MCHECK(node.addAttribute(attr));
	}
	return MS::kSuccess;
}
开发者ID:Esri,项目名称:esri-cityengine-sdk,代码行数:9,代码来源:PRTAttrs.cpp

示例2: addAttribute

    //---------------------------------------------------
    MPlug DagHelper::addAttribute ( const MObject& node, const MObject& attribute )
    {
        MPlug plug;
        MFnAttribute attributeFn ( attribute );
        MFnDependencyNode depFn ( node );
        MStatus status = depFn.addAttribute ( attribute, MFnDependencyNode::kLocalDynamicAttr );
        if ( status == MStatus::kSuccess )
        {
            plug = depFn.findPlug ( attribute );
        }

        return plug;
    }
开发者ID:3dfreeman,项目名称:OpenCOLLADA,代码行数:14,代码来源:COLLADAMayaDagHelper.cpp

示例3: SetNodeID

MStatus Maya::SetNodeID( const MObject& node, const Helium::TUID& id )
{
  MStatus status;
  MFnDependencyNode nodeFn (node);

  // make sure we have the dynamic attribute to store our id created
  MObject attr = nodeFn.attribute(MString (s_TUIDAttributeName), &status);
  if (status == MS::kFailure)
  {
    // check to see if we are a locked node
    bool nodeWasLocked = nodeFn.isLocked();
    if ( nodeWasLocked )
    {
      // turn off any node locking so an attribute can be added
      nodeFn.setLocked( false );
    }

    // create the attribute
    MFnTypedAttribute attrFn;
    attr = attrFn.create(MString (s_TUIDAttributeName), MString (s_TUIDAttributeName), MFnData::kString);
    status = nodeFn.addAttribute(attr);

    // reset to the prior state of wasLocked
    if ( nodeWasLocked )
    {
      nodeFn.setLocked( nodeWasLocked );
    }

    // error check
    if (status == MS::kFailure)
    {
      MGlobal::displayError(MString ("Unable to create TUID attribute on maya node: ") + nodeFn.name());
      return status;
    }
  }

  MPlug plug (node, nodeFn.attribute(MString (s_TUIDAttributeName)));

  plug.setLocked(false);

  tstring s;
  id.ToString(s);
  plug.setValue(MString(s.c_str()));

  plug.setLocked(true);

  return status;
}
开发者ID:,项目名称:,代码行数:48,代码来源:

示例4: createAttribute

    //---------------------------------------------------
    MObject DagHelper::createAttribute (
        const MObject& node,
        const char* attributeName,
        const char* attributeShortName,
        MFnData::Type type,
        const char *value )
    {
        // Before creating a new attribute: verify that an old one doesn't already exist
        MStatus status;
        MObject attribute;
        MFnDependencyNode nodeFn ( node );
        MPlug plug = nodeFn.findPlug ( attributeShortName, status );

        if ( status != MStatus::kSuccess )
        {
            MFnTypedAttribute attr;
            MStatus status;
            attribute = attr.create ( attributeName,attributeShortName,type,&status );
            if ( status != MStatus::kSuccess ) return MObject::kNullObj;

            attr.setStorable ( true );
            attr.setKeyable ( false );
            attr.setCached ( true );
            attr.setReadable ( true );
            attr.setWritable ( true );
            status = nodeFn.addAttribute ( attribute, MFnDependencyNode::kLocalDynamicAttr );
            if ( status != MStatus::kSuccess ) return MObject::kNullObj;

            plug = nodeFn.findPlug ( attribute, &status );
            if ( status != MStatus::kSuccess ) return MObject::kNullObj;
        }

        status = plug.setValue ( value );
        if ( status != MStatus::kSuccess ) return MObject::kNullObj;

        return attribute;
    }
开发者ID:3dfreeman,项目名称:OpenCOLLADA,代码行数:38,代码来源:COLLADAMayaDagHelper.cpp

示例5: doIt

MStatus testGlassCmd::doIt(const MArgList &args)
{
	MStatus stat=MStatus::kSuccess;

	MSelectionList list;
	MFnDependencyNode meshDependFn;
	MFnDependencyNode materialDependFn;
	MDGModifier dgMod;

	//create a new material node, here is the test glass node
	MObject testGNode=dgMod.createNode(testGlassNode::id);
	materialDependFn.setObject(testGNode);
	MString testName=materialDependFn.name();
	MGlobal::displayInfo(testName+" god, please give me the node first time");


	//find the mesh node(s) from selected object(s)
	//create a new "yafaray material" attribute if the mesh node(s) dont have
	//then conect the material node to the mesh node(s)
	MGlobal::getActiveSelectionList( list );
	MItSelectionList iter( list, MFn::kMesh );
	for( ; !iter.isDone(); iter.next())
	{
		MObject meshDependNode;
		MFnNumericAttribute numAttr;
		

		iter.getDependNode( meshDependNode );
		meshDependFn.setObject( meshDependNode );
		//MString dependName=dependFn.name();
		//MGlobal::displayInfo(dependName+" is here\n");

		if( !meshDependFn.hasAttribute("YafarayMaterial") )
		{
			MObject attrYafarayMaterial=numAttr.create("YafarayMaterial","yama",MFnNumericData::kBoolean);
			numAttr.setDefault( true );
			numAttr.setStorable( true );
			meshDependFn.addAttribute(attrYafarayMaterial,MFnDependencyNode::kLocalDynamicAttr);
		}

        //find the source plug and the result plug, then connect them
		//if the result plug as  already had a sourse plug connected to it, disconnect first
		MPlug glassPlug=materialDependFn.findPlug("OutGlass");
		MPlug meshPlug=meshDependFn.findPlug("YafarayMaterial");

		MPlugArray srcMeshPlug;		
		if(meshPlug.connectedTo(srcMeshPlug, true, false))
		{
			MPlug srcPlug;
			//if(srcMeshPlug.length!=0) 
			//{
				srcPlug=srcMeshPlug[0];
			//}

			dgMod.disconnect(srcPlug, meshPlug);
		}

		dgMod.connect(glassPlug,meshPlug);

	}



	dgMod.doIt();
	//why still cant got the name here?
	MGlobal::displayInfo(testName+" god, please give me the node second time");
	
	return stat;
}
开发者ID:Maitreya,项目名称:YafaRay-Maya-Exporter,代码行数:69,代码来源:testGlassCmd.cpp


注:本文中的MFnDependencyNode::addAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。