C++ Export Plugin / can I get blendshape target directory?

C++ Export Plugin / can I get blendshape target directory?

Anonymous
Not applicable
837 Views
1 Reply
Message 1 of 2

C++ Export Plugin / can I get blendshape target directory?

Anonymous
Not applicable

HI, all.

I am developing an export plugin
So, I need to get the blend shape group, but I couldn't manage it.

 

exsample.png

 

MFnBlendShapeDeformer bsFn(bs);
auto attr = bsFn.attribute("targetDirectory");
if (!attr.isNull()) {
	MFnCompoundAttribute compAttr(attr);
	for (int c = 0; c < compAttr.numChildren(); c++) {
		auto child = compAttr.child(c);
		if (child.apiType() == MFn::kTypedAttribute) {
			//??
		} else if (child.apiType() == MFn::kNumericAttribute) {
			//??
		} else {
			//??
		}
	}
}

I understand that kTypedAttribute and kNumericAttribute can be obtained with such code, but I can not get the value.

I want to get

 a) the weight of the group

 b) the parent of the group

 c) child of the group

 

 

 

 

>blendshape.ma

setAttr ".tgdt[0].cid" -type "Int32Array" 2 -1 2 ;                   <-
setAttr ".tgdt[1].cid" -type "Int32Array" 2 0 1 ;                   <-
setAttr ".tgdt[1].dtn" -type "string" "Group 1";
setAttr -av ".tgdt[1].dwgh" 0.30000001192092896;   <-

 

please give me some help.

 

0 Likes
Accepted solutions (1)
838 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
Accepted solution

sorry.

This Issue has been self-solved, using elementByPhysicalIndex.

I didn't notice the array of targetDirectry.

 

I got it with this code.

 

//get target directory plug.
//bsFn is MFnBlendShapeDeformer auto tgdtPlug = bsFn.findPlug("tgdt"); if (!tgdtPlug.isNull()) { //loop for target directories. for (int tgdti = 0; tgdti < tgdtPlug.numElements(); tgdti++) { auto compund = tgdtPlug.elementByPhysicalIndex(tgdti); //process compound elements. for (int ci = 0; ci < compund.numChildren(); ci++) { //plug & attribute object auto& elemPlug = compund.child(ci); MFnAttribute elemAttr(elemPlug.attribute()); auto sn = elemAttr.shortName(); if (sn == "pnid") { elemPlug.asInt(); //parent id } else if (sn == "cid") { MObject intArray = elemPlug.asMObject(); auto ia = MFnArrayAttrsData(intArray).intArray(""); //children id(s) } else if (sn == "dwgh") { elemPlug.asFloat(); //weight } else if (sn == "dtn") { elemPlug.asString(); //name } else if(etc) ... } } } }

 

0 Likes