Hi
I would like to read some XAttributes values from elements. The values is listed In the element information window (please see the attached screendum). I've attached a design file with just a few elements with XAttributes. In V8i I could read this information via XMLInstanceAPI but I can't figure out how to read it in Connect. Until now I got this:
XAttributeHandlerId handlerId = XAttributeHandlerId(0, 0); XAttributeCollection col = XAttributeCollection(elmRefIn, handlerId); int count = 0; XAttributeCollection::const_iterator iterEnd = col.end(); for (XAttributeCollection::const_iterator iter = col.begin(); iter != iterEnd; ++iter) { (*iter).GetHandlerId(); (*iter).GetId()); (*iter).PeekData(); count++; }
I can read the HandlerId's / Id's and I can get the data as a void pointer and then what ? Please note that I'm not the author of the data.
I've been looking through the documentation and this forum but I've not been able to find the clue in how to go on...
TIA...
Regards, Evan
4152.example.dgn
Unknown said:Please use the DgnEC APIs to read EC data in CONNECT Edition
Could you expand a little on your recommendation? I see those classes also in the MicroStationAPI documentation. What reason is there to prefer .NET over native code?
Regards, Jon Summers LA Solutions
Thank you very much for the replies.
Now I've managed to get the labels, typenames and values of the properties using the code listed below:
ElementHandle eh(elmRefIn, ISessionMgr::GetActiveDgnModelRefP()); FindInstancesScopeOption scopeOptions; scopeOptions.SetSearchAttachments(true); FindInstancesScopePtr scopeP = FindInstancesScope::CreateScope(eh, scopeOptions); DgnECManagerR ecManager = DgnECManager::GetManager(); ECQueryPtr query = ECQuery::CreateQuery(ECQueryProcessFlags::ECQUERY_PROCESS_SearchAllClasses); DgnECInstanceIterable instanceIter = ecManager.FindInstances(*scopeP, *query); for each (DgnECInstanceP instP in instanceIter) { WString displayLabel; instP->GetDisplayLabel(displayLabel); ECN::ECClassCR cls = instP->GetClass(); if (cls.GetPropertyCount(false) > 0) { ECN::ECPropertyIterable propIter = cls.GetProperties(); UInt32 propIndex = 0; for each (ECN::ECPropertyP propP in propIter) { lifalib_dmsg("Label = %ls, TypeName = %ls", propP->GetDisplayLabel(), propP->GetTypeName().GetWCharCP()); WString wsVal; if (instP->GetValueAsString(wsVal, propIndex, false, 0) == 0) lifalib_dmsg("Val = %ls", wsVal.GetWCharCP()); propIndex++; } } }
What puzzles me is that the values doesn't match the labels / typenames. Can anyone tell me why ?
Answer Verified By: EvanH