# Getting Type Mark from Linked Elements

**URL:** https://forum.dynamobim.com/t/getting-type-mark-from-linked-elements/49773
**Category:** Uncategorized
**Created:** [April 25, 2020, 9:52am UTC](https://forum.dynamobim.com/t/getting-type-mark-from-linked-elements/49773 "2020-04-25T09:52:38Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![Keith\_Wilkinson1](https://avatars.discourse-cdn.com/v4/letter/k/5f8ce5/32.png) [@Keith\_Wilkinson1](https://forum.dynamobim.com/u/Keith_Wilkinson1)
#### Post date: [April 25, 2020, 9:52am UTC](https://forum.dynamobim.com/t/getting-type-mark-from-linked-elements/49773/1 "2020-04-25T09:52:38Z")

</div>

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.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/2/c20f1a7fd402f8a3855289fedb4551d1d052836b.png)

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/8/88816fac9cbdda59c36d06e9c9905790d32dc281.png)

---

<div class="post-metadata">

### Author: ![dsnook](https://avatars.discourse-cdn.com/v4/letter/d/48db29/32.png) [@dsnook](https://forum.dynamobim.com/u/dsnook)
#### Post date: [April 27, 2020, 8:54am UTC](https://forum.dynamobim.com/t/getting-type-mark-from-linked-elements/49773/2 "2020-04-27T08:54:12Z")

</div>

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:

 ![Capture1](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/6/c616132c860db506ee35e230f05bc83f6ff4a123.png)

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

---

<div class="post-metadata">

### Author: ![Keith\_Wilkinson1](https://avatars.discourse-cdn.com/v4/letter/k/5f8ce5/32.png) [@Keith\_Wilkinson1](https://forum.dynamobim.com/u/Keith_Wilkinson1)
#### Post date: [April 27, 2020, 9:33am UTC](https://forum.dynamobim.com/t/getting-type-mark-from-linked-elements/49773/3 "2020-04-27T09:33:09Z")

</div>

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

Cheers

K.

---

<div class="post-metadata">

### Author: ![janathbdesign](https://avatars.discourse-cdn.com/v4/letter/j/43a26b/32.png) [@janathbdesign](https://forum.dynamobim.com/u/janathbdesign)
#### Post date: [February 17, 2022, 2:51am UTC](https://forum.dynamobim.com/t/getting-type-mark-from-linked-elements/49773/4 "2022-02-17T02:51:01Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Daan](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/daan/32/82246_2.png) [@Daan](https://forum.dynamobim.com/u/Daan)
#### Post date: [February 20, 2022, 4:21pm UTC](https://forum.dynamobim.com/t/getting-type-mark-from-linked-elements/49773/5 "2022-02-20T16:21:22Z")

</div>

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 🙂

---

<div class="post-metadata">

### Author: ![janathbdesign](https://avatars.discourse-cdn.com/v4/letter/j/43a26b/32.png) [@janathbdesign](https://forum.dynamobim.com/u/janathbdesign)
#### Post date: [February 24, 2022, 2:50am UTC](https://forum.dynamobim.com/t/getting-type-mark-from-linked-elements/49773/6 "2022-02-24T02:50:56Z")

</div>

Thanks Daan,

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

 ![Capture](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/0/4/0436f6fa49a98ee3d9d3556783aa69ba55a076e4.png)

---

<div class="post-metadata">

### Author: ![Daan](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/daan/32/82246_2.png) [@Daan](https://forum.dynamobim.com/u/Daan)
#### Post date: [February 24, 2022, 5:06pm UTC](https://forum.dynamobim.com/t/getting-type-mark-from-linked-elements/49773/7 "2022-02-24T17:06:05Z")

</div>

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

---

<div class="post-metadata">

### Author: ![janathbdesign](https://avatars.discourse-cdn.com/v4/letter/j/43a26b/32.png) [@janathbdesign](https://forum.dynamobim.com/u/janathbdesign)
#### Post date: [February 25, 2022, 1:33am UTC](https://forum.dynamobim.com/t/getting-type-mark-from-linked-elements/49773/8 "2022-02-25T01:33:20Z")

