How to control the offset of non-rectangular crop boxes through Dynamo

I am working with a graph that will process the active view, analyze all of the rooms inside that view, copy-as-dependent the correct amount of views (One view for each room), and then create a crop-box around those rooms inside of each view. The problem here is that I need the crop-box to have an offset, but the crop boxes are non-rectangular and so simple scaling or normal offset mechanics do not work. I have tried normal crop-box offset nodes, and a few various other methods, and so far nothing has worked. Any suggestions?

I have included the graph for download, as well as a picture of the graph. Also included are pictures of what I would like to happen, and what actually happens. The main packages I used were Springnodes, Clockwork, Archi-lab, and Lunchbox.

Graph Download : http://www.filedropper.com/roomviewdependentnooffset

Result I would Like: http://s21.postimg.org/gdep0hdfr/Intended_Result.png

Result I get: http://s30.postimg.org/9c1atjqpt/Result.png

Graph Picture: http://s18.postimg.org/ibz8l6dsp/Current_Graph.png

 

 

Eric,

Have a look at CurveLoop.CreateViaOffset(CurveLoop, double, XYZ) where CurveLoop is the original polyline (or curve loop as revit referes to it), double is offset distance and XYZ is a direction vector in which you want to offset the curve.

I am mentioning this method specifically because I am guessing that what you get from each Room when you query its boundaries is a CurveLoop. Using this method is the next logical step.

Good luck!

Hey Konrad, Just tried CurveLoop.CreateViaOffset and I keep getting an error saying that <type’ object has no attribute ‘CreateViaOffset’>. CreateViaOffset also does not come up as a recognized term in the Python coder. Is there some package that I am not importing that I should be? Thanks, Eric

EDIT: Turns out CreateViaOffset is in Revit 2015 API, so it is now getting recognized. However, I am getting a “expected CurveLoop, got line” error, even though the script ran off of a curve loop before.

Here’s my current code.

TransactionManager.Instance.EnsureInTransaction(doc)

for area in areas:

segments = UnwrapElement(area).GetBoundarySegments (SpatialElementBoundaryOptions())

loop = CurveLoop()

for segment in segments[0]:

loop.CreateViaOffset(segment.Curve, 4, vector)

vcrShapeMgr = UnwrapElement(views[i]).GetCropRegionShapeManager()

vcrShapeMgr.SetCropRegionShape(loop)

i = i +1

TransactionManager.Instance.TransactionTaskDone()

 

This is a late reply. I am guessing that you might be getting really short lines when trying the offset tool. Try debugging this solution by running it on a single room or just a few of them so you can see what’s going on. Also, you might just be better off by running the first part that gets you boundaries, then using Dynamo geometry kernel to do the geometrical operation of offsetting as I am guessing that Dynamo might actually be better offsetting curves than Revit is. Then you would have part two of Python code and just convert them to CurveLoops and set the new CropBox.