I am trying to create a tag that contains objects of a certain type. The "API and XML Online Reference Guide for Mechanical" shows there's a class called ObjectTag but I can't find how to create one. I have used Ansys.Mechanical.Application.ObjectTag. This does create the tag object and I can add objects to it but it doesn't appear in the Tree. Checking with print(ExtAPI.DataModel.ObjectTags.TagNames) returns an empty list. What is he correct way to create a Tag that does become visible in the Tree?
def tag_comments(tagname):
"""
Adds a Tag which contains all Comments in the model
tagname: name to be given to the created tag
"""
OT=Ansys.Mechanical.Application.ObjectTag(tagname)
all_comments = ExtAPI.DataModel.GetObjectsByType(Ansys.ACT.Automation.Mechanical.Comment)
for comment in all_comments:
OT.AddObject(comment)
Create a tag for the comments
tag_comments('Comments_tag')
Check created object (WORKS WELL)
print(OT.Name)
for item in OT.Objects:
print(item.Name)
print(" ")
Check if tag visible in Tree (NOT working. Returns empty list)
print('Available tags:')
print(ExtAPI.DataModel.ObjectTags.TagNames)