Hello everyone,
How do I make a temporary body unselectable?
Hello everyone,
How do I make a temporary body unselectable?
Use swTempBodySelectOptions_e.swTempBodySelectOptionNone for the last parameter of IBody2::Display3 method
Hi Artem,
I have tried IBody2::Display3 method in following way.
swBody->Display3(modelDoc, RGB(0, 0, 255), swTempBodySelectOptions_e::swTempBodySelectOptionNone, &retVal)
The retVal given by this function is 0(successful) but temporary body is still selectable in view.
Following is the code:
CComPtr<IModelDoc2> modelDoc;
SwApp->get_IActiveDoc2(&modelDoc);
CComPtr<IModeler> 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<IBody2> swBody;
modler->ICreateBodyFromCone2(dblData, &swBody);
CComPtr<IPartDoc> partDoc;
partDoc = modelDoc;
CComPtr<IFeature> feature;
partDoc->ICreateFeatureFromBody4(swBody, false, 0, &feature);
VARIANT_BOOL retBool;
feature->SetUIState(swUIStates_e::swIsHiddenInFeatureMgr, true);
modelDoc->EditRebuild3(&retBool);
long retVal;
swBody->Display3(modelDoc, RGB(0, 0, 255), swTempBodySelectOptions_e::swTempBodySelectOptionNone, &retVal);
What if you remove this portion?:
CComPtr<IFeature> feature;
partDoc->ICreateFeatureFromBody4(swBody, false, 0, &feature);
VARIANT_BOOL retBool;
feature->SetUIState(swUIStates_e::swIsHiddenInFeatureMgr, true);
modelDoc->EditRebuild3(&retBool);
I believe this is not your temp body selectable, but the actual body in the tree as it is the same as your temp body as you have created the feature from it.
BTW. What are you trying to do? Your code does the following:
You need to keep the swBody pointer alive. Declare it as local variable, otherwise it will be automatically destroyed and temp body disappears.