Get Reference of element to be used to place tag

Get Reference of element to be used to place tag

ahmed.elhawary73
Advocate Advocate
247 Views
1 Reply
Message 1 of 2

Get Reference of element to be used to place tag

ahmed.elhawary73
Advocate
Advocate

Hello Dears,

 

We can use the below static method to place a new tag on particular element, the question is how to get Reference for the Element that I want without asking the user to pick an object!

 

 

IndependentTag.Create(Document, ElementId, ElementId, Reference, Boolean, TagOrientation, XYZ)   
referenceToTag
Type: Autodesk.Revit.DB Reference
The host reference of the tag. The reference can be to an element or subelement in a local or linked document.

0 Likes
Accepted solutions (1)
248 Views
1 Reply
Reply (1)
Message 2 of 2

naveen.kumar.t
Autodesk Support
Autodesk Support
Accepted solution

Hi @ahmed.elhawary73 ,

 

The simplest approach is to use a FilteredElementCollector to filter and retrieve the required element, and then create a reference to it.

Element elem;
Reference referenceToTag = new Reference(elem);

Additionally, please refer to the link below for further details:

https://www.revitapidocs.com/2018/1f622654-786a-b8fd-1f81-278698bacd5b.htm


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network