Lookup parameters by GUID in python


Trying to collect Project Info parameters for Survey Base Point so to push them to some Shared Parameters in a Home View Titleblock.

I managed to figure out how to do it using the ele.LookupParameter(parameter name) but I would rather do it using the GUID so to make it more robust.

I could not find how to do it on the web. Any ideas?
Thank you for your comments.

with revit.Transaction('Update Home View Info'):
#	forms.alert('You are about to update the Home View info \nDo you want to continue?', yes=True, no=True, exitscript=True) 

	sbp = DB.FilteredElementCollector(revit.doc)\

	pbp = DB.FilteredElementCollector(revit.doc)\

	projInfo = DB.FilteredElementCollector(revit.doc)\

	#get Survey Base Point properties
	for ele in sbp:
		sbp_ew = get_BI_convertFeet2Milims(ele,DB.BuiltInParameter.BASEPOINT_EASTWEST_PARAM)
		sbp_ns = get_BI_convertFeet2Milims(ele,DB.BuiltInParameter.BASEPOINT_NORTHSOUTH_PARAM)
		sbp_elev = get_BI_convertFeet2Milims(ele,DB.BuiltInParameter.BASEPOINT_ELEVATION_PARAM)
		#print (sbp_ew_)

	#get Project Base Point properties
	for ele in pbp:
		pbp_ew = get_BI_AsValueString(ele,DB.BuiltInParameter.BASEPOINT_EASTWEST_PARAM)
		pbp_ns = get_BI_AsValueString(ele,DB.BuiltInParameter.BASEPOINT_NORTHSOUTH_PARAM)
		pbp_elev = get_BI_AsValueString(ele,DB.BuiltInParameter.BASEPOINT_ELEVATION_PARAM)
		pbp_angle = get_BI_AsValueString(ele,DB.BuiltInParameter.BASEPOINT_ANGLETON_PARAM)
		#print pbp_ew,pbp_ns,pbp_elev,pbp_angle

	# Home View Shared Parameters info
	# Saved in Project Info

	# SBP EW fd81e15d-2a2f-4d32-bcdf-0e17bc90ecc9
	# SBP NS 2f98f72d-97fe-46ed-b537-9f1bc9168f56
	# SBP ELEV a03fa8de-d275-4ab7-b977-407a98205ae7
	# SBP Location 450bb136-dc81-4fc0-9f2c-fa24d5dada08

	# PBP EW bdef5e57-6934-46ca-8354-adcc77197537
	# PBP NS fd773da1-ed21-41ec-8174-bd915e4a7373
	# PBP ELEV 0780a8ab-c1ab-4f91-94e7-fdb362278926
	# PBP Angle 02da19a4-0140-4cd3-b1bb-8bb0dc87a0bd
	# PBP Location a9ccfd60-6e8f-4571-88d2-ebd8a61dc166

	for ele in projInfo:
		# setting up Home View parameters for Survey Base Point
		home_sbp_ew_param = ele.LookupParameter('Survey Point E/W')
		if home_sbp_ew_param:
		home_sbp_ns_param = ele.LookupParameter('Survey Point N/S')
		if home_sbp_ns_param:
		home_sbp_elev_param = ele.LookupParameter('Survey Point Elevation')
		if home_sbp_elev_param:

Yes, you just need to construct actual GUIDs. Then you can access them directly from the Element’s Parameter Property.

from System import Guid

# Construct actual Guid from string
sbp_ew_guid = Guid('fd81e15d-2a2f-4d32-bcdf-0e17bc90ecc9')
sbp_ew_param = ele.Parameter[sbp_ew_guid]

thanks @cgartland.

How would I use this in my actual code?
Can I use the LookupParameter together with the Guid?

No, LookupParameter is only used with a string (i.e. the parameter’s name). If you use the Parameter property, you can only access it with either a Guid, BuiltInParameter or Definition.

You would just replace this line (and similar lines):

home_sbp_ew_param = ele.LookupParameter(‘Survey Point E/W’)

With something like this:

home_sbp_ew_param = ele.LookupParameter(Guid(‘fd81e15d-2a2f-4d32-bcdf-0e17bc90ecc9’))

In my other example I assigned the Guid to a different variable, but it isn’t necessary (apart from making the code more readable). Just make sure to include this at the beginning of your script:

from System import Guid