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:
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!