vba drop tags to text

I've been advised to post the below question in a specific vba forum rather than in the general microstation forum. Since the question applies to both v8i and XM release, I hope for understanding that I will post it in both forums.

 

Dear community,

I am currently writing a vba script, and at a certain point of a longer procedure I want to copy a tag and drop the copied element to a text element.

The copying works fine, it returns another Ustn Element Type 37 / tag (which looses its linkage as shown with the 'broken' symbology) , that's how it should be.

Now surprisingly the Element.IsDroppableElement returns false.

I would prefer a solution other than using CadInputQueue in conjunction with the command 'change tags droptext', as using this option slows down the execution of the routine notably.

Thank you in advance for any helpful hints.

Andreas

  • TagElements are not TextElements

    The simple answer is that TagElements are not some complex form of TextElements and cannot be 'dropped' to text, irrespective of what MicroStation's user interface may lead you believe. To put it another way, there is no TagElement.Drop method.

    However, a reasonable answer is not far away. A TagElement can store various types of data (in VBA terms, a TagElement may be a String, Integer, or Double). The TagElement.Value property gets the internal value of the tag as a VB Variant type.

    To 'drop' a TagElement to a TextElement, do something like this …

    1. Convert TagElement.Value to a String
    2. Create a new TextElement, assigning the Variant from the tag (CStr (vtValue))
    3. Add the new TextElement to the active model
    4. If required, delete the TagElement

    Regards, Jon Summers
    LA Solutions

     
    Regards, Jon Summers
    LA Solutions

  • Hello,

    is there any reason why you cannot use the command:

    change tags droptext

    Best regards,

    Henk

  • Jon and Henk,

    thank you for your input. As mentioned in my original post, the "CHANGE TEXT DROPTEXT"-approach is feasible and working, but causes a notable 'hang' in the execution at runtime (I don't know the reason, however I kind of regard using CadInputQueue only a second best workaround)

    As always, Jons simple answer is both enlightening and disarming, where would we be without you?

    My thoughts went into the same direction, however I hoped to omit the necessity to create a new element due to then not needing to define both text and element attributes. I had expected, that if a command exists, then there should be a programmatical equivalent.

    I will go that way, and well, thank you again.

    Andreas

  • Tag Text Properties

    A TagElement has properties that affect its appearance as text. They were inherited from the active text settings when the TagElement was created. You can use the following properties when creating your TextElement …

    • Font
    • Height
    • InterCharacterSpacing
    • IsFixedSpacing
    • Justification
    • Slant
    • SlantValue
    • Width

    I hoped to omit the necessity to create a new element

    At some point in this process a new element has to be created. You start with a TagElement and end up with a TextElement.

    Regards, Jon Summers
    LA Solutions

     
    Regards, Jon Summers
    LA Solutions