Fetch values from type name and distribute them into type parameters

As you can see, I already started defining the very beginning of the script, however I cannot seem to figure out the next steps, even though I searched here and on Youtube to get a clue.

I´m trying to come up with a solution to fetch values from the type name and distribute them into type parameters as follows:

12311.105, where 12311 is Assembly code and 105 indicates unique code for a specific element.

My question is – Can you possibly extract these codes and set their values to predefined type parameters? If so, what nodes would you use and what is the logic behind them?

Hi,

So the since you are working with Type Parameters, make sure you also work with Type Elements. Right now you work with Instances. Let’s say you have 4 Wall types in your project, but you have only used the first 3, then your script will not work for the fourth wall type.

A better way is to Collect all the Wall Types instead of the Walls.

Then you have to extract the codes from the names. you can do this using the String.Split Node. You split the name using “.” (Dot) and the " " (Space)

Then Use Element.SetParameterByName to set the Value to desired Parameter Name

1 Like

I would also recommend setting up a dictionary of all the codes and their associated values, so that when you pull each section of the element name you just have to check it against the dictionary to get the associated value.

1 Like

Hi Joelmick, thanks for your input really appreciate that! It was actually very helpful and the script is running with no issues whatsoever!

However I came across an issue I don´t seem to figure out. Regardless many different tries I cannot wrap my head around the following issue:

As per the project I´m working on at the moment I need to apply the predefined codes to different families such as:

  • walls
  • floors
  • doors
  • windows
  • stairs
  • railings
  • structural connections
  • casework
  • furniture
  • ceilings
  • structural columns
  • structural framing
  • plumbing fixtures

However as I already found out, element.types node does not include most of the listed families, therefore the script usage is limiting. I have tried running it with walls or floors and the result was spotless. Another point I would like to solve is to run all the listed families together without selecting them one by one.

Any idea how this could be solved? :slight_smile:

Screenshot of the script is attached for your review and if neccessery, I can send over the script itself for further modifications.

Thanks in advance, your help would be highly appreciated in this manner :slight_smile:

Hi @krajcik57VS2

I checked and you are right. The Element Types node does not contain most of the Categories listed.

I have a question do you want all the Instances or do you want the Types in the Project. I mentioned that for your example you can better get the Types instead of the instances:

Let’s say you have 4 Wall types in your project, but you have only used the first 3, then your script will not work for the fourth wall type.

In your screenshot you get the “Walls” instead of the “Wall Types”. Therefore my question.

Getting All the Type Elements within a Category

Let’s say you want all the Element Types of the Following Categories:

  • walls
  • floors
  • doors
  • windows
  • stairs
  • railings
  • structural connections
  • casework
  • furniture
  • ceilings
  • structural columns
  • structural framing
  • plumbing fixtures

As you mentioned, most of the Categories do not exist in the Element Types node.

You can do the following steps to get all Element Types of the requested Categories (in pure Dynamo Code):

  1. Get All ElementTypes in the project. You can do this by using the Element Types node and set that to ElementTypes. This will return al Types in the Project (Thing that are not placed in Revit, but exist in the Database)

  2. Get all the Categories you want to Filter out. Create a List of the Category names and use Category.ByName node to get them.

  3. Get the Category of each element Type from step 1 and Filter them by the List with Categories from step 2.

  4. (Bonus) You can group the elements by their Category to keep everything together nice and tidy.

Getting All the Instance Elements within a Category

  1. Get all the Categories you want to Filter out. Create a List of the Category names and use Category.ByName node to get them.

  2. use the All Elements of Category node to get the Instances.

Hi Joelmick,

thanks again for your input, seems like the script is moving forward step by step!

I replicated your suggestions in the script, long story short - it works but it doesn´t comply with the rest of the nodes - see image down below.
Though you might know better where the issue is coming from, any ideas? :slight_smile:

i.e.

Please check you input at the most left watch node. There might be a null in there giving an error. I cannot see what the error say if you post an image like this.

I checked the watch node several times as suggested, no null there.
Node: Element.name" says “Warning: Asked to convert non-convertible types”.
and as you can see 34 elements were recognized, all the other got null.

I would gladly attach the script, but since I´m a new user, I can´t do so yet.

When you get an error in a node (Everything starts at the Element.Name Node) the problem is always in the nodes before that one. Make sure to capture those as well.

It is a very weird rule that new users cannot share multiple files when they start, since you always want to share multiple files (Picture, DYN files, RVT file). So annoying. please try to share your graph and maybe your project over multiple post or by personal message