First of all, I have been researching and googling anything and everything about what I am trying to do here and I am not looking for a handout by any means.
I am trying to create a Dynamo graph and I am having a hard time getting started. I am a relatively new Dynamo user when it comes to creating my own from scratch. I have downloaded many and tried to reverse engineer them over the years but I haven’t had the time to really understand all the nuances of how to work with specific elements. I do have quite the library of scripts that I have written with the help of other posts here and there. (The people that shared their images of their graphs and/or plainly uploaded for direct download should be celebrated BTW.)
My question is: I am wondering if someone could help guide me through writing my first real “from scratch” complex script? I am wanting to create a script that will open a given set of families in my library, creating a subcategory, and then potentially setting certain objects on those subcategories that were just created. That last part would be the icing on the cake actually. If I could even have the ability to mass created subcategories and then automatically have Dynamo/Revit open each family, add the subcategory and then save and close the family beofre moving to the next family would be huge for me. I will upload a dyn with some nodes that I think would be used for your review and comments if you don’t mind helping me out.
I am NOT asking for someone to write the whole thing for me. Just someone I could ask some questions to and maybe give some nudges when needed.
Here is what I think I know, feel free to correct some or all of my current understanding of what I think I need to do. I need to get a folder location or have the ability to select multiple families. Whether that is on a network server locally or from a project with them loaded into already. I am not sure if there are pros and cons to either outside of the obvious things. Like who wants to have to load a bunch of families into a dummy project file just to run a script right? Well if thats the only way its feasible in the end to do what I am trying to do, then so be it.
I do know that I can and should use some nodes from some specific packages and I have them all installed. Crumple, Orchid and Clockwork are a couple that I am looking into. I am not keen on python coding but that may be the correct answer here.I have wanted to learn Python for a long time now.
Before I go any further I should ask if what I am trying to do can even be done at all?
Don’t try and get ‘background opening’ your family documents to be a thing you go after just yet. It makes things much more difficult for any author, and in my experience it will not save any time over the alternatives. Instead build the graph to work on an open file. Focus on making a subcategory first. If you get that you have accomplished half the battle and at least set things up so the people who have to move stuff to a subcategory will have the right subcategories in the document (and spelled right - I once had a case where 3 people were doing this task manually and one of them used a different spelling… which voided all there work).
Also, I believe this will eventually take some C# coding or Python scripting (if only for the second half). Learn the base language (Python or C#) first - this takes a few hours and you can do it from your cell phone during a commute or lunch, as there are dozens of free apps. I would recommend Python first as it ‘works for you’ the most readily. C# helps to scale to other environments and is faster, but your data set (if working with one file at a time) should be small enough that it won’t matter. Stick to CPython or IronPython3 though for security and portability reasons.
Next learn the Revit API - this will require a CPU with Revit installed. If you go thr Python route the Dynamo Python Primer is very well developed for this; as is the Dynamo Primer section.
Now when it comes time for running the graph on all 36171026519 families, use the Dynamo Multi Player from Bird Tools. This tool opens a Revit document and runs a graph on the document for all documents in a list.
Hopefully this helps you get started. I believe the ‘make sub categories’ section of this can be done in a half day; assigning object to said subcategory will take longer.
Thank you for your response Jacob. You have helped me over the years as well on specific other posts that I have made. I appreciate your willingness to assist and not bash. =)
I will take your suggestion and see what I can get done to start.
So after a few days of heavy deadlines in the office I was able to get back to this. Here is my graph currently. Of course it does not work yet but I wanted to post in case someone wanted to take a look and comment and/or suggest how to move forward:
I know the list of subcategories isn’t fully developed to actually create multiple subcategories yet. I am still trying to learn how to get this list to pump in data to create multiple subs without having to duplicate the entire graph pieces individually for each subcategory I want to create.
I think jqroelofs is onto the issue. I am just not sure the best way to attack it.
I am assuming one of the issues here is that I have a list of subcats and I am dumping that list into the Subcategory.ByName node all at once where the node is looking for just one name?
Copy the text of the error message from the Graph Node Manager which can be found in the view extensions menu.
Read what it says CAREFULLY.
… is expecting…
… but got …
Each of the object types in the ‘expecting’ has a matching object in the ‘got’ list. Note that ‘anything’ is a var and stuff like curve is a geometry; however an integer (int) is not a Dynamo color (DSCore.Color), and that in some cases null will be problematic.
@jacob.small I did not know about that Graph Node Manager!. Thanks for that.
I also did not realize I was that close already lol. Sure enough, I added the ARGB node and set all of the subcategory colors to 0,0,0,0 (see updated graph). Is this the best and preferred way to select color in Dynamo or is there a better and more efficient way to do it?
I did notice that the subcategories were created however the node setting the cutline weight value was not used in the family. Any idea why that might be?
This way works and when I don’t want any variation in color is usually what I use (or Color.ByARGB(255,0,0,0). You were actually sending Colors of (255,0,0,0), or Black - all 0’s would be invisible due to the 0 for Alpha which would be entirely see though. If prefer to select a color rather than assigning RGB values you can look into the Color Palette node.
Not offhand - try opening the custom node, copying the Python node, closing the custom node, and then paste the Python nto your canvas. Double click it to edit it and check to see if the “cut line weight” input should be a double, integer, string, or maybe a graphic style or other object type.
It appears that both the cut line width and projection line weight python code is looking for an integer. I believe that’s what i fed into it so I am confused =)
I am now trying to break down the most efficient way to have several colors set to specific sub-categories now while I also try to figure ouot why the line weights are not setting correctly yet.
One obvious way to do it would be to duplicate the nodes as many times as I need different colors and remove subcategories in those specific copies where the color needs to be different. Is that the most efficient way in your opinion?
Copy the python node over and check the source code; something inside that node should tell you where/how it’s setting the cut line weight. My guess is there is a ‘try’ statement followed by something along the lines of ‘except: pass’, which is suppressing the error.
Worth a try; that said I don’t see anything preventing an exception so it may be an API issue. Which Revit version are you in? Can you post your current .dyn and an rvt to run this in?