Find Element by GUID

Find Element by GUID

DouglasNiven7951
Contributor Contributor
10,497 Views
15 Replies
Message 1 of 16

Find Element by GUID

DouglasNiven7951
Contributor
Contributor

We supplied a Revit model to our Client (constructed from point clouds). He has sent us a list of elements with Tags which we must attach to each element. The Client has referenced the elements by GUID. How do we find an element in a Revit model using the GUID? Is there a plug-in that can do it?

Thanks in advance.

0 Likes
Accepted solutions (1)
10,498 Views
15 Replies
Replies (15)
Message 2 of 16

ToanDN
Consultant
Consultant

ToanDN_0-1666217960367.png

 

0 Likes
Message 3 of 16

DouglasNiven7951
Contributor
Contributor

Thanks for the swift response, however I believe this option is the 'short' ID not the GUID or UniqueGUID which has a combination of hex letter and numbers.

0 Likes
Message 4 of 16

ToanDN
Consultant
Consultant

@DouglasNiven7951 wrote:

GUID or UniqueGUID which has a combination of hex letter and numbers.


You can install Revit Lookup add-in from the link below.

https://www.modelical.com/en/how-are-elements-inter-coded-in-bim-bim

 

ToanDN_0-1666226827086.png

 

Message 5 of 16

L.Maas
Mentor
Mentor

Little script in Dynamo can do the trick.

Here I extract the ID, then do a search and then temporarily isolate that element in the view

LMaas_0-1666254889266.png

 

You also could easily vary this by writing all IDs to a parameter and then create a schedule based on that parameter and so on. And depending on what you need with the element, you might be able to automate the rest of the process too.

 

Or if you are talking about the IfcGUID then you can easily find it by exporting to IFC and check "Store the IFC GUID in an element parameter after export". After that you can create a schedule based on that IfcGUID

LMaas_0-1666255267724.png

 

Louis

EESignature

Please mention Revit version, especially when uploading Revit files.

Message 6 of 16

DouglasNiven7951
Contributor
Contributor
Thanks again. My GUIDs appear to be DWF - they are standard GUID format. I have found the Building Code Author who has code to calculate the IFC GUID from the DWF GUID and then to the Unique GUID.
0 Likes
Message 7 of 16

DouglasNiven7951
Contributor
Contributor

Thanks for your reply. I have tons of experience automating AutoCAD API using VB6 (!!!) But none in Revit. I will try your suggestion - refer to my other reply in the earlier post. I only have DWF GUIDs

0 Likes
Message 8 of 16

L.Maas
Mentor
Mentor

Then this might help (script attached). I never used DWF GUIDS, so not sure if they are correct.

LMaas_0-1666261735504.png

 

Louis

EESignature

Please mention Revit version, especially when uploading Revit files.

Message 9 of 16

DouglasNiven7951
Contributor
Contributor

Thank you so much for your efforts. We will give this a try.

0 Likes
Message 10 of 16

DouglasNiven7951
Contributor
Contributor
Accepted solution

OK, I have found the IFC coding and mapping. I can create my own app now to convert the DWF to IFC. The user can then search filter by IFC.

Thanks everybody for your help - your suggestions were a catalyst for my thoughts.

IFC-GUID Base-64 character encoding mapping:
0123456789012345678901234567890123456789012345678901234567890123
0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_$

 

###############################################################################
# #
# This file is part of IfcOpenShell. #
# #
# IfcOpenShell is free software: you can redistribute it and/or modify #
# it under the terms of the Lesser GNU General Public License as published by #
# the Free Software Foundation, either version 3.0 of the License, or #
# (at your option) any later version. #
# #
# IfcOpenShell is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# Lesser GNU General Public License for more details. #
# #
# You should have received a copy of the Lesser GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
# #
###############################################################################

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import uuid
import string

from functools import reduce

chars = string.digits + string.ascii_uppercase + string.ascii_lowercase + '_$'


def compress(g):
bs = [int(g[i:i + 2], 16) for i in range(0, len(g), 2)]

def b64(v, l=4):
return ''.join([chars[(v // (64 ** i)) % 64] for i in range(l)][::-1])

return ''.join([b64(bs[0], 2)] + [b64((bs[i] << 16) + (bs[i + 1] << 😎 + bs[i + 2]) for i in range(1, 16, 3)])


def expand(g):
def b64(v):
return reduce(lambda a, b: a * 64 + b, map(lambda c: chars.index(c), v))

bs = [b64(g[0:2])]
for i in range(5):
d = b64(g[2 + 4 * i:6 + 4 * i])
bs += [(d >> (8 * (2 - j))) % 256 for j in range(3)]
return ''.join(['%02x' % b for b in bs])


def split(g):
return '{%s-%s-%s-%s-%s}' % (g[:8], g[8:12], g[12:16], g[16:20], g[20:])


def new():
return compress(uuid.uuid4().hex)

Message 11 of 16

L.Maas
Mentor
Mentor

Not sure if I would go that way. As you can see from the script, it reads the Revit ID, IFGUID, Unique ID and the DWF GUID from the element, so why generate it yourself?

And if it gets more into programming, then also do not forget to visit the Revit API forum.

And a last thing when showing code samples try to use the code tag

Code Here

 

LMaas_0-1666299527413.png

 

Louis

EESignature

Please mention Revit version, especially when uploading Revit files.

0 Likes
Message 12 of 16

DouglasNiven7951
Contributor
Contributor

OK, so the user work flow would be to work from model to list rather than list to model. Meaning they select an element with your script, find the DWF ID on the list and apply the tag. They also have to rename the elements and clean up the element tree so they can create new 'layers' for finalised items and switch those off to ensure everything has been handled - for QC purposes.

I did post on the API forum as well and Jeremy Tammik has been advising me. That work flow would be to back calculate Unique ID's and Revit IDs from the DWF ID in an external app then use the result to search in Revit for each element. A different route for the same task.

Since you have kindly supplied a script, that seems the easiest route because I am an Algol W (!!) and VB6 coder not C# - (Lets say I have a lot of wrinkles and prefer to write my apps using punched cards 😁)

Thank you again

Message 13 of 16

DouglasNiven7951
Contributor
Contributor

Just for information, our Client is the Engineering contractor for a Developer who is building a whole new city. The whole city will be BIM. We 3D scan the city as-built and create the Revit model. The Revit model will be transferred into a digital twin. Clearly the GUID is important factor in uniquely identifying elements in each unit area. It would be nice if Autodesk built in a GUID search option in the standard search routine. Not rocket science or a lot of coding time to do.

Thanks again to all who helped.

0 Likes
Message 14 of 16

nikhil.patel2
Enthusiast
Enthusiast

Would you have a dynamo graph to extract the GUID (not the uniqueID) by any chance?

0 Likes
Message 15 of 16

DouglasNiven7951
Contributor
Contributor

Sorry no, in the end we were able to use the standard Revit ID. It was a work share model so occasionally ID's changed but we used Navisworks old revision and new revision to visually identify the elements and update the ID on the Excel tag list.

0 Likes
Message 16 of 16

hagay.e
Contributor
Contributor

hello Louis, 

i was looking for a way to allocate revit element based on the IFCGUID and i saw this post

i have run the Dynamo script that you have shown but it is not related to IFCGUID, 

it based on a UniqueID that i could not find in the revit as alocated to element. so it can not be seen in SChedule....

is there a way to find the element by the IFCGUID? is there a way to convert IFCGUID to UniqueID? 

is there a way to find\show element from linked model by one of these parameters? 

 

Thnaks, Hagay.

0 Likes