Ok, so after asking I plugged away and figured out how to do it. Here is
what I found for anyone else who is interested in doing this.
def getAttrPlug(nodeName, attrName):
selectionList = OpenMaya.MSelectionList()
try:
selectionList.add(nodeName)
except:
return None
dependNode = selectionList.getDependNode(0)
dagNode = OpenMaya.MFnDagNode(selectionList.getDagPath(0))
attrNode = dagNode.attribute(attrName)
return OpenMaya.MPlug(dependNode,attrNode)
def createPluginData(typeId, dataList):
pluginDataCreator = OpenMaya.MFnPluginData()
bdtID = OpenMaya.MTypeId(typeId)
pluginDataCreator.create(bdtID)
values = bytearray(dataList)
pluginDataCreator.data().readBinary(values, len(dataList))
return pluginDataCreator.data()
blindNode = getAttrPlug("blind", "blindData")
blindData = createPluginData(0x00001948, [84,111,111,32,69,97,115,121])
dataHandle = blindNode.asMDataHandle()
dataHandle.setMPxData(blindData)
On Wednesday, February 22, 2017 at 2:16:03 PM UTC-8, Cameron Fulton wrote:
>
> Hi all,
>
> So I have a custom data type that I create in cpp that I use for an
> attribute on a custom node. My custom data type is pretty straight forward:
> class BlindData : public MPxData
> {
>
>
> public:
> BlindData();
> virtual ~BlindData();
>
>
> /**
> * Copy the local data from a similar data object
> *
> * @param MPxData
> * Data object to copy from.
> */
> virtual void copy(const MPxData&);
>
>
> MStatus
> readBinary(istream& in, unsigned int length);
>
>
> MStatus
> writeBinary(ostream& out);
>
>
> MTypeId typeId() const;
>
>
> MString name() const;
>
> static MString typeName;
> static MTypeId id;
> static void* creator();
>
>
> std::vector<char> m_data;
> };
>
> And then I just use that as a type for my attr on my node
> MFnTypedAttribute tAttr;
> MStatus stat;
>
> blindDataAttr = tAttr.create("blindData",
> "blind",
> BlindData::id,
> MObject::kNullObj,
> &stat);
> addAttribute(mPoseDataList);
>
>
> So now I want to set that in Python, but I'm not sure how too. Anyone run
> into this before?
>
--
You received this message because you are subscribed to the Google Groups
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/03035e4d-77fe-4ad4-88be-902e6248c70b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.