How can I programmatically find which field from ECClass correspond to some real EC data on object. In .Net I can use Elemennt.GetDependants() to find connected textnodes, but I don’t know how extract information that this text or some part of text is field from some EC property and and which key belongs to this field?
In old fashion way in tags is simple extract to which element is tag connected and which tag-definition from which tagset represents.
Something similar I expect with fields is it possible?
Miro
I am a little confused for your question. Do you want to get ECProperty name from an ECValue or want to get graphic element from an ECInstance ?
Hi Yongan,
as far as I understand Miro's question, this is about this situation:
Miro's question is whether is possible, when I have TextElement instance, to obtain not only a value of the filed, but also what EC data (schema / class / property) is linked with this field.
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Miro should probably specify what version (v8i? CONNECT?) and what language (C++? C#? Doesn't matter?)
Paul Connelly said:Miro should probably specify what version (v8i? CONNECT?) and what language (C++? C#? Doesn't matter?)
You are right, this mandatory information is missing.
Based on another discussions I had with Miro in the past, I can confirm it's CONNECT and C#.
Regards,
Unfortunately you can do very little with EC Fields using the C# API.
Hi Paul,
Paul Connelly said:you can do very little with EC Fields using the C# API.
Thanks for your answer. Can be your answer interepreted in such way there is a solution when C++ is used? ... which opens a possibility e.g. to implement own wrapper using C++/CLI to access such functionality from NET.
If Miro can more clearly explain what they're trying to accomplish, sure.
Otherwise, look for 'TextField' in the APIs defined in TextBlock.h, and peruse the APIs defined in TextField.h.
Yes as Jan said, I want extract information from text node which can contain more text blocks and maybe some text block is EC Field and I want know from which EC schema/class/property is this field filed. If it is not directly accessible via C# is it possible to write some wrapper for .Net solution?
Miro Cecho said:is it possible to write some wrapper for .Net solution?
For sure it is ;-)
NET offers PInvoke (Platform Invoke) as a standard way how to call native code from managed. Often C++/CLI is used instead of PInvoke, because C++/CLI allows more precise implementation (especially memory and resources management) and sometimes it's more straightforward comparing to "cryptical" marshalling definition. There are also solutions that help to automate the wrapper implementation (e.g. this one).
In MicroStation SDK, there are several "mixed examples" that show how C++/CLI can be used. It does not demonstrate how to create a wrapper, but this is topics where many discussions (using both PInvoke and C++/CLI) can be found on Internet.
From a TextBlock you can obtain a Caret, which is an iterator over the contents of the text block.
From a Caret, you can obtain a TextField.
Unfortunately, the published SDK is rather stingy regarding what it will allow you to do with a TextField once you've obtained one. This is in part due to backwards-compatibility with EC fields create in v8i - of particular relevance to your question, such fields do not store an ECSchema name.
So it sounds like you will need some enhancements to the published SDK:
1. Make TextField::FindTarget() available. This returns an ECInstance from which you can obtain ECSchema+ECClass.
2. Make TextField::GetAccessor() available. This returns the property access string.
If you have further requests in this area please specify them.
Paul Connelly said:API enhancements...
Good suggestions!
Regards, Jon Summers LA Solutions
Paul Connelly said:it sounds like you will need some enhancements to the published SDK: 1. Make TextField::FindTarget() available. This returns an ECInstance from which you can obtain ECSchema+ECClass. 2. Make TextField::GetAccessor() available. This returns the property access string
it sounds like you will need some enhancements to the published SDK:
2. Make TextField::GetAccessor() available. This returns the property access string
Did those suggestions get anywhere?