How can we find programmatically whether a DGN element has a particular property?
For example, several elements have a Length property. It's valid for lines, line-strings, arcs and I believe curve vectors in general. The picture is blurred because sometimes the property name (not its display name) is Length and sometimes TotalLength. But can I determine that fact programmatically: I'm looking for fictitious method something like HasProperty (ElementHandleR eh, L"className", L"propName")?
Length
TotalLength
HasProperty (ElementHandleR eh, L"className", L"propName")
In particular, for my current project I want to know whether a DGN element has the Bearing or Azimuth property. A simple DGN line element has that property, but what other element types?
Bearing
Azimuth
You can try to get all instances available on a specific element. And then check if the individual instance has a specific property:
//ECQueryProcessFlags flags = intrinsic or extrinsic
ECInstanceList GetElementProperties(ElementHandleCR element, ECQueryProcessFlags flags){ ECInstanceList ecInstanceList; DgnECManagerR dgnECManager = DgnECManager::GetManager();
FindInstancesScopePtr scope = FindInstancesScope::CreateScope(element, FindInstancesScopeOption(DgnECHostType::Element)); ECQueryPtr findAll = ECQuery::CreateQuery(flags); for each (DgnECInstancePtr instance in dgnECManager.FindInstances(*scope, *findAll)) ecInstanceList.push_back(instance);
return ecInstanceList;}
Also, if you know Schema-Class, then you can prepare ECQuery accordingly.
Answer Verified By: Jon Summers
Mangesh.Shelar said:You can try to get all instances available on a specific element.
Thanks for the code how to ask for EC properties, the approach I mentioned as one from possible solutions.
Mangesh.Shelar said:Also, if you know Schema-Class, then you can prepare ECQuery accordingly.
I think it would be BaseElementSchema or DgnElementSchema in this case.
Regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point