Crop box


#1

i try to create a crop box for an axonometric view.

right now i am failing to create the correct bounding box!

what i did so far:

i created a solid from panels

for the solid i created a axonometric view eyepoint targetpoint. where targetpoint is the locationpoint of the panel.

with that i went into python.

i imported the bounding box of the panel

and the panel.

from the panel i extracted the location point (mid)

from the bounding box i took height and width.

then i assigned the (in my opinion) correct values to the cropbox.

but nope, sometimes the cropbox fits, most times not!

any clue?

pics are: what i expect, what i get, the python

 

right wrongpython


#2

<pre style=“color: #000000;”>#Copyright© 2014, Konrad Sobon

@arch_laboratory, http://archi-lab.net

import clr
clr.AddReference(‘ProtoGeometry’)
from Autodesk.DesignScript.Geometry import *

Import ToDSType(bool) extension method

clr.AddReference(“RevitNodes”)
import Revit
clr.ImportExtensions(Revit.Elements)

Import DocumentManager and TransactionManager

clr.AddReference(“RevitServices”)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

from System.Collections.Generic import *

Import RevitAPI

clr.AddReference(“RevitAPI”)
import Autodesk
from Autodesk.Revit.DB import *

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

#The inputs to this node will be stored as a list in the IN variable.
dataEnteringNode = IN

linkElements = []
for i in IN[0]:
linkElements.append(UnwrapElement(i))

rvtLink = UnwrapElement(IN[1])
transform = rvtLink.GetTotalTransform()

elements = []
for i in IN[2]:
elements.append(UnwrapElement(i))

viewName = IN[3]

#get ViewFamilyType for a 3D View
collector = FilteredElementCollector(doc)
viewTypeColl = collector.OfClass(ViewFamilyType)
for i in viewTypeColl:
if i.ViewFamily == ViewFamily.ThreeDimensional:
viewType = i
else:
continue

“Start” the transaction

TransactionManager.Instance.EnsureInTransaction(doc)

#define bounding box enclosing all elements
bboxMin, bboxMax = [], []
for i in linkElements:
bboxMin.append(transform.OfPoint(i.get_BoundingBox(doc.ActiveView).Min))
bboxMax.append(transform.OfPoint(i.get_BoundingBox(doc.ActiveView).Max))
for i in elements:
bboxMin.append(i.get_BoundingBox(doc.ActiveView).Min)
bboxMax.append(i.get_BoundingBox(doc.ActiveView).Max)
minX, minY, minZ, maxX, maxY, maxZ = [], [], [], [], [], []
for i, j in zip(bboxMin, bboxMax):
minX.append(i.X)
minY.append(i.Y)
minZ.append(i.Z)
maxX.append(j.X)
maxY.append(j.Y)
maxZ.append(j.Z)
bboxMinX = min(minX)
bboxMinY = min(minY)
bboxMinZ = min(minZ)
bboxMaxX = max(maxX)
bboxMaxY = max(maxY)
bboxMaxZ = max(maxZ)
#create a bounding box
bbox = BoundingBoxXYZ()
bbox.Min = XYZ((bboxMinX - 0.1), (bboxMinY - 0.1), (bboxMinZ - 0.1))
bbox.Max = XYZ((bboxMaxX + 0.1), (bboxMaxY + 0.1), (bboxMaxZ + 0.1))
#create 3d View
view = View3D.CreateIsometric(doc, viewType.Id)
view.Name = viewName
view.SectionBox = bbox

“End” the transaction

TransactionManager.Instance.TransactionTaskDone()

#Assign your output to the OUT variable
OUT = 0
Try this: I think inputs are the geometry. :slight_smile: It deals with setting the crop box and it will create a new 3d view I think so you would have to add that view target etc.


#3

Hi guys,

Just to add to the discussion, there are a few default nodes for axonometric view creation - “AxonometricView.ByEyePointTargetAndElement” and “AxonometricView.ByEyePointTargetAndBoundingBox”.

I did a quick test on how they perform and it seems that the one taking an element input functions well but unfortunately has no options for controlling the crop box size.

The second one that takes a bounding box adjusts the crop box( wrongly) and fails to apply the crop to the view or isolate the elements.

2015-04-16_11-16-03

view by element:

2015-04-16_11-16-27

view by BBox:

2015-04-16_11-16-35

This is on R15, Dynamo 0.8 stable. I’m not sure if the two problems are connected.


#4

Just a small addition to this discussion:

A while back I needed to make slight adjustments to a large number of view cropboxes for a fabrication workflow. The node (View.ResizeCropbox) is available in package Clockwork.


#5

just to contribute too.

my solution went like: create an axonometric view.

revit will automatically create a copbox sized 100x100x100 (in metric units)

the cropbox will be centered to the elements in the view

create a viewfilter.

after that create a bounding box for the active elements in the view.

resize the crop box to width and height from the boundingbox.

after that you can export to img and get perfect results

@dimitar: i guess that the ootb cropbox has an error in unit conversions???

same problem persists for the creation of sections. there the cropbox is misplaced too.

 


#6

I don’t think its unit conversions because I always do mine manually and I would still have problems with this workflow. I think its because Dynamo defines origin differently than Revit. Just a wild guess, but I was testing reporting coordinates relative to Project Origin and/or Survey Point and none of them aligns with what is being shown in Dynamo. :frowning: I am a little bummed out. Maybe I should stop converting my units because now, Dynamo is unitless, but I just don’t know how that works. :frowning:


#7

konrad, the unitless dznamo 8 is failing too.

my first approaches in changing cropboxes whre in 0x7xxx

when i tried 0x8xxx i got other but wrong results.

i think there is a conversion bug in one of the dynamo functions pertaining views in general.