Keynote from element PYTHON

Hi everyone!

Can you help me to get parameter values from BuiltIn Parameters in PYTHON. I know how to get Shared Parameters only…

import clr

clr.AddReference("RevitAPI")
clr.AddReference("RevitServices")

import Autodesk
import RevitServices

from Autodesk.Revit.DB import *
from RevitServices.Persistence import DocumentManager

doc =  DocumentManager.Instance.CurrentDBDocument

collector = FilteredElementCollector(doc)
element = collector.OfCategory(BuiltInCategory.OST_Casework).ToElements()

out = []
for i in element:
    for param in i.Parameters:
        if param.IsShared and param.Definition.Name == 'CATEGORY':
            paramValue = i.get_Parameter(param.GUID)
            out.append(paramValue.AsString())   
         
OUT = out

Hi,
Use this property
IsShared

[EDIT]

Hi c.poupin,

Would you mind providing me with an example using the above code?

Cheers,

Oops, I answered too quickly
an example to get only BuittInParameter(s)

import clr

clr.AddReference("RevitAPI")
clr.AddReference("RevitServices")

import Autodesk
import RevitServices

from Autodesk.Revit.DB import *
from RevitServices.Persistence import DocumentManager

doc =  DocumentManager.Instance.CurrentDBDocument

collector = FilteredElementCollector(doc)
element = UnwrapElement(IN[0])

myInternalParameters = []

for param in element.Parameters:
    paradef = param.Definition
    if not param.IsShared and isinstance(paradef, InternalDefinition):
    	if paradef.BuiltInParameter != BuiltInParameter.INVALID:
        	myInternalParameters.append([param.Definition.Name, paradef.BuiltInParameter, param])

         
OUT = myInternalParameters
1 Like

Hi @c.poupin

Thanks for that!

Probably a simple question. I was after the values. Is it possible to add the parameter value within your output list?

Also, could it be applied to multiple elements?

Thank you!

Hi @c.poupin

I think I found a way to get the element value:

elementname = element.get_Parameter(BuiltInParameter.KEYNOTE_PARAM)

parameterstoragetype = elementname.StorageType

paramvalue = elementname.AsString()

Can you please help to get a list of all element values?


import clr

clr.AddReference("RevitAPI")
clr.AddReference("RevitServices")

import Autodesk
import RevitServices

from Autodesk.Revit.DB import *
from RevitServices.Persistence import DocumentManager

doc =  DocumentManager.Instance.CurrentDBDocument

collector = FilteredElementCollector(doc)
element = UnwrapElement(IN[0])

myInternalParameters = []
        	
elementname = element.get_Parameter(BuiltInParameter.KEYNOTE_PARAM)

parameterstoragetype = elementname.StorageType
paramvalue = elementname.AsString()

OUT = elementname, paramvalue, parameterstoragetype

thanks

here an example


import clr

clr.AddReference("RevitAPI")
clr.AddReference("RevitServices")

import Autodesk
import RevitServices

from Autodesk.Revit.DB import *
from RevitServices.Persistence import DocumentManager

doc =  DocumentManager.Instance.CurrentDBDocument

collector = FilteredElementCollector(doc)
toList = lambda x : x if hasattr(x, '__iter__') else [x]
#Preparing input from dynamo to revit
lstelems = toList(UnwrapElement(IN[0]))

myInternalParameters = []
for element in lstelems:
	for param in element.Parameters:
		paradef = param.Definition
		if not param.IsShared and isinstance(paradef, InternalDefinition):
			if paradef.BuiltInParameter == BuiltInParameter.KEYNOTE_PARAM :
				elementname = element.get_Parameter(BuiltInParameter.KEYNOTE_PARAM)
				paramvalue = elementname.AsString()
				parameterstoragetype = elementname.StorageType
				myInternalParameters.append([param.Definition.Name, paramvalue, parameterstoragetype])

OUT = myInternalParameters
2 Likes

Merci beaucoup @c.poupin!

Cela a bien fonctionné !

1 Like

Hi @c.poupin

Hopefully quick question. If the parameter is an instance Built In parameter (i.e: Room number, level, etc…) how would you approach it?

Thanks in advance!

Here an example


# get Parameter Type
param_type = element_type.get_Parameter(BuiltInParameter.MY_BUILTIN_NAME)
# get Parameter Instance
param_instance = element_instance.get_Parameter(BuiltInParameter.MY_BUILTIN_NAME)
1 Like