I’m trying to grab the Type Marks from elements in a linked file. Could anyone shed any light on why this is returning as ‘0’?
My guess it’s something to do with Type Marks having to be assigned within a file (i.e. it doesn’t behave like a ‘normal’ parameter) but if this was the case I’d expect the same thing to happen with the Mark value but this return fine…
Both Mark and Type Mark show in a schedule.
Using the Archilab nodes to grab the linked elements.
Hi Keith
There does seem bit of an oddity with the ‘Type Mark’ parameter. if you pull the element type from the instance, it doesn’t read the ‘Type Mark’ parameter as you have stated. You can however get the element types directly using python and then match up the type ids between the instance and type and that will return the type mark:
# www.watermangroup.com : Darren Snook : London
#--------------- REFERENCES START ---------------
# Enable Python 'Common Language Runtime' (.NET) support
import clr
# Load Revit API
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
# Load System .NET
import System
from System.Collections.Generic import *
# Load Revit Services
# Gives access to the Revit document
clr.AddReference('RevitServices')
import RevitServices
# Get document object
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
# get link instance; retrieve document
link = UnwrapElement(IN[0])
linkdoc = link.GetLinkDocument()
# get category
cat = IN[1]
#get built-in category from category; code adapted from here: https://forum.dynamobim.com/t/how-get-ost-built-in-name-of-element/17657/5
bics = System.Enum.GetValues(BuiltInCategory)
bic = []
for i in bics:
try:
if cat == cat.ById(ElementId(i).IntegerValue):
bic.append(i)
else:
pass
except:
pass
bic = bic[0]
# get types in linked file
elemTypes = FilteredElementCollector(linkdoc).OfCategory(bic).WhereElementIsElementType().ToElements()
# get type ids
elemTypeId = [i.Id for i in elemTypes]
# get type marks
elemTypeMark = [i.get_Parameter(BuiltInParameter.ALL_MODEL_TYPE_MARK).AsString() for i in elemTypes]
# get instances in linked file
elems = FilteredElementCollector(linkdoc).OfCategory(bic).WhereElementIsNotElementType().ToElements()
# loop through instances; compare ids, get types and type marks
typeMarks = []
for i in elems:
for j,k in zip(elemTypeId,elemTypeMark):
if i.GetTypeId() == j:
typeMarks.append(k)
else:
pass
OUT = elems,typeMarks
If you create a Custom Node from the python code and add some in-/output nodes you just have to set the lacing to list level 2 and it should work on lists aswell.
Then you won’t even have to edit the Python code itself
Sorry to ask you this. I’ve been trying 2 days to make this work.
I am now trying to retrieve values of other parameters. I noticed the your code retrieves values from the type, not the instances. Is it possible to retrieve the values of all instances, same as the original python script?
@janathbdesign no worries, to get an instance built-in parameter (Mark parameter for example), loop over the instances list: elemMark = [[i.get_Parameter(BuiltInParameter.ALL_MODEL_MARK).AsString() for i in t] for t in instances]
@janathbdesign I thought you wanted built-in parameters, anyhow the LookupParameter method you mentioned will get the values of the non built-in parameters, (types and instances), just make sure whenever it is an instance parameter to loop over the instances list, and if it is a type parameter loop over the types list:
Got it working with the instance parameters and everything, thanks.
one more question on the original file you sent me if I may.
for some reason the code only picks up 2 typeMarks and familyNames not 5 (one for each instance).
I am not sure why, can it be because instances and types are lists with sublists?