Structural Rebar Tags need to align Align

Hi all, Cheers!
I am trying to Align the Structural Rebar Tags to reduce the time by using dynamo script. But in mid i got stuck. I tried to Use Element.GetLocation node identify the existing Tag location on model to base for another Structural tags. But it shows It shows an error of 'Óperation failed. The location of the structural element is not a valid curve.
If anyone knows the solution please suggest me to continue the script. Thank you!

Hello,

Great to see you in the community! Wish you best of luck for your project. You can check out community guidelines to find answers more quickly by structuring the post better.

Is it possible for you to share a screenshot of your dynamo project so that we can detect the issues more easily? Normally you can get the location of tag elements using Element.GetLocation. Alternatively, you can use Element.Location+ node from Clockwork package. It will give more detailed information about the selected object.

Looking forward to hearing from you!

Hi Emrullah,
Thank you for giving me the solution for above Query. Here after i will share the screen shot of my project regularly. And as per your recommendation i just used the Clockwork node which is Element.Location+ but if i connected with the elements it shows null. Please check with this.

Do you have a version of the IronPython2 package which works for your Dynamo for Revit version installed and working? If not this will happen 100% of the time. If you have it installed open a detached copy of you model and remove everything from the dataset except for what is required to recreate one or two instances to recreate the issue, and post your model here or on another site where the model can be readily downloaded.

Yea Jacob, I have IronPython2 Package. I am currently working on Revit 2023. I have attached the model here and it contains only Structural rebar Tags. Also i have included the dynamo script till what i done.
Structral Tag.rvt (5.4 MB)
Structural Tag Align.dyn (46.9 KB)

GetLocation+ is working for me, which confirms it’s an environment issue.

Edit the Clockwork node by double clicking it. Copy the TurnIntoList and Python node to the clipboard, switch back to the active graph, and paste them into the graph. Wire your selected element into the TurnIntoList node and see if you get a better error message.

This might work for you as long as you only have tags (added some error handling to inform when you selected a non-tag element)

########################################
############## Properties ##############
########################################
__author__ = 'Jacob Small'
__version__ = '0.1.0'
__description__ = """Gets the location of tag heads."""
__RevitBuilds__ = "2023.1"
__DynamoBuilds__ = "2.16"
__ReleaseNotes__ = """-"""
__Dependancies__ = "-"
__Copyright__ = "2024, Autodesk Inc"
__License__ = """MIT"""



########################################
### Configure the Python environment ###
########################################
### standard imports ###
import sys #add the sys class to the Python environment so we can work with the sys objects
import clr #add the CLR (common language runtime) class to the Python environment so we can work with .net libraries

### Dynamo Revit imports ###
clr.AddReference("RevitNodes") #add Dynamo's Revit nodes library to the clr
import Revit #import Dynamo's Revit node class
clr.ImportExtensions(Revit.Elements) #add the element conversion methods to the CLR
clr.ImportExtensions(Revit.GeometryConversion) #add the geometry conversion methods to the CLR

### Revit API imports ###
clr.AddReference("RevitAPI") #add the Revit API to the CLR
import Autodesk #add the Autodesk class to the Python environment 
from Autodesk.Revit.DB import * #import every class of the Revit API to the Python environment



results = [] #list to hold the results
elems = UnwrapElement(IN[0]) #import the elements from IN[0] of the Dynamo environment and convert to native Revit elements
if not elems.__class__ == [].__class__ : elems = [elems] #ensure that elems is a list, not an individual object, so that we can always prepare for a loop
for elem in elems: #iterate over the list of elements
    if not hasattr(elem,"TagHeadPosition"): results.append("element is not a valid tag type") #inform the user if the element isn't a valid tag
    else: results.append(elem.TagHeadPosition.ToPoint()) #otherwise get the location point
OUT = results #return the results to the Dynamo list

Please ensure you are using the correct types of elements in your dynamo script. Structural Reber tags are generally use with the Structural elements. Make sure the elements you are retrieving location from the structure have the valid location.

I just had a client have a problem with the Element.Location+ node and I believe the issue stemmed from no IronPython2 package as @jacob.small stated.

Rather than trying to resolve the install trouble on their end, I ended up writing some python to replicate the Element.Location+ output.

Have you tried writing some code to replicate Element.Location+ to retrieve the points data that you need?

@johntk22 Yes i am using a proper elements type and confirms it has valid location in revit.

@austin.guter Even after installing the IronPython2 package, the issue persists. I’m new to Dynamo and lack the expertise necessary to write code.

Jacob, I followed your advice in the thread above. but the null value persists. I may have done something incorrectly. Please find a picture of what I did below. I’m new to Dynamo.

Preview the results of ‘turn into list’, if null open it up and do the same as the get location+ node.

This is almost certainly an incorrect Python 2.7 package installation at this point.

Alternatively you can try using the Python script I posted above to get the location of tags.

Edit completely missed Jacob’s code, his is better.
Here is some python code to do the job:

# Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

# The inputs to this node will be stored as a list in the IN variables.
rebarTags = UnwrapElement(IN[0])
locations = []
for rebarTag in rebarTags:
    location = rebarTag.TagHeadPosition
    locations.append(location)
    

# Place your code below this line

# Assign your output to the OUT variable.
OUT = locations

This pulls out the TagHeadPosition of structural rebar tags and area reinforcement tags.
Should hopefully be close to what element.location+ does.

Thank you! I tried with your script,
It is working for Multiple Tags only, If i pick single tag it shows error. Also it doesn’t give X,Y & Z value as Jacob’s Script.

I used your script it is working for only single tag. If i select multiple Tags it shows Error.

Post a Revit file with those 3 tags and their hosts please.

Please find attached the Model file.
Structral Tag.rvt (5.6 MB)

Code is working fine for me:


Note that I’m using CPython3 instead of the unsecure and unsupported IronPython2 engine. You’ll have to edit my stuff if you want to keep using the old engine (I don’t recommend it).

Yes, thank you very much @jacob.small. Now it is working properly and i am using Cpython.

1 Like

Ensure the tags that you are align have valid parameters or properties that can be accessed. Some tags have custom parameters or properties that need to retrieve in accurate location.