Rooms/Room tags not updating in views after floors are painted programmatically

Rooms/Room tags not updating in views after floors are painted programmatically

asattar.md
Contributor Contributor
1,797 Views
9 Replies
Message 1 of 10

Rooms/Room tags not updating in views after floors are painted programmatically

asattar.md
Contributor
Contributor

We have written a plugin that automatically applies a different material to floors.

 

We call

doc.Paint(element.Id, face, materialId)

for all the faces of the element. This code is updating the materials (as we can see from the material browser).

 

The problem the tag that describes this material is not getting updated in the sheets. The tag is a keynote tag.

What we have found is moving the tag slightly (manually) updates the tag. It shows the right value.

 

tag.jpg

Actual value should be Botticino (defined as keynote for the material). It shows Kota Blue even after calling the doc.Paint method. However, if we move the tag slightly, it updates to Botticino (as shown in the screenshot).

Are we missing some method that needs to be called for the views to refresh?

0 Likes
Accepted solutions (1)
1,798 Views
9 Replies
Replies (9)
Message 2 of 10

thannaingoo.api
Advocate
Advocate

Hi,

 

You can use the regenerate method revit document to reflect all the changes.

 

doc.Regenerate();
0 Likes
Message 3 of 10

asattar.md
Contributor
Contributor

Tried that. Has no effect. Similarly uidoc.RefreshActiveView also has no effect.

0 Likes
Message 4 of 10

Revitalizer
Advisor
Advisor

Hi,

 

you wrote "move the tag slightly".

 

What about moving the tag by a XYZ.Zero vector?

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes
Message 5 of 10

thannaingoo.api
Advocate
Advocate
0 Likes
Message 6 of 10

asattar.md
Contributor
Contributor

Hi, I just did that. It didn't work. Nothing changed.

0 Likes
Message 7 of 10

asattar.md
Contributor
Contributor

Thanks for the link. I had gone through it and tried doc.Regenerate() and uidoc.RefreshActiveView()

0 Likes
Message 8 of 10

asattar.md
Contributor
Contributor

The funny thing is it's very inconsistent.

When I use RevitPythonShell, get the element and try to do

e.TagHeadPosition = e.TagHeadPosition.Add(XYZ.Zero)

and then commit the transaction, it works sometimes, sometimes it doesn't.

But when I run it as part of a larger plugin, it doesn't work at all.

0 Likes
Message 9 of 10

asattar.md
Contributor
Contributor
Accepted solution

We have fixed it!

The trick was to first make the view of the tag active and then copy paste it in the same place. We deleted the older tag. I believe, if we just move it slightly also it will work as long as the view is active.

Message 10 of 10

PerryLackowski
Advocate
Advocate

I had a similar issue adding tags to some detail items. I could add the tags in the correct positions, but if I manually moved them later, they would move back to their original basepoint and offset from there. Regenerating didn't help, but I found that placing the tags and then wiggling them did the trick. Here's my python code for future reference. I'm using Revit 2021.1.

t = DB.Transaction(doc, 'Add Tags')
t.Start()

for elem in elements:

    # Get desired tag location as an offset from the element you are tagging
    tag_loc = elem.Location.Point.Add(DB.XYZ(0,-2.25,0))

    # Create tag
    new_tag = DB.IndependentTag.Create(
        doc,
        view_id,
        DB.Reference(elem),
        False,
        DB.TagMode.TM_ADDBY_CATEGORY,
        DB.TagOrientation.Horizontal,
        tag_loc
    )

    # Optionally, set tag type
    #new_tag.ChangeTypeId(DB.ElementId(desired_type_id))

    # Wiggle tag
    DB.ElementTransformUtils.MoveElement(doc, new_tag.Id, DB.XYZ(2,0,0))
    DB.ElementTransformUtils.MoveElement(doc, new_tag.Id, DB.XYZ(-2,0,0))

t.Commit()

 

0 Likes