I'm back after a while with a new article on Dynamo. This time I'll try to explain how to check if a list of parameters are available in the project. This can be used as starting point to QA a model against a pre-defined template.
The idea is pretty simple: we need to extract all the parameters from the model and to do this we list all the elements of type "ParameterElement". You'll get the list of both shared and project paraemters in this way.
Then we can extract the paraemters names and create a list of paraemter that we want to check (this list can be also an input from Excel).
The idea is pretty simple: we need to extract all the parameters from the model and to do this we list all the elements of type "ParameterElement". You'll get the list of both shared and project paraemters in this way.
Then we can extract the paraemters names and create a list of paraemter that we want to check (this list can be also an input from Excel).
Whit a simple Python script that compares all the parameters name, agains the list of predifined parameters, we can easily extract two lists: the first is the list of matched and the second is the list of unmatched.
This is the python code.
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.
dataEnteringNode = IN
paramAvailable = UnwrapElement(IN[0])
listOfParam = UnwrapElement(IN[1])
lstFound = []
lstNotFound = []
for p in listOfParam:
c = 0
for l in paramAvailable:
if (l==p):
c = 1
if (c == 1):
lstFound.append(p)
else:
lstNotFound.append(p)
#Assign your output to the OUT variable.
OUT = (lstFound, lstNotFound)
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
#The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN
paramAvailable = UnwrapElement(IN[0])
listOfParam = UnwrapElement(IN[1])
lstFound = []
lstNotFound = []
for p in listOfParam:
c = 0
for l in paramAvailable:
if (l==p):
c = 1
if (c == 1):
lstFound.append(p)
else:
lstNotFound.append(p)
#Assign your output to the OUT variable.
OUT = (lstFound, lstNotFound)
Are you sure you don't want to learn how to code?
Enjoy,
Cesare
I cant seem to get this to work at all. Breaks at the first run.
ReplyDeleteNever mind it worked used the parameter Element type and not Element Types
DeleteKenco Electric India Private Limited is a trusted and reliable (EPC) Contractor. This company is one of the top Electrical EPC Contractor In the Northern Region and other parts of India.
ReplyDeleteKenco Electric
Kenco Electric India Private Limited is a trusted and reliable (EPC) Contractor. This company is one of the top Electrical EPC Contractor In the Northern Region and other parts of India.
ReplyDeleteKenco Electric