Announcements
Due to scheduled maintenance, the Autodesk Community will be inaccessible from 10:00PM PDT on Oct 16th for approximately 1 hour. We appreciate your patience during this time.
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: 

NewRoomTag Method not working

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
dnenovMXKU9
872 Views, 6 Replies

NewRoomTag Method not working

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;
		}
6 REPLIES 6
Message 2 of 7

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

 


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

Message 3 of 7

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.

Message 4 of 7
jeremytammik
in reply to: dnenovMXKU9

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

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 5 of 7
jeremytammik
in reply to: dnenovMXKU9

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

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 6 of 7
FAIR59
in reply to: dnenovMXKU9

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);
Message 7 of 7
dnenovMXKU9
in reply to: FAIR59

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!

 

linkedroomtag.PNG

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

Post to forums  

Rail Community


Autodesk Design & Make Report