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.

Darren, Keith,

This is really great! I am developing automated door and window schedules and this is really usefull getting type marks from linked files.

Would it be possible to adjust the python so I can use a list links?

Thanks am gazillion!

Jan

Hi @janathbdesign ,

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 :slight_smile:

Thanks Daan,

Tried that, but there must be somehting I am doing wrong:

Could you upload your .dyn-file and a sample revit file? I think it has to do something with the lacing :smiley:

Sure Daan, “Door and Window Schedule.rvt” has the other two files linked to it.

Thanks for your help.

Jan

Door and Window schedule.rvt (2.1 MB)
linked file.rvt (3.1 MB)
linked file 1.rvt (3.1 MB)
Copy Type Mark From Linked File multiple links V1.01.01.dyn (22.8 KB)

@janathbdesign can you try this?
Copy Type Mark From Linked File multiple links V1.01.02.dyn (20.0 KB)

1 Like

Thanks Tradelie,
Absolutely brilliant, does exactly what I need!

Jan

1 Like

Hi Elie,

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?

thanks,
Jan


linked file 1.rvt (3.4 MB)
Uploading: Door and Window schedule.rvt…
Copy Type Mark From Linked File multiple links V1.01.02.dyn (20.0 KB)

@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]

Thanks Elie,

But these parameters are not built in parameters, they are shared parameters.

In the python code I use when I select a single link, this line will retrieve the value:

get HARDWARE parameter value

par1Set = [i.LookupParameter(parName1).AsString() for i in elemTypes]

@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:

Yeah, I figured it was something like that. let me try again. Thanks!

1 Like

Hi tradelie,

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?

Copy Type Mark From Linked File multiple links V1.01.02.dyn (20.0 KB)

thanks again for any help.

Jan