Hi,
I am just curious to see if anyone has been able to use the NewRoomTag method to tag Rooms from Linked files with any success? I've just tested it with a really simple setup of 1 linked project and I can consistently create an invisible Tag. The invisible Tag can be selected by its Id, but has the unpleasent characteristic of not being visible.
https://www.revitapidocs.com/2015/9847aafe-42f9-fe8e-5229-c491add7ec46.htm
Here is the Macro I've used to test this example:
public void TagRoom() { UIDocument uidoc = this.ActiveUIDocument; Document doc = this.ActiveUIDocument.Document; UIApplication uiapp = this; var documents = uiapp.Application.Documents; IList<Element> elems = new FilteredElementCollector(doc) .OfCategory(BuiltInCategory.OST_RvtLinks) .OfClass(typeof(RevitLinkType)) .ToElements(); Document link = null; foreach(Document d in documents) { if((elems.First().Name.Contains(d.Title))) { link = d; } } var room = new FilteredElementCollector(link) .OfCategory(BuiltInCategory.OST_Rooms) .Cast<Room>() .First(); var point = uidoc.Selection.PickPoint(); var v = doc.ActiveView; using(Transaction t = new Transaction(doc,"TestRoomTag")) { t.Start(); var tag = CreateRoomTag(doc, room, v, point); TaskDialog.Show("Testag", tag.Id.ToString()); t.Commit(); } } RoomTag CreateRoomTag(Autodesk.Revit.DB.Document document, Room room, View view, XYZ point) { // Create a UV structure which determine the room tag location UV roomTagLocation = new UV(point.X, point.Y); // Create a new room tag in the created room LinkElementId roomId = new LinkElementId(room.Id); RoomTag roomTag = document.Create.NewRoomTag(roomId, roomTagLocation, view.Id); if (null == roomTag) { throw new Exception("Create a new room tag failed."); } // Give the user some information TaskDialog.Show("Revit","Room tag created successfully."); return roomTag; }
Solved! Go to Solution.
Solved by FAIR59. Go to Solution.
Hi @dnenovMXKU9 ,
I hope the below link will help you to solve your problem.
https://blogs.rand.com/support/2013/01/revit-cannot-see-the-linked-models-room-tags.html
Hi Naveen,
Thank you for the idea, but no, it doesn't solve our problem. We want to be able to tag Rooms from Linked files programatically, as intended in the method provided by the Revit API.
The blog post you pointed to speaks about showing Room Tags residing in the Linked file using 'By Linked View' approach, which is not what we want at all.
There is a lot of discourse about tagging things from Linked files and that's impossible at this stage, but I thought Room Tags were a special case. I wonder if anyone was able to crack this particular nut.
Dear Deyan,
Thank you for your query, and thanks to Naveen for trying to help.
The Building Coder recently discussed the very topic you address:
https://thebuildingcoder.typepad.com/blog/2019/05/tagging-a-linked-element.html
I hope this helps.
Best regards,
Jeremy
Dear Deyan,
Thank you for your update to the associated ADN case 15526990 [NewRoomTag Method not working].
You ask, 'Why are you closing the issue? It has not been resolved, what do you mean?'
Indeed, the question has not yet been completely resolved, although I very much hope and expect that the blog post I pointed out above will help significantly.
I am only closing the internal ADN case.
I am doing so, since we are discussing the issue here in the public forum.
I very much prefer discussing all non-confidential issues in public.
That has several advantages: the entire team sees the issue, peers can join in and help, and the conversation becomes visible to others, to help them resolve their issues as well.
In fact, many of the independent developers participating in this forum are much more knowledgeable in this topic than I and my colleagues at Autodesk, and can help you solve tricky Revit API issues more efficiently, since they really use it in depth in their everyday work.
Thank you for your understanding.
Best regards,
Jeremy
there are 2 versions of the new LinkElementId() constructor. The one you use, tags the room in the linked document that is "opened in memory"( and therefore not visible in views.)
Using the other requires a room and a RevitLinkInstance.
RevitLinkInstance linkedInstance; Room room; LinkElementId roomId = new LinkElementId(linkedInstance.Id, room.Id);
Worked like a charm, Sir! I did not even check for overloads in the constructor, I got tricked by the special significance of LinkedElementId... thank you once again!
Can't find what you're looking for? Ask the community or share your knowledge.