Can we add attribute to temporary bodies?

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 modelDoc;
SwApp->get_IActiveDoc2(&modelDoc);

CComPtr modler;
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 swBody;
modler->ICreateBodyFromCone2(dblData, &swBody);

long retVal;
CComPtr swBodyDisp(swBody);
swBody->Display3(modelDoc, RGB(0, 0, 255), swTempBodySelectOptions_e::swTempBodySelectOptionNone, &retVal);

VARIANT_BOOL retval1;
CComPtr attributeDef;
SwApp->IDefineAttribute(L"TestAttributeTest", &attributeDef);
attributeDef->AddParameter(L"TestAttribute", swParamType_e::swParamTypeDouble, 2.0, 0, &retval1);

attributeDef->Register(&retval1);

CComPtr attribute;
attributeDef->CreateInstance5(modelDoc, swBodyDisp, L"TestAttribute", 0, swInConfigurationOpts_e::swAllConfiguration, &attribute);

SolidworksApi/macros