fill pattern operations

image by archi-lab.net

Every now and then I find myself scrolling through the Dynamo Forum looking for things to do. I know what you are thinking now: I must be bored as hell. No, I am not. I just always found interesting problems on the forums, hence I am drawn to them. Keeps my Dynamo skills sharp too.

However, I have to say that for the last few months it has been a struggle. I am probably going to sound like an old grumpy man, but boy did the Dynamo Forum change…or perhaps I changed. I used to be able to get into the office in the morning, get a cup of coffee, pop that bad boy open, and instantly find a few questions that I could answer. It was kind of my morning ritual. It got me going in the morning, stretched my brain a little bit if you wish. Now? I am having a difficult time finding any interesting questions. They are all same old, answered questions. I cannot tell you how many times I have seen someone ask if we can “edit the visibility graphics (VG) for linked models”. No. Sorry. No can do. A 2 seconds search would have told you that. Why are you asking again? Agrrrr. I am so mad.

I don’t know who am I mad at here though. Is it the new users? Maybe, but they are new. They are bound to have the same questions I once had. I can’t be mad at them. What about the old timers? Guys and gals that I came up with. I think they learned their lessons and moved on. Or, perhaps, just learned how to google shit before asking on the forum. LOL. Anyways, I think I am really mad at the platform they are inheriting from our generation. The only reason that people still ask about VG, is because it’s still not possible. When will you fix this Autodesk? It’s been two decades.

End of rant.

So, nowadays, when I scroll the forum, it’s usually in search of something that I haven’t done before. Something that I can add to archi-lab.net. Usually some new custom nodes etc. I mean if we are not updating our packages, then how will Dynamo users survive? The OOTB nodes ie. RevitForDynamo package grew by Element.Delete node in the last two years. Great job killing that project too. Luckily for everyone, there are still some great custom packages out there, that people care about, and add some new stuff to. We will survive! Shout out to @a_dieckmann @60secondrevit to name the two of the best!

Anyways, here’s some new components, for quite a simple workflows. These will allow you to filter different kinds of Fill Patterns, rename them and delete them if needed. I guess the usefulness of these lies in situations where if by accident your model ends up with tons of new imported patterns, you would be able to delete them or rename them.

Here’s how to rename a Fill Pattern:

The interesting thing about this particular small workflow, and also part of the issue that was raised by the user on the forum, was that “Solid Fill” pattern cannot be renamed. This is a Revit API limitation, where “Solid Fill” is literally the ONLY Fill Pattern that cannot be deleted/renamed. I am guessing that the reason for that is to make sure that a Revit model has at least one consistently named Fill Pattern. That name is locked. That’s why we have a node below where we fill out “Solid Fill” out of the list. I don’t think we can do anything with them, so we must isolate them.

Here’s how to delete some fill patterns:

Here’s how to use the Fill Pattern Target (Drafting, Model) to potentially filter it even more:

Of course all of the code for these new components is posted to archi-lab GitHub repo. That code is written in C#. I understand that some people might think that it makes it really hard for others to dissect and make use, but I actually think that you can easily grab snippets of that code and use it in things like Macros. Macros can be a great resource for experimenting with Revit API’s. Go use them!

Just in case you think that Python code is more valuable, here’s some of the code that I wrote when creating the above nodes:

These nodes can be found in the following package version:

UPDATE 01/10/2020:

Keith asked in comments if it was possible to obtain information about the Fill Pattern. Here’s the info he was looking for:

As a matter of fact it is possible to obtain that info, but it’s as usual not straight forward. So first of all, we need to get a FillPatternElement. They are kind of an container for the actual Fill Pattern. Once we have that we can get the FillPattern object from it. For the most part what you see and use in Dynamo are actually FillPatternElements, since they are what is needed to set Filled Region patterns etc. Anyways, once we have the actual FillPattern object we can query it for the above properties:

  • Name: that’s pretty straight forward. It has a property called Name.
  • Parallel vs Crosshatch: that’s a little trickier. So Fill Pattern will have a property called GridCount. If that is set to 2 that means that we needed 2 lines to create the pattern so it’s a Crosshatch. Otherwise, if that is set to 1 then we are dealing with Parallel lines.
  • Angle: again a tricky one. Assuming that we have at least one GridLine (parallel) or two (crosshatch), we can grab the first one from the list and query it for an Angle property. Bear in mind that this would be returned in Radians so we have to convert back to Degrees.
  • Line Spacing 1: this is another tricky one. So again, assuming that we have at least one GridLine we can check it for an Offset property. Bear in mind that this would be returned in internal units so Decimal Feet. We have to convert it back to mm.
  • Line Spacing 2: this is another tricky one. Same as above applies, but this time we grab the second line, and again have to convert to mm.
  • Orientation: this property is pretty straight forward, but the issue is that it’s stored internally as an Enum, that has a completely different name than what we see in the UI. I matched them to the UI and return that to make it easier on the user to understand.

