🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

How to set a tag name for a surface using Python?

User: "exMSC"
Altair Community Member

Using Python and Hypermesh 2024, what would be a Python code to set the tag attribute name for a surface? I'd like to run through a list of selected surfaces in Hypermesh and have the Python code assign a sequential name (tag) to each name such as, "stiffener01", "stiffener02", etc.

Thanks.

 

Find more posts tagged with

Sort by:
1 - 1 of 11

    in HM 25.0 we have the pythonrecorder

    import hm
    import hm.entities as ent

    def run():
    from hm.mdi import apis
    model = apis.HmModelDebug()

    # [TCL]: *tagcreate surfaces 37 "tag_label1" "body_label1" 4
    entityptr = ent.Surface(model, 37)
    # [TIP]: tagcreate is deprecated.
    model.tagcreate(entityptr=entityptr, label="tag_label1", body="body_label1", color=4)

    # [TCL]: *createmark tags 2 1
    # [TCL]: *setvalue tags mark=2 description=description
    tags_collection = hm.Collection(model, hm.FilterByEnumeration(ent.Tag, ids=[1]))
    tags_collection.set_items('description', "description")

    # [TCL]: *tagcreate surfaces 49 "tag_label2" "body_label2" 4
    entityptr_1 = ent.Surface(model, 49)
    # [TIP]: tagcreate is deprecated.
    model.tagcreate(entityptr=entityptr_1, label="tag_label2", body="body_label2", color=4)

    # [TCL]: *createmark tags 2 2
    # [TCL]: *setvalue tags mark=2 description=description2
    tags_collection_1 = hm.Collection(model, hm.FilterByEnumeration(ent.Tag, ids=[2]))
    tags_collection_1.set_items('description', "description2")