Hello all, I’m here to continue on the previous post of Accessing Shared Parameter Part 1. In this post, I’m going to share with you guys an alternative method to access the shared parameter file in your Revit model. The picture below shows the complete dynamo graph, it is basically similar to the previous graph posted in the previous, but different approach is being adopted in the python script.

import clr clr.AddReference('ProtoGeometry') from Autodesk.DesignScript.Geometry import * # Import DocumentManager and TransactionManager clr.AddReference("RevitServices") import RevitServices from RevitServices.Persistence import DocumentManager from RevitServices.Transactions import TransactionManager # Import RevitAPI clr.AddReference('RevitAPI') from Autodesk.Revit.DB import * # Import ToDSType(bool) extension method clr.AddReference("RevitNodes") import Revit clr.ImportExtensions(Revit.Elements) # Import ToProtoType, ToRevitType geometry conversion extension methods clr.ImportExtensions(Revit.GeometryConversion) # Import DSCore nodes in Dynamo clr.AddReference('DSCoreNodes') import DSCore from DSCore import * # Import python library import sys pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib' sys.path.append(pyt_path) import os import shutil import math # Import math library from math import * #Import Data and Time from datetime import datetime now = datetime.now() #Import System Library import System from System.Collections.Generic import * from System.IO import Directory, Path doc = DocumentManager.Instance.CurrentDBDocument uiapp = DocumentManager.Instance.CurrentUIApplication app = uiapp.Application #Preparing input from dynamo to revit SharedParameterFilePath = IN[0] app.SharedParametersFilename = SharedParameterFilePath SharedParamFile = app.OpenSharedParameterFile() grs = SharedParamFile.Groups guidList,nameList,datatypeList,dataCatList,Grouplist,visList,descripList,userModList = [],[],[],[],[],[],[],[] for grp in grs: GroupName = grp.Name defs = grp.Definitions for definition in defs: guidList.append(str(definition.GUID)) nameList.append(str(definition.Name)) datatypeList.append(str(definition.ParameterType)) dataCatList.append(str(definition.ParameterGroup)) Grouplist.append(GroupName) visList.append(definition.Visible) descripList.append(str(definition.Description)) userModList.append(definition.UserModifiable) #Final output OUT = guidList,nameList,datatypeList,dataCatList,Grouplist,visList,descripList,userModList
Whereas the code above shows what is happening inside the python script.
Essentially, we are utilizing Revit API to achieve this.
app.SharedParametersFilename = SharedParameterFilePath
refers to this API doc whereby we set the file path of the shared parameter file to desire location. Thereafter, we just open the shared parameter file using the OpenSharedParameterFile()
method , getting the DefinitionFile data as output. Thus, finally, access its groups data through this API doc. Afterwhich, we can simply loop through each group to obtain its definition, and for each definition, append the required information or parameters as the output.
The output data is as per shown in the picture above and the downloadable files are below:
If there’s any unclear information or things that is unclear, feel free to drop a comment down below. Else, as always, happy coding~
May I access to the revit files and dynamos of both part1 and part2?
Thank you!
Hello Stephen, the link had been updated. Sorry for any inconvenience caused.