I have created one temporary body, and tried to add attribute to it. But CreateInstance5() method return null.
What is the problem? The code is as follow.
CComPtr
SwApp->get_IActiveDoc2(&modelDoc);
CComPtr
SwApp->IGetModeler(&modler);
double dblData[9];
// cone X Y Z Face Center
dblData[0] = 0;
dblData[1] = 0.3;
dblData[2] = 0;
// cone X Y Z Axis (rotation)
dblData[3] = 0;
dblData[4] = 0;
dblData[5] = 1;
// cone Base Radius , cone Top Radius, cone Height
dblData[6] = 0.2;
dblData[7] = 0;
dblData[8] = 0.3;
CComPtr
modler->ICreateBodyFromCone2(dblData, &swBody);
long retVal;
CComPtr
swBody->Display3(modelDoc, RGB(0, 0, 255), swTempBodySelectOptions_e::swTempBodySelectOptionNone, &retVal);
VARIANT_BOOL retval1;
CComPtr
SwApp->IDefineAttribute(L"TestAttributeTest", &attributeDef);
attributeDef->AddParameter(L"TestAttribute", swParamType_e::swParamTypeDouble, 2.0, 0, &retval1);
attributeDef->Register(&retval1);
CComPtr
attributeDef->CreateInstance5(modelDoc, swBodyDisp, L"TestAttribute", 0, swInConfigurationOpts_e::swAllConfiguration, &attribute);