Hi
I've created some parametric cells in a celllibrary and I want to place them programmatically. I've looked into the constraint2ddemo example and I've made it work but this example 'just' places a parametric cell with predefined values from a parameterset. i would like to specify the values individually using input from the user. As a test I've made some small modifications to the exampleFunctionalCellFromDgn function:
After this line
auto defaultInfo = ParametricCellInfo::Create(status, *def, L"set1", plcModel/**pModel*/);
I've added these lines of code:
IParameterDefinitionsPtr paramDefs = def->GetParameterDefinitions(); VirtualCollectionIterator<IParameterDefinitionsIterator> iterEnd = paramDefs->end(); for (VirtualCollectionIterator<IParameterDefinitionsIterator> iter = paramDefs->begin(); iter != iterEnd; ++iter) { ECValue val1; mdlDialog_dmsgsPrint((*iter).GetDisplayLabel()); if (wcsicmp((*iter).GetDisplayLabel(), L"Radius1") == 0) { ECObjectsStatus rc = def->SetValue((*iter).GetAccessString(), ECValue(43.0)); char msg[80]; sprintf(msg, "rc = %d", rc); mdlDialog_dmsgsPrintA(msg); } } def->WriteValues();
The value returned is 200730 meaning Bentley::ECN::ECOBJECTS_STATUS_UnableToSetReadOnlyProperty
Is it somehow possible to place a parametric cell and specify specify the values individually ?
TIA
Regards, Evan
Hi Evan,
As per current sample code available with us; there is no means to address the mentioned scenario by using API.
We have reported Defect 945501: [Community][Microstation Forum]SDK sample for creating parametric cell programmatically to track the issue and soon come up with the solution.
I appreciate your patience,
Regards,
Abhijit
Hi Abhijit,
has this defect been solved now? I still have the same Problem.
[RH-20220323-UPDATE: MicroStation CONNECT Edition SDK Update 13 added: ..\examples\Elements\ManagedParametricCellPlacementExample to resolve Defect 945501]
Hi Manuel Höger,
MicroStation CONNECT Edition SDK Update 13 added: ..\examples\Elements\ManagedParametricCellPlacementExample to resolve Defect 945501.
HTH,Bob
Hi Robert,
As I see, this example just starts the keyIn for placing a parametric cell. But I can't find any Code to manipulate the parameter values of the cell like in Evans Example above.
I need to change the parameters of a placed parametric cell problematically but all tries failed until now.
This is the code I tried:
EditElementHandle eeh; ParameterStatus status = ParameterStatus::Success; DgnFileP designFileP = ACTIVEMODEL->GetDgnFileP();; ElementRefP eleRef = ParametricCellDefHandler::GetInstance().FindByName(m_cellName.c_str(), *designFileP); if (!eleRef) return; ParametricCellDefinitionPtr def = ParametricCellDefHandler::GetInstance().GetCellDefinition(EditElementHandle(eleRef)); ParametricCellInfoPtr defaultInfo = ParametricCellInfo::Create(status, *def, NULL, *ACTIVEMODEL->AsDgnModelP()); //IEditParameterDefinitionsPtr editParamDefs = def->GetParameterDefinitions()->GetForEdit(); //looked like the solution but returns a nullptr IParameterDefinitionsPtr paramDefs = def->GetParameterDefinitions(); VirtualCollectionIterator<IParameterDefinitionsIterator> iterEnd = paramDefs->end(); for (VirtualCollectionIterator<IParameterDefinitionsIterator> iter = paramDefs->begin(); iter != iterEnd; ++iter) { mdlDialog_dmsgsPrint((*iter).GetDisplayLabel()); if (wcsicmp((*iter).GetDisplayLabel(), L"Length") == 0) { ECN::ECObjectsStatus rc = def->SetValue((*iter).GetAccessString(), ECN::ECValue(43.0)); //ECOBJECTS_STATUS_UnableToSetReadOnlyProperty } } status=def->WriteValues(); //ERROR status = ParametricCellHandler::GetInstance().CreateCellElement(eeh, *defaultInfo.GetCR()); //SUCCESS wprintf(L"%s\n", status == ParameterStatus::Success ? L"SUCCESS" : L"ERROR"); eeh.AddToModel(); //SUCCESS return;