# How to Get SpecType by String

**URL:** <https://forum.dynamobim.com/t/how-to-get-spectype-by-string/94312>\
**Category:** Revit\
**Tags:** designscript, dynamo\
**Created:** [October 5, 2023, 9:05am UTC](https://forum.dynamobim.com/t/how-to-get-spectype-by-string/94312 "2023-10-05T09:05:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![qwerty123456](https://avatars.discourse-cdn.com/v4/letter/q/a88e57/32.png) [@qwerty123456](https://forum.dynamobim.com/u/qwerty123456)\
**Post date:** [October 5, 2023, 9:05am UTC](https://forum.dynamobim.com/t/how-to-get-spectype-by-string/94312/1 "2023-10-05T09:05:14Z")

</div>

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/b/abeee47452b9a5e63aa9fe599b749d53c8de403d.png)  
The problem with dropdown is that the stored value can often go missing when opening another project.  
The codeblock is what I want to achieve, but apparently it’s not working

---

<div class="post-metadata">

**Author:** ![qwerty123456](https://avatars.discourse-cdn.com/v4/letter/q/a88e57/32.png) [@qwerty123456](https://forum.dynamobim.com/u/qwerty123456)\
**Post date:** [October 5, 2023, 9:15am UTC](https://forum.dynamobim.com/t/how-to-get-spectype-by-string/94312/2 "2023-10-05T09:15:52Z")

</div>

Found it here

> [@FamilyDocument.AddParameter groupType and SpecType 2.13](https://forum.dynamobim.com/t/familydocument-addparameter-grouptype-and-spectype-2-13/82656/5):
>
> Hello @crapai here are some images from another dev that I think illustrate a way to get the info you want if I am understanding correctly. (ForgeType.TypeId) node

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/4/b45354de3931b052dc7b8e7215e6d5885fa0b629.png)

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [October 5, 2023, 10:04am UTC](https://forum.dynamobim.com/t/how-to-get-spectype-by-string/94312/3 "2023-10-05T10:04:48Z")

</div>

> [@qwerty123456](#):
>
> The problem with dropdown is that the stored value can often go missing when opening another project.

This shouldn’t be an issue from Dynamo 2.12 on, as the data is stored in Dictionary format instead of list indexing. This means that soon (2022 supports 2.12 and 2021 is on the last 5 or 6 months of it’s life). As a result moving to dropdowns should be possible soon.

---

<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:** [November 3, 2023, 11:50pm UTC](https://forum.dynamobim.com/t/how-to-get-spectype-by-string/94312/4 "2023-11-03T23:50:16Z")

</div>

Hi @jacob.small , @qwerty123456 (and (@Michael_Kirschner2 ),

I’ve been playing around with getting SpecTypes and I was wondering where one could find a more comprehensive list regarding those SpecType Id inputs (referring to quoted post), which I’m now only able to get through a Dropdown node.

> [@qwerty123456](#):
>
> Found it here

I would like to have multiple SpecTypes input, perhaps preferably in a Data-Shapes or other interface, so the dropdown node isn’t ideal for that. And it only allows the user to have a single input, instead of a code block list with multiple.

What I’ve got now works, but isn’t great since it just works with ForgeTypeIds, which I don’t really understand haha

What I’ve got now (above group) seems to work, kinda, it retrieves all ForgeTypeIds, not really sure what those are, and I’ve filtered them to the desired ones and then wrote some python to get the unit types of those spec types. I’ve tried getting that python code from within the first Clockwork node, but I just can’t get it to work, even when copying the code 1:1 into my workspace.

 ![2023-11-04 Spec Type and ForgeTypeId testing_2023-11-04_12-57-17](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/a/fa20ecb1694190669318aa66b04f73a301c5cf18.png)  
[2023-11-04 Spec Type and ForgeTypeId testing.dyn](https://forum.dynamobim.com/uploads/short-url/2cekuLw7tSuUplajsASz56weVYX.dyn) (24.1 KB)

---

<div class="post-metadata">

**Author:** ![Mike.Buttery](https://avatars.discourse-cdn.com/v4/letter/m/b19c9b/32.png) [@Mike.Buttery](https://forum.dynamobim.com/u/Mike.Buttery)\
**Post date:** [November 4, 2023, 1:23am UTC](https://forum.dynamobim.com/t/how-to-get-spectype-by-string/94312/5 "2023-11-04T01:23:29Z")

</div>

This is a bit quick and dirty as will have a few methods hiding the list (Equals, GetType, GetHashCode)  
`[p for p in dir(SpecTypeId) if "_" not in p]`

If it is an attribute you can get the object it with `eval(f"SpecTypeId.{p}")`

---

<div class="post-metadata">

**Author:** ![martin.taurer54TJX](https://avatars.discourse-cdn.com/v4/letter/m/9de0a6/32.png) [@martin.taurer54TJX](https://forum.dynamobim.com/u/martin.taurer54TJX)\
**Post date:** [December 1, 2024, 5:20pm UTC](https://forum.dynamobim.com/t/how-to-get-spectype-by-string/94312/6 "2024-12-01T17:20:52Z")

</div>

I found a workflow how to retrieve the Spec Type names: Create a project and create a family in there. In that family, start to add paraeters of different types… Yes/No, Material, Length,… then run the script attached and see what the string is you need to pass on.

 ![GetSpecType_2024-12-01_06-19-16](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/c/2c239d8b6327fd6f63d78ccea459254de865e681.png)
