I’m new to rhino inside and I can’t figure out how to create from within rhino inside wall families of different widths (or depths?) and instances of them inside revit. To be clear: I want to create a number of walls in revit using data from gh, say a list a of curves and a list of floats representing those walls widths, feed all of that into some rhino inside revit components and get those corresponding walls in revit. Also,l would very much like to do this with the basic wall system family.
As far as I know, walls of different widths must belong to different types within the family in revit, therefore I assume I would need to create those family types from the (rhino inside) side, I want to automate this creation of family types of walls of different widths.
Right now I I am running with a crappy solution, that is manually creating wall types of all widths in a given range ( say from 5 to 60 cm ) and then looking for the wall type of the width to pass that types ID to the WallByCurve component.
Is there anyway to do this?
Thank you very much for your help!
WallTypes.gh (12.6 KB)
Does this solve the issue?
Thank you very much for your hasty reply. Unfortunately I couldn’t get your script working for me. the different errors I’m stuck on now are:
transaction starting in line 31 triggers an error about another transaction being currently started and not yet comitted.
I also get the iteration over none type error, this is triggered by the type variable in the for loop, but I am reading correct data in the Type input in the proper GHPython component as I hover over the Type input… ??
3)I am also getting this error: “1. Solution exception:Starting a transaction from an external application running outside of API context is not allowed.”
after this last one I gave up and wrote back to you… XD
also, I’m really interested in learning Revit API for python but can’t seem to find good content as for API documentation in Python (I think there is none…) or tutorials, guides, etc… asince you seem to know your way around any suggestions in this sense would be greatly appreciated.
Thanks for all!
WallTypes.gh (15.2 KB)
Far from the truth, I’ve been doing quick scripts only for two weeks! I still don’t know what I’m doing 99% of the time, and you can tell by looking at the code.
I always try to enable element binding so I tend to leave a specific piece of code by default which might not work in many situations and is basically useless for this, so I deleted it this time just in case.
Try to follow the specific order which I highlight in the groups, I’m sorry I can’t provide a cleaner solution for now (still getting used to transactions).
Does it suit your needs now?
Also, if you want to get started in using the Revit API, Jeremy Tammik’s blog and the Revit API documentation site (watch out for obsolete versions, always check the year in the link) are the go-to places for me. I also google for solutions to the different errors and exceptions I get as I see them.
And obviously the Rhino.Inside-Revit github, python scripts which have been already posted on this forum, plus the webpage that the devs are building (great work btw, keep it up!) based on the github info, which is already a very good source of information.
Translating the C# code you usually see to Python is, at least in my limited experience, just a matter of learning the basic syntax differences between both languages. If you want to take a step further and also include specific libraries and stuff, it might become a more complex matter. Although by the time you get into specifics you would be probably already experienced.
Hope this helps.
Yes! got it to work once!
The problem Im getting is when I re run the script it will crash because the ElementType.Duplicate will get an error of the type: “1. RhinoInside.Revit: The name is already in use for this element type.” because it allreadey created it in the previous run, it will then not generate the type and anything that hangs from there will crash too.
Ok, I think i see where to go from here. Thank you for taking the time to help me and for your advice on content. Best wishes mate!
You can plug a
Data component to the output of the
Duplicate Type component and internalize it. Then, disable Duplicate Type and just modify the rest of the script as you please. So far it works for me, I can dynamically adjust the different wall thicknesses, and also updating the wall curves shouldn’t be a problem either.
Hey, sorry to wreck the hype, but the previous time it actually only half worked.
It created the walls with a type named according to the parametric width input, so that is pretty cool, BUT the actual width was the original in all types…
Does this work correctly for you??? that is baffling…
No prob. Have you set Run to True in the GHPython component?
My procedure is as follows:
- Search for base wall type to duplicate with the panel, enable
Document.ElementTypes and check the specific type.
ElementType.Duplicate. By now you should have the different types you want, although with same width as starting type.
- Set Run in GHPython component to True. Now widths should be adjusted to target widths.
AddWall.ByCurve. You should see walls have correct widths.
If you want to modify the types you already created, you can plug a
Data component (or whatever that can store Revit Wall Type information so that you can point further changes to these Type definitions) to the output from
ElementType.Duplicate, then right click it and internalize that data, then disable
ElementType.Duplicate (otherwise Revit will try to duplicate the starting type again and find that there are already existing types with these names, thus getting an error).
Also make sure to follow a similar, simple data tree structure to the one that I was following, since I didn’t code this script to support complex data tree access. I still need to learn how to work that way with the GHPython components.
import Grasshopper.DataTree as dt
import Grasshopper.Kernel.Data.GH_Path as gp
that is pretty much all you need, the rest is self explanatory in the built in help documentation
however, I try to avoid it as much as possible, compared to python it is quite cumbersome to use tree structure.
Ok now it worked
I baby stepped through this as you explained and this time it did the trick.
Thanks again for your help, you rock!