Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Tag Walls through API

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
dgoff96
156 Views, 2 Replies

Tag Walls through API

I have been trying this over and over again, and can’t seem to get it to work. I am working on a tool that should add wall tags to certain walls, however, I’m having trouble with the IndependentTag.Create() method. Below is my code (in python). I recycled this code from another tool that tags different element types and works just fine, so I’m pretty sure the syntax is correct:

 

families = DB.FilteredElementCollector(doc).OfCategory(DB.BuiltInCategory.OST_WallTags).OfClass(DB.FamilySymbol).ToElements()
    for fam in families:
        if fam.Family.Name == "MyTagName":
            tag = fam
            break
tag = DB.IndependentTag.Create(doc, tag.Id, view.Id, DB.Reference(wall), True, DB.TagOrientation.Horizontal, mid_point)

 

I keep getting this error: 

Exception: The ElementId symId does not correspond to a FamilySymbol. I have checked that the "tag" element that is returned from my for loop is in fact a Family Symbol, so I'm not sure what I am doing wrong here. Any help would be greatly appreciated!
2 REPLIES 2
Message 2 of 3
dgoff96
in reply to: dgoff96

I wound up solving this myself. Somehow, the tag.Id was getting changed somewhere along the way (not sure how as I couldn't find anywhere in my loop where it would have been changed). Anyway, I just made sure to get the Id explicitly when I search for the correct Family Symbol. Then it worked just fine.

Message 3 of 3
ctm_mka
in reply to: dgoff96

my guess would be the break in your for loop was causing tag to be nullified, not sure if you can do this in python, but c# i would use continue vs break for that reason.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


Rail Community