70002019 Importing Dgn TagElement objects

Article 70002019
Type Wish
Product DGN
Version 9001
Date Added 7/15/2021 12:00:00 AM
Fixed 9.9002.0.6 (7/27/2021 12:00:00 AM)
Submitted by Eric Guilhaurre

Summary

Importing Dgn TagElement objects

Solution

In version 9002.0.6 Dgn TagElement objects are imported described below

If TagElement is referenced to an existing vdFigure object then it is added to Xproperties using its tag Name as Xproperty Name and set its value to Xproperty value
Additionally if the reference object is a vdInsert the TagElement is added as vdAttribute in the vdInsert Attributes list
If the height of the TagElement is 0 then the Attribute is mark as Invisible


If TagElement does not have a reference object then it is added as vdMtext or vdText to the model entities with textString equal to TagElement value and Xproperty with Name and value equal to TagElement properties
Also in this case if the height of the TagElement is 0 then the vdText or vdMtext are marked as Invisible
All tag Elements have an extra xProperty DGN_TAGELEMENT.


Finally If you want to scan all TagElements in the drawing after openning a Dgn file filter out all vdFigures that contains Xproperty with name "DGN_TAGELEMENT" as follow:

              //filter all entities that have Dgn TagElement assigment
                vdPrimariesList prims = doc.GetPrimaries(true);
                foreach (vdPrimary prim in prims)
                {
                    if (prim.XPropertiesRef == null) continue;
                    if (prim.XProperties.FindName("DGN_TAGELEMENT") == null) continue;
                    System.Diagnostics.Debug.WriteLine(string.Format("{0} : {1}", prim._TypeName, prim.Handle.ToString()));
                    //print TagElement properties
                    foreach (vdXProperty item in prim.XProperties)
                    {
                        if (string.Compare(item.Name, "DGN_TAGELEMENT") == 0) continue;//do not print flag xproperty
                        System.Diagnostics.Debug.WriteLine(string.Format("\t\t{0} = {1}", item.Name, item.PropValue.ToString()));

                    }
                    if (prim is vdMText)
                    {
                        vdMText txt = prim as vdMText;
                        txt.visibility = vdFigure.VisibilityEnum.Visible;
                        txt.Height = 1.0;
                        txt.Update();
                    }
                    if (prim is vdText)
                    {
                        vdText txt = prim as vdText;
                        txt.visibility = vdFigure.VisibilityEnum.Visible;
                        txt.Height = 1.0;
                        txt.Update();
                    }
                }
                doc.Redraw(true);

Send comments on this topic.