Hello all,
I’m currently working on a project in Revit with Dynamo, and I’m facing an issue with displaying tags for Rebar Sets using Create Tag node. The Rebar Set tag is not showing the current index of the rebar in the set (hide), but when I attempt to show first bar, the tag for the rebar set appears.
I want a tag for the particular index of the rebar in the corresponding rebar set by using dynamo. I tried a lot but can’t get expected result. If anyone have any idea or solution it would be appreciated.
Thank you in advance.
Now, I am trying to get the specific rebar index of rebar set which is visible in view using python.
Once I select the particular rebar of rebar set using index which i get from above method, then it needs to connect with create tag node. I have shared my python code below and it is showing error. Any idea? Thanks!
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
#The inputs to this node will be stored as a list in the IN variables.
rebar_sets = UnwrapElement(IN[0])
index = []
TransactionManager.Instance.EnsureInTransaction(doc)
for e in rebar_sets:
bar_index = e.GetBarIndexFromReference(rebar_sets)
index.append(bar_index)
TransactionManager.Instance.TransactionTaskDone()
#Assign your output to the OUT variable.
OUT = index
I’m still unable to find the answer. For each rebar set, I may make a tag for the first rebar. However, for some presentational reasons, I must display the other rebar. Therefore, when I switch the presentation mode, the tag is not displayed.
I changed the tag’s host in Revit from the first rebar to the third rebar, and the tag appears perfectly after creation.
Is there any chance of doing it successfully in Dynamo? Please see the snapshot below to fully understand what’s going on. I’ve been trying to solve this for a week, but I still can’t. I need help!
Hi everyone,
I discovered that this feature is no longer supported by Revit 2023. Check out the Autodesk article https://www.autodesk.com/support/technical/article/caas/sfdcarticles/sfdcarticles/Node-Tag-ByElement-in-Dynamo-is-not-working-for-Rebars-in-Revit-2023.html
They have given the C# code to tag subelements of rebar.
Rebar rebar; // this is your rebar IList<Subelement> subelements = rebar.GetSubelements(); // here are the subelements foreach(var subelement in subelements) { IndependentTag tag = IndependentTag.Create(m_rvtDoc, m_view.Id, subelement.GetReference() /*the new reference is to the subelement/{*}, true, Autodesk.Revit.DB.TagMode.TM_ADDBY_CATEGORY, Autodesk.Revit.DB.TagOrientation.Horizontal, tagPosition); }
I don’t know anything about C#. Does anyone know how to use this in Dynamo to tag the rebar set’s subelement?
@JOTHISH30
pretty much looks like this:
doc = DocumentManager.Instance.CurrentDBDocument
uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
# your rebar
rebar = UnwrapElement(IN[0])
#Do some action in a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)
for sub_elem in rebar.GetSubelements():
tag_pos = sub_elem.Location.Point # well, I suppose it's here
tag = IndependentTag.Create(doc, doc.ActiveView.Id, sub_elem.GetReference(), True, Autodesk.Revit.DB.TagMode.TM_ADDBY_CATEGORY, Autodesk.Revit.DB.TagOrientation.Horizontal, tag_pos)
TransactionManager.Instance.TransactionTaskDone()
Hello @BimAmbit
I appreciate your response. I modified your code and tried it. IN[0] = Rebar Set and IN[1] = Tag Head Location, however I receive an error. Please see the attached snapshot, and my complete code is below.
import clr
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
# Import Element wrapper extension methods
clr.AddReference("RevitNodes")
import Revit
# Import geometry conversion extension methods
clr.ImportExtensions(Revit.GeometryConversion)
import sys
sys.path.append(r"C:\Program Files (x86)\IronPython 2.7\Lib")
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
version=int(app.VersionNumber)
doc = DocumentManager.Instance.CurrentDBDocument
uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
# your rebar
rebar = UnwrapElement(IN[0])
tag_pos = UnwrapElement(IN[1])
#Do some action in a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)
for sub_elem in rebar.GetSubelements():
tag = IndependentTag.Create(doc, doc.ActiveView.Id, sub_elem.GetReference(), True, Autodesk.Revit.DB.TagMode.TM_ADDBY_CATEGORY, Autodesk.Revit.DB.TagOrientation.Horizontal, tag_pos)
TransactionManager.Instance.TransactionTaskDone()
@JOTHISH30 try strip input 1 to a single position, not a list unless you do want a list of positions. In that case, loop through sub elements and tag positions simultaneously.
for sub_elem, tag_pos in zip(rebar.GetSubelements(), tag_positions):
tag = IndependentTag.Create(doc, doc.ActiveView.Id, sub_elem.GetReference(), True, Autodesk.Revit.DB.TagMode.TM_ADDBY_CATEGORY, Autodesk.Revit.DB.TagOrientation.Horizontal, tag_pos)
@BimAmbit, I receive the same error even though I’m only using single position (Input [1]).
import clr
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
# Import Element wrapper extension methods
clr.AddReference("RevitNodes")
import Revit
# Import geometry conversion extension methods
clr.ImportExtensions(Revit.GeometryConversion)
import sys
sys.path.append(r"C:\Program Files (x86)\IronPython 2.7\Lib")
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
version=int(app.VersionNumber)
doc = DocumentManager.Instance.CurrentDBDocument
uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
# your rebar
rebar = UnwrapElement(IN[0])
tag_pos = UnwrapElement(IN[1])
TagMode = UnwrapElement(IN[2])
#Do some action in a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)
for sub_elem in rebar.GetSubelements():
tag = IndependentTag.Create(doc, doc.ActiveView.Id, sub_elem.GetReference(), True, TagMode, Autodesk.Revit.DB.TagOrientation.Horizontal, tag_pos)
TransactionManager.Instance.TransactionTaskDone()
Otherwise, I get the problem below if I use your updated code.
Am I incorrectly using your code?
@JOTHISH30 the C# code snippet above is calling a tag creation function that does not specify tag type whereas what you are trying to do here is in fact the other creation function which indeed allow you to specify one. Meanwhile, there are a couple of things worth notice:
- Error message did change, if you look closer, the node is not complaining about the list input anymore.
- TagMode is TagMode, not Tag Type.
- Points need to be converted to Revit Types when you work with a native API call.
tag_pos.ToXYZ()
will do.
The one that specifies tag type.
IndependentTag Class
The one that does not.
IndependentTag Class
You are very close to get it done. Try the best you can but if it still doesn’t click, I’ll post an entire reference script here. (hopefully, send me demo model )
@BimAmbit I truly appreciate your help. After such a long time, I finally found the solution I was looking for. Your inputs have been incredibly valuable. Below are the finalized python code.
# your rebar
rebar = UnwrapElement(IN[0])
tag_pos = UnwrapElement(IN[1])
tagType = UnwrapElement(IN[2])
def toRvtPoint(point):
return point.ToXyz()
def toRvtId(_id):
if isinstance(_id, int) or isinstance(_id, str):
id = ElementId(int(_id))
return id
elif isinstance(_id, ElementId):
return _id
tagTypeId = toRvtId(tagType.Id)
location = toRvtPoint(tag_pos)
#Do some action in a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)
for sub_elem in rebar.GetSubelements():
tag = IndependentTag.Create(doc, tagTypeId, doc.ActiveView.Id, sub_elem.GetReference(), True,
Autodesk.Revit.DB.TagOrientation.Horizontal, location)
TransactionManager.Instance.TransactionTaskDone()
OUT = tag
1 Like