Getting Type Mark from Linked Elements

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.

Any thoughts/solutions gratefully received.

Cheers

K.

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:

The python code is here:

# 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

I trust that helps

thanks Darren, I’ll give that a go later and let you know if there are any problems!

Cheers

K.