[CONNECT C++] Loop TextFields in existing text element and then get field properties and set field Properties?

Could anyone offer any help with how to do this? I see a TextFieldDictionary in the API. but not really sure how to implement this.

what im trying to do is for a given text element get all the text fields that are linked to a property of a item type. as well as change what property that field is linked to.

I used the code from Yongan.Fu in post https://communities.bentley.com/communities/other_communities/chinafirst/f/microstation-projectwise/180135/msce-c-textblock to create a text field but that's pretty much the only example of textfields I could find.

JD

Parents
  • The way the the API treats text in memory in the CONNECT MicroStationAPI is abstract.  It has nothing to do with DGN elements (Text and Text Nodes) and discards completely the V8 way of handling text elements directly with the mdlText_api.

    The TextBlock is the foundation of CONNECT MicroStationAPI  text handling.  It is well-documented in MicroStationAPI  help.  There are examples but, perversely, they are in the deprecated mdlText_api documentation...

    mdlText_api deprecated

     
    Regards, Jon Summers
    LA Solutions

  • okay so im still a little lost...

    so I get my textBlock from my element like this...

    ElementHandle eh(elemId, pActiveModel);
    TextBlockPtr textBlock = TextHandlerBase::GetFirstTextPartValue(eh);

    then I see this getfield method that takes a caretCR….

    TextFieldPtr firstfield = textBlock->CreateStartCaret->GetField();

    so I know that isn't right..but confused as to how I would iterate the textblock to get all the textfields...

    any guidance? not really sure what start caret is meaning.

  • any guidance?

    From the questions posted here in the last year or two I think there are several of us who would welcome more hints about C++ text processing from Bentley Systems.

    not really sure what start caret is meaning

    Interpret it as a pointer into some component of a TextBlock.  In C++ terms, an iterator.  It's volatile and may become invalid as you manipulate a TextBlock.

    Behind the scenes, I believe that a TextBlock is an API that manages an XML document.  The TextBlock API is manipulating the XML elements of that document.  The XML may be simple — just one word — or complex, containing multiple paragraphs, styles and text fields.  When you write the TextBlock to a DGN model it converts to the appropriate text element or text node element.

     
    Regards, Jon Summers
    LA Solutions

Reply
  • any guidance?

    From the questions posted here in the last year or two I think there are several of us who would welcome more hints about C++ text processing from Bentley Systems.

    not really sure what start caret is meaning

    Interpret it as a pointer into some component of a TextBlock.  In C++ terms, an iterator.  It's volatile and may become invalid as you manipulate a TextBlock.

    Behind the scenes, I believe that a TextBlock is an API that manages an XML document.  The TextBlock API is manipulating the XML elements of that document.  The XML may be simple — just one word — or complex, containing multiple paragraphs, styles and text fields.  When you write the TextBlock to a DGN model it converts to the appropriate text element or text node element.

     
    Regards, Jon Summers
    LA Solutions

Children