How to Get SpecType by String


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

Found it here

image

1 Like

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.

1 Like

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.

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.dyn (24.1 KB)

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}")