Looking to get the GUID of Revit Elements, as well as call for Revit elements with GUID

I’m looking to test out a .DYN that will receive a list of GUIDs and then select those Revit model elements.

I currently have a test project set up with three pieces of MEP Fabrication Pipework geometry. I am looking to retrieve the GUID from these three pieces of geometry to use for testing.

I continue to receive an “Unhandled Exception Error” Message, I am not sure as to why

Here is my DYN so far

Is this what you are trying to do?

import sys
import clr
from Autodesk.DesignScript.Geometry import *

import Revit

from RevitServices.Persistence import DocumentManager

doc = DocumentManager.Instance.CurrentDBDocument

elems = IN[0]
myGuids = []
for elem in elems:

OUT = myGuids
#OUT = [doc.GetElement(i).ToDSType(True) for i in guid]

I think that’s it! Thank you so much,

I’ve realized that the above script does not do what I am looking for. I am looking to extract the GUID from a Revit Element. The same GUID Value that will match up with the GUID value that can be extracted from AutoCAD.

I am importing AutoCAD geometry into Revit and am looking to extract the GlobalUniqueID from the Revit Content. I am having a rough time with this one.

Are you referring to an IFC GUID? The UniqueId of a Revit element is Revit-specific and not globally unique. When you import the data from AutoCAD is there a GUID parameter which you can see in Revit?

1 Like

Not the IFC GUID. The same Globally Unique ID that can be seen in AutoCAD.

I am having a hard time extracting the GUID from the Revit Model Elements at this point in time.

I’m not sure if this can be accomplished as Revit does not use GUIDs. I haven’t used much AutoCAD so I don’t know where to approach it from that end. I have used a bit of Civil3D to create property sets using formulas (examples here) to carry over additional data that isn’t typically included in an IFC export. However, if you are not using IFC, this approach may not work for you.

Hi @t.large

Could you please share the screenshot of it in Autocad?

Don’t worry!
We’ll try to help you.

So here is a screenshot of the GUID of the elbow shown. This is in AutoCAD.

Thank you!

@t.large Could please drop dwg file with elbow here?

Drawing_Test.dwg (2.5 MB)

The file includes an elbow and a table that contains the elbow’s Globally Unique ID.

And I am looking to extract the same value from the same content in Revit (after I import the content into Revit.) Should I be looking into IFC GUID? I suppose I just always assumed it was something totally unrelated. I’m not at all sure how it works.

Also, for what it is worth, I am running AutoCAD 2019, Revit 2019, and Dynamo

Hello @aaronrumple! I would also like to get the GUID of a revit element. I am trying this python script but it does not seem to be working. Is this script correct above? Please advise.

if it matters, my element list contains a mixture of linked model elements and current document elements. I am using Dynamo 1.3.4 thanks!

Your data has an additional level of nesting, requiring another loop to be added:

element_lists = UnwrapElement(IN[0])
uniqueid_lists = []
for element_list in element_lists:
    uniqueid_temp = []
    for element in element_list:

OUT = uniqueid_lists

This can (and should) be done with a recursive function, but I would need to do a refresher on recursion first.

1 Like

thanks cgartland, what does a recursive function do? Why is it important here?

A recursive function would be able to handle any level of nesting (e.g. if you have a single element, list of elements, or list of list of elements, etc.). If one were to provide a list of elements with a 3rd level of nesting to the above code, it would also fail.

However, I would like to point out that the above code gets the UniqueId of each element. The UniqueId is not globally unique, which has been discussed on the Revit API forum. If you are trying to get an IFC Guid, the above code doesn’t do that.

1 Like

Thank you Cgartland… It really works. thats what I was looking for. :grinning:

1 Like