Thursday, October 10, 2013

TREES FOR INSTANCE

This is going to be a marathon.  I spent the whole long weekend climbing trees ... sort of.
I started this a while ago.  It was inspired by a post on Revit Swat.  I had the idea of using a rectangular rig for the leaf, so it would maintain a constant shape instead of getting fatter as it got shorter.



It's an adaptive rig so I can use it in a repeater (the branch)  I use a reporting parameter to extract the length of each leaf instance and use it to drive the width.  (W=L*F where F is a width factor)   Add a few rungs, hang a couple of splines and use them to make a surface.  Hey presto: a scalable leaf.



The branch is copied straight from Revit Swat, as far as I could make out.  Again it's a 2 point adaptive.  Connect the 2 points with a ref line & host a point at the mid-point.  Show all ref planes.  Place a point on the horizontal plane and give it an offset.  Show all ref planes of this new point.  Set the work plane on axis, place 2 more points, offset these to either side.  Use spline-through-points to
create 3 curved ref lines. 

Select these & Divide Path.  Place a leaf on one side.  Repeat.  Do the same for the other side.  We have a branch.  A couple of points here.  You will get an error message after the repeat command because it's impossible to make a leaf at the ends of the line (it would be zero length).  To avoid this you need to set beginning & end indents for each of the repeaters.  Once this is done it will be possible to control the number of leaves with a parameter. 



So the next stage is to place branches in a tree.  All these families are "Generic Model Adaptive" with the category changed to "Planting" (and "Shared" unchecked)  I used a loft based on 2 circles for the tree trunk.  Then more circles to create repeaters for the branches.  The end points of the branches were set to "vertical on placement" basically so that they don't fall over on their sides.



One of the advantages of making trees from Revit native geometry (as opposed to 3d CAD trees embedded in Revit families) is the ability to apply material parameters.  I decided to have subcategories for global control of materials, & parameters to act as overrides where needed. 



I have instance parameters for the base radius & height of the trunk.  These exist in the basic tree and are linked through to matching perimeters in the final family.  I ended up with a family where the overall height is set by the inbuilt type parameter, but the trunk shape can be varied using instance parameters.  



You may have noticed that the leaf has changed.  I was struggling with displaced geometry at this point and ditched the rectangular rig.  By now I have a family that has ballooned to 6mb.  I was curious what would happen if I exported this to dumb CAD geometry and then embedded this in a planting family.  This did indeed reduce the file size, but at the price of making materials harder to control & losing the variable proportions. 



Have you ever noticed that file sizes in Revit fluctuate for no apparent reason ?  Anyway it turns out that my Revit trees settled down to around 1Mb later on.  So I dumped the CAD idea.  Instead I went for simpler branches in 3 rows.  This eliminated one level of nesting.  Just make surfaces directly from the 3 curves in the branch family.  I also added one more circle to the trunk to give it a subtle curve. 



I was pretty chuffed with this family.  Sadly attempts to control the slenderness of the branch/leaf created unpredictable geometry ... groups of branches flying into the air etc.  Couldn't understand that.  Experimented with a "ring of branches" family nested 3 times.  Also unpredictable.  Eventually I made the family again from scratch and achieved a more slender version.  In this final image most of the trees are the second version.  The trees in the background to the left are the first version.  You can also see one or two aborted experiments way back.



Second morning and I went back to the original leaf idea and rebuilt it from scratch.  For some reason it decided to behave itself this time.  Gave me a family that looks a bit like a cycad.  Used to have those in my garden in Zimbabwe.  Fascinating plants. 



I was about to nest this to enable scaling when I realised that I had all the control I needed via the adaptive family parameters. 



All good so I decided to move on.  What about a deciduous tree ?  Maybe I could use a divided surface and curtain panels to scatter triangular shaped leaves around a canopy.   Just for fun I made the canopy revolve from an old fashioned spline (not the spline through points type)



For the divided surface I used bent triangles.  Made a very simple curtain panel family, loaded it and added a trunk.  It works,  probably could add all kinds of embellishments & variations, but for now I just added a "resolution" parameter to control the number of surface divisions (in both directions).  Eventually I rigged this up to adjust automatically to the built in "height" parameter that controls scaling of planting families.  That way different sizes of tree have more or less the same leaf size.



So let's get back to the idea of an instance parameter for random variation of sizes.  You have a tree family (A) nested inside the final planting family (B).  Link the Height parameter in A to an instance parameter (Ht) in B.  Create a number factor called F.  Use the built in Height parameter of family B, multiplied by F to control Ht ... ie the Height parameter of family A.  End result ... The inbuilt Height parameter works.  You can create families with typical heights.  BUT you also have a scale factor "F" which acts as a a multiplier factor. 



Place a few trees.  Fire up randomiser (free plug in from DP Stuff) fill in the various fields, set min & max values, press randomise.  The trees randomise around the typical height.  I did this with an OOTB RPC family.  Now I'm not crazy about RPCs, they look a bit flat ... mostly because they are flat ... they look OK from street level, but with a high camera angle, not so good.  For better trees, use 3D max, or maybe Lumion.  But there are lots of times when we want to have trees directly in Revit.  RPCs are one way to do this.  Random variation in heights will help to make them more convincing.  Ramdomising the rotation angles would also be good. 

Turns out this is also very easy to do.  Just rotate family A slightly & create an angular dimension between the family and the Centre L/R reference plane.  Label this with an instance parameter.  All done.



