How to move Room Tags

Hello Everyone,

I’m trying to move room tags to the center of the room using dynamo.
I Managed to get the center of the room using bounding box.
However, I don’t know how to get the created room tags and move it to the new location
Any tips how to think for the second part?

Note: I know there are packages doing the same job with only two nodes, however it’s a course task to try solve it without the packages.

Get All Room Tags for the active view.
Check to see if the tag is tagging a link (roomTag.IsTagginLink)
Get the Location Point of the Room Tag
Get the Room of the Tag (doc.GetElement(roomTag.TaggedLocalRoomId)
Get the Location Point of the Room (p1)
Move the Room Tag to the Room (p2) (ElementTransforUtils.MoveElement(doc,roomTag.Id,p1-p2))

This is a little older, but may also help you move in the right direction.
Rooms - Center All Room Tags on Room Reference.dyn (2.7 KB)

it worked
many thanks for your guidance

Hi,
Thanks for the scrip but I’m getting a warning while running.

“Warning: RoomTag.CenterOnRoomLocation operation failed.
Object reference not set to an instance of an object.”

Please let me know how to resolve the issue.

Could you post a picture with all the elements previews expanded?

Actually, want to move all the Room tag (61k) to the center/within the room to resolve the 300 warning in the model.
Working model is a drainage model and architectural model is linked.