The above was created from the following sample Fill Pattern:

I hope this helps!

Support archi-lab on Patreon!

14 Comments

  1. Jeremy says:

    I have been trying to solve packing views on sheets with python bin packing algorithm for a couple years. If you ever got really board that’d be cool :) I think I got as far as adding this into dynamo to try it https://github.com/secnot/rectpack but couldnt get outputs to use, also had to add the library to refer back too. Also Miscellany and refinary tool kits were close but didnt have options to not rotate rectangles. Basically you’d have a bunch of views and that’d pack on sheets not over lapping and once a sheet was full it would create another to keep packing. I’ve struggled haha.

    • Hahaha, bored but not “that” bored. LOL. I mean, I did some automatic drawing layouts on sheets before, but never used the packing algorithms. The thing that I struggle with here, is that in architecture – where I worked for a few years – that kind of drawing packing would not be useful anyways. As far as I remember, we always spent a lot of time “planning” sheet layouts so that each sheet would convey all of the needed information for a specific part of the building. It was never a problem of packing as many drawings as one can possibly fit on a sheet, but rather fitting the details, legends, notes that are referred to in some floor plan or section. Sure, towards the end of the drawing set, we would have just misc. details, and we would pack these as tightly as possible, but even then, they had to be organized by the type of detail they were ie. curtain wall details, masonry wall details etc. So what I am trying to get at, is that a packing algorithm might be solving an issue if the issue was that we were wasting paper space by not efficiently packing drawings on a sheet, but i found that this is actually almost never an issue.

  2. Jeremy says:

    haha I see what your saying. But this would be purely for my curtain wall window elevation schedule script. Elevates all curtain walls numbering by level and dimensions but then they just need to be fitted on a sheet to complete things. Also I had 24 different types of bathrooms the other day that I could automate elevations, floor plans and 3Ds (thanks to your nodes I think, cheers :)) and pack on sheets but with no logic, with those situations and most of all curtain wall window elevation scheduling it’d be amazing. Due to the windows being 1:50 scale and quite a few could fit on a sheet. I know it wouldn’t pack perfectly but there would just be some minor alignment after. I know another company has done this with python but his algorithm was to move the view on the sheet till it intersected with a corner and then place the other and move till it intersects. Bin packing would be ultimate though.

  3. Keith Wilkinson says:

    Hey Konrad,

    Is there any way to access the settings for a fill pattern? I’d like to be able to generate names based on these values but currently can’t find any way in Dynamo of getting these values…

    • Hey Keith,

      Yes, you can get these properties. Please check out an update to this post and an image with a host of new nodes that I added to archi-lab.net to facilitate extracting this information.

      Cheers!

      -K

  4. Thomaz Yuji says:

    Hey Konrad!

    What about creating new fill patterns? I know Zebra package can create .pat files by outputing string values, however, what about duplicating some patterns and changing line spacing for example? Is that possible?

  5. Jason L says:

    Hi Konrad,

    I was using some of your Fillpatterns nodes but now after I formatted and went for Revit 2022, I downloaded archi-labs package but cannot find them? Could you please advise under which package version I can find them?

  6. Alejandro says:

    Currently attempting to use this code but cannot find the FilledPatterns.Target node in the archi-lab package. Any advice?

  7. Albert says:

    How can I filter all fill pattern with same prefix and rename

  8. mahdi habibollahi says:

    hi
    I installed your package but i can not use it completely .Do you have a video that explains the use of your package?

Leave a Comment