Exemplo n.º 1
0
        public static bool setTagOnElement <T>(BCOM.Element element,
                                               string tagSetName, string tagName, T value, BCOM.MsdTagType type = BCOM.MsdTagType.Character)
        {
            BCOM.TagElement tag     = null;
            BCOM.DesignFile dgnFile = element.ModelReference.DesignFile;

            BCOM.TagSet tagSet = getTagSetOrCreate(dgnFile, tagSetName);

            try { tag = element.GetTag(tagSet, tagName); }
            catch (Exception) {}

            if (tag == null)
            {
                BCOM.TagDefinition tagDef = getTagDefOrCreate(tagSet, tagName, type);
                // TODO tagDef.IsHidden  = ...
                tag = element.AddTag(tagDef);
            }

            if (tag != null)
            {
                tag.Value = value;
                tag.Rewrite();
                return(true);
            }

            return(false);
        }
Exemplo n.º 2
0
 public static BCOM.TagDefinition getTagDefOrCreate(
     BCOM.TagSet tagSet, string tagName, BCOM.MsdTagType tagType)
 {
     try
     {
         return(tagSet.TagDefinitions[tagName]);
     }
     catch (Exception)
     {
         return(tagSet.TagDefinitions.Add(tagName, tagType));
     }
 }