</div>

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](https://forum.dynamobim.com/uploads/short-url/2c6UEW9QmUg0oSQMEWOcGGdrLC8.rvt) (2.1 MB)  
[linked file.rvt](https://forum.dynamobim.com/uploads/short-url/pKYtZeNAoLW8zHy5RXVlDcYhFIk.rvt) (3.1 MB)  
[linked file 1.rvt](https://forum.dynamobim.com/uploads/short-url/uEpGpUtY6vQfqIdgNCgSNwctnpD.rvt) (3.1 MB)  
[Copy Type Mark From Linked File multiple links V1.01.01.dyn](https://forum.dynamobim.com/uploads/short-url/5b51s75bUDJnz79q9lMEcND2kxP.dyn) (22.8 KB)

---

<div class="post-metadata">

### Author: ![Elie.Trad](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/elie.trad/32/110373_2.png) [@Elie.Trad](https://forum.dynamobim.com/u/Elie.Trad)
#### Post date: [February 25, 2022, 1:55pm UTC](https://forum.dynamobim.com/t/getting-type-mark-from-linked-elements/49773/9 "2022-02-25T13:55:11Z")

</div>

@janathbdesign can you try this?  
[Copy Type Mark From Linked File multiple links V1.01.02.dyn](https://forum.dynamobim.com/uploads/short-url/8lW4eRpbRholyBQqaPLH7BNryPp.dyn) (20.0 KB)

---

<div class="post-metadata">

### Author: ![janathbdesign](https://avatars.discourse-cdn.com/v4/letter/j/43a26b/32.png) [@janathbdesign](https://forum.dynamobim.com/u/janathbdesign)
#### Post date: [February 26, 2022, 5:19am UTC](https://forum.dynamobim.com/t/getting-type-mark-from-linked-elements/49773/10 "2022-02-26T05:19:14Z")

</div>

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

Jan

---

<div class="post-metadata">

### Author: ![janathbdesign](https://avatars.discourse-cdn.com/v4/letter/j/43a26b/32.png) [@janathbdesign](https://forum.dynamobim.com/u/janathbdesign)
#### Post date: [March 1, 2022, 9:56am UTC](https://forum.dynamobim.com/t/getting-type-mark-from-linked-elements/49773/11 "2022-03-01T09:56:41Z")

</div>

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

 ![Capture](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/4/74776bc3d8035b46753639326d5ccd965a080f27.png)  
[linked file 1.rvt](https://forum.dynamobim.com/uploads/short-url/8skRAXNDyT3vOMSfCzYQJRjt3QB.rvt) (3.4 MB)  
Uploading: Door and Window schedule.rvt…  
[Copy Type Mark From Linked File multiple links V1.01.02.dyn](https://forum.dynamobim.com/uploads/short-url/aUjPLpnU4IX3bWff47EfgHfuzx5.dyn) (20.0 KB)

---

<div class="post-metadata">

### Author: ![Elie.Trad](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/elie.trad/32/110373_2.png) [@Elie.Trad](https://forum.dynamobim.com/u/Elie.Trad)
#### Post date: [March 1, 2022, 11:06am UTC](https://forum.dynamobim.com/t/getting-type-mark-from-linked-elements/49773/12 "2022-03-01T11:06:54Z")

</div>

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

---

<div class="post-metadata">

### Author: ![janathbdesign](https://avatars.discourse-cdn.com/v4/letter/j/43a26b/32.png) [@janathbdesign](https://forum.dynamobim.com/u/janathbdesign)
#### Post date: [March 2, 2022, 4:51am UTC](https://forum.dynamobim.com/t/getting-type-mark-from-linked-elements/49773/13 "2022-03-02T04:51:17Z")

</div>

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]

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/f/2fc5af27309d98ca03575d43605fa725fd681dc5.png)

---

<div class="post-metadata">

### Author: ![Elie.Trad](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/elie.trad/32/110373_2.png) [@Elie.Trad](https://forum.dynamobim.com/u/Elie.Trad)
#### Post date: [March 2, 2022, 9:27am UTC](https://forum.dynamobim.com/t/getting-type-mark-from-linked-elements/49773/14 "2022-03-02T09:27:49Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/9/7920ec92ee1eddc336ae876bb7fad4c701c4c19f.png)

---

<div class="post-metadata">

### Author: ![janathbdesign](https://avatars.discourse-cdn.com/v4/letter/j/43a26b/32.png) [@janathbdesign](https://forum.dynamobim.com/u/janathbdesign)
#### Post date: [March 2, 2022, 9:43am UTC](https://forum.dynamobim.com/t/getting-type-mark-from-linked-elements/49773/15 "2022-03-02T09:43:59Z")

</div>

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

---

<div class="post-metadata">

### Author: ![janathbdesign](https://avatars.discourse-cdn.com/v4/letter/j/43a26b/32.png) [@janathbdesign](https://forum.dynamobim.com/u/janathbdesign)
#### Post date: [March 8, 2022, 9:52am UTC](https://forum.dynamobim.com/t/getting-type-mark-from-linked-elements/49773/16 "2022-03-08T09:52:34Z")

</div>

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?

 ![only 2 parameters 1](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/8/a85dca27ad938f850b8ad8018ea49d85430ce742.png)

[Copy Type Mark From Linked File multiple links V1.01.02.dyn](https://forum.dynamobim.com/uploads/short-url/aUjPLpnU4IX3bWff47EfgHfuzx5.dyn) (20.0 KB)

 ![only 2 parameters 2](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/1/8186d37a84bc57e3da4e02681492a9a05fd72103.png)

thanks again for any help.

Jan