Now we come to a big drawback with the adaptive component based trees.  Can't embed symbolic lines or detail components.  No visibility controls for selectively hiding geometry in plan view.  This is a big drawback if you want to use the mass modelling tools for regular familes (planting, plumbing, furniture)  There are 2 good reasons for using symbolic representation in orthographic views.  First to reduce processor load & speed up regeneration times; second to give a cleaner graphic representation.  Both are especially important with complex curvilinear forms.  Exactly the kinds of shapes where the mass modelling tools would help. 

Enough of the moaning.  Let's get back to RPC families.  Here we do have symbolic representation.  It's embedded in a planting family called "xxx Base" where xxx could be "Deciduous" or "Tropical" etc.  It's one of 2 objects in the RPC family, the other is a "render appearance".  It's the object we see, and somehow it links to the render appearance stored in any of the folders listed under the Rendering tab of "Options".  Whenever you select one of these appearances, the object you see in the project also changes shape in an appropriate manner. 



You probably know all this.  The point is that the 2 objects scale up and down together.  So a 10m Scarlet Oak will have a plan symbol twice as big as a 5m Scarlet Oak.  The downside is that you only have one symbol to represent all the different deciduous trees.  If you have a tall thin tree & a short fat tree, one of them is going to have an inaccurately sized plan symbol.  It would be better if the plan symbol was separated from the RPC object.  Then perhaps you could a different scaling factor to the plan symbol for each tree type.  You could also have a number of different symbols loaded into the family so that different tree types could be identified by their plan symbol.  A nice idea, but does it work ?  I did a bunch of tests with simple planting families, just a cylindrical extrusion.  Two separate instances nested into the same blank family.  I worked out how to control the two instances separately. 



Next step was to do the same with plan symbols.  It's a lot of work & you have to link each type's parameters, one by one but I got there in the end.  Struggled a bit with the proportional scaling of plan symbols, but got there in the end.  When I got really stuck I went for a lie down & scribbled a bit of algebra on a scrap of paper.  The answer was counter-intuitive (for me at least) but it seems to work. 



I spent a couple of hours converting old CAD plan symbols into Revit symbolic lines.  Did all this in a temporary RFA file and copy-pasted the end results into my "deciduous base" families.  I made quite a few and loaded 5 of them into my final trial which takes all the types in "RPC deciduous" and maps them into my host family.  Perhaps I need a diagram. 



Going to finish with a render showing the difference between standard & randomised families.  I'm quite proud of this.  Useful in shaded views & in renders.  The correct sizing of plan symbols is another breakthrough.  Combined, these 2 customisations make for much more effective RPC trees.  The adaptive component families were interesting experiments, but the RPC work has a much broader application.



Still a bit rough at the edges, but you can download my modified RPC deciduous along with a pdf summary below. (link to follow)





 

10 comments:

  1. Andy,

    Another interesting post! I have a similar approach for our RPC planting family at work. I delete all the symbolic lines from the rpc family and add a nested family with a simple version of the tree in plan. each circle has a parameter to control as instance parameter, one of the things i added is critical root zone, many of our projects requires to show it for documentation. the other thing i modified is the height parameter from type to instance. again, it is for accurate documentation, we may have oak trees in many locations with different heights. making different height with different sizes is a stupid way to do it. Still dont know why the factory didnt think about it.

    ReplyDelete
  2. Hi! nice post,
    In the last diagram are all the same family? or you need a new family for every type?
    Is it posible that you post one of these family to check out? thanks!

    ReplyDelete
  3. Fascinating stuff Andy,
    The independant height and width parameters looks incredibly useful - I have struggled with this for years. I'm not sure I quite understand the trick you used but I'll give it a go.
    One advantage of working in the middle east is you get to use all those palm trees! That curtain panel on a spline revolve idea looks very clever for deciduous trees. Maybe you could combine that with scaleable splines to get tree variations, as per my post on scaling trees: http://revitcat.blogspot.com.au/2013/07/revit-scaleable-spline-tree-family.html

    ReplyDelete
  4. Hi Manuel
    Yes it's one family. Basically one of the default RPC families from Autodesk with customization by me so that the plan symbol matches the RPC object for each type AND instance parameters so you can more easily randomize scale and rotation.
    Yes I will post this file very soon. Just need to clean it up a little. Stay tuned.

    ReplyDelete
  5. Hi Tim & Phil
    Thanks for comments. Good to know other people have been thinking along similar lines. Took me 3 separate sessions spaced out over time to think this one through. I will post the file shortly. Perhaps someone else can convert one of the other OOTB families :-)

    ReplyDelete
  6. Excellent post Andy, thanks for sharing this.

    Will the family be available for download anytime soon? Would love to check it out if so!

    Ben

    ReplyDelete
  7. Sorry guys. Getting a bit carried away with pumpkins at the moment. Will upload soon, I promise.

    ReplyDelete
    Replies
    1. Excellent, thanks Andy! Appreciate it if you could send out a Tweet once you've uploaded.

      Look forward to seeing the pumpkin creations as well, last years were ace!

      Delete
  8. Andy did you ever upload these Revit trees? - just came across your post now, would like to study how you set up these files

    ReplyDelete
  9. See my November post "Tree Family Download" for the families. Sorry but the only way to get them into 2012 would be to start from scratch. Unlikely.

    ReplyDelete

I've been getting a lot of spam so had to tighten up comments permissions. Sorry for any inconvenience. I do like to hear from real people