Automate filled region from multiple .pat files using Dynamo for Revit

Hello everybody,
I’m at my first post here (hence you can guess about my experience in Dynamo).
I haven’t any picture to share for the while since my board is still pretty messy, but

what I am trying to do is to import dozens (well, actually around 900…) Autocad .pat files stored in a directory on my pc and to generate filled regions.
Imagine what I want to achieve is to have a revit template file with just an abacus of filled regions that I can copy-paste into other projects.

I won’t give too many details (feel free to ask in case you need) but the issue I am dealing with is that I can’t succeed in “cleaning” the unnecessary strings from some files.

Now I reached the point of having every .csv line organized into a list of strings like this:

value, value, value, value, value, value
value, value, value, value, value, value
value, value, value, value, value, value
value, value, value, value, value, value
value, value, value, value, value, value
value, value, value, value, value, value
value, value, value, value, value, value
value, value, value, value, value, value
value, value, value, value, value, value

and I find out how to separate the lines starting with * (representing the .pat file name) - That’s a real hype if you’re new to the task :stuck_out_tongue:

Problems are:

1- (Even) using the same method I can’t drop out from the list the comment strings inside the .csv files (starting with ;; or ;), which are not containing values to use for creating the patterns and shall be skipped

2-When I bool filter the strings starting with “*” everythings works perfectly fine except for one single line (the first line of the second file actually), so that I get an OUT list with all the string of values (plus this single string, plus the comment string) and an IN list with all others strings starting by “*” (every first line of each file).

I was also able to cross these lists and split the unique giant list in several lists (being the content of each single file, organized in rows containing 6 values each) and it seemed to work, except for those non-homogeneous behaviours I described. Moreover, obviously not every .csv file has the same number of strings, and only some have comments lines, so it is impossible on such a large amount of data to work by index or range (or am I missing something?)

Maybe there is a smarter way to do this but I am new to Dynamo and Python, and trying to use this as an opportunity to approach these tools for data-related tasks (for Revit), so any help will be truly appreciated.

So, my very specific question is: Why can’t I get rid of those strings? And how do I accomplish that? Not only the characters, but the whole string starting with/containing ;; so that I can automate the cleaning of files.
Of course, I’d like to automate the task, so when I add new files to my directory they can be automatically processed by dynamo, but how?

Thank you very much, feel free to suggest me also tutorials and guides on this topic (I am checking some but still searching)


Can you please share a screenshot of how the comments and values actually look inside the csv?
If possible, I would recommend sharing a sample csv.

Hi @AmolShah, thank you for answering.
There goes the printscreen, Dynamo versus .CSV

Meanwhile I noticed @Alban_de_Chasteigner has been dealing with something similar as well, so I just downloaded the GeniusLoci package and will take a look…

Thank you :slight_smile:

Why not read them in as a text file instead? Then use a ‘String.Split’ node to first delineate your pat separations? You can then pull the name and break up lines (/n character) and split at each , as the 3rd step.

@mario.trabucchi See if this gets you started
Split.dyn (35.6 KB)


@AmolShah your flow gets it at best, thank you very much! I just had to add inside the input codeblock for Regex node the “-” sign and " " in order to get everything at its place (due to the variety of the .pat files, it was filtering out some strings that I don’t wanted to.
But then it worked! ^^

The only problem (on my machine) is that having to process so much information (about 900 .pat files) it really takes ages to do it :confused:
So i will definitely proceed onto this, maybe just fractioning the data I intend to process. And I’ll keep you updated.

Anyway, I’m posting what I was trying to do “the basic way” (being a beginner is important for me to understand and keep track of what I am doing).
The last node (As I said previously) is not filtering some strings, as if they doesn’t “start with *”, while they actually do.
I was wondering about what am I missing, it seems like it skips periodically some indices, and I can’t understand the criteria. I checked the .pat files and nothing strange seems to go on with those…

So I wanted to ask: Shouldn’t this flow work as well? Or am I missing anything?
Thank you!

@JacobSmall thank you but I think I can’t understand the difference very well…

Hi Mario,

As you noticed I have already cleared up the subject of creating Fillpatterns.
Obviously if several Fillpatterns are contained in a single .pat file it is indeed necessary to subdivide and reprocess the strings as in the top of this image:
Here is an example with simple .pat files :

1 Like

Thank you very much @Alban_de_Chasteigner!
I’ve seen your work indeed, so once I am done with step 1 I’ll definitely test it and will share the result!
Hope to keep it smooth and efficient to use, but I’m not a programmer soooo… :wink:

Ok, I came along with this, but still there must be something wrong…
@Alban_de_Chasteigner maybe I did not state that clearly, but my purpose is to get several .pat files from a directory and automatically create the corresponding fill pattern at the same time. And filled region elements, after that.

I am mostly doing this as an exercise in order to start understanding the logics of Dynamo, being at my very first approaches, and I was asking to myself: if I get hundreds of .pat files I randomly found on the net and would like to build a library of filled regions for Revit in the faster way, how could I do that on Dynamo (-without being a programmer- that’s the most important part of the question :wink: ) ?

And so I got started but… You can see the results…
Can I ask you where do you think I am wrong? I can’t make this work, not even for a single .pat file inside the folder, but… It seems to me I accomplished to structure the data fine, based on human logics…

By the way, @AmolShah I had a better look to the .pat files and found out that an annoying character inside some of them was the substitute character (␚), which I now replaced.

Best wishes!

1 Like

Hi Mario,

It’s hard to help you without seeing the previews under the nodes.
There are 2 GetItemAtIndex in an error state.

It would be easier to try on a single FillPattern to begin with and when that will work to add the others.
You can also add your pat file and your graph so that we can see what’s going on.

ha_01.dyn (126.6 KB)

Thank you @Alban_de_Chasteigner!
There goes my board (thought I couldn’t share), still I can’t upload .pat files, but hope you can test it out with anyone around!


Hi Mario,

Longest lacing works like charm to create the Fill patterns but you have an unit issue.

See the difference between the Parse Pat File Watch nodes and yours. (probably Millimeter or Inch to convert to the current project units)

Perfect! I knew it just needed a little tuning somewhere but didn’t know WHERE! :slight_smile:
Very appreciated, thank you very much!


Ok, at the end I came up with this one…
@Alban_de_Chasteigner I wanted to ask you a couple of things:

1- Which node/s are you feeding with your “parse .pat file” node in order to handle several files at once?
2- I noticed not every .pat file (found across the net) is structured with the typical 7 values per row, so I had to do a clumpsy non-programmer adjustment just before the “string to number” conversion. Is your node able to interpret those lines with more then 7 values?
Because this flow is simply “taking the first 7 items” and lose any other information.

I guess I’ll stop bothering you for a while after this :wink:
Thank you very much!

Import several pattern types into project.dyn (105.0 KB)

Hi Mario,

1.The FileSystem.GetDirectoryContents node
The lacing of the Parse PAT File must be set on longest.

  1. The Parse PAT File do some pythonic string operations (regular expression, split at line) and units conversion.
    I didn’t try with non regular .pat files. Can you make a trial or share a non typical pat file ?