Modify CropBox of Elevation View

Modify CropBox of Elevation View

grahamcook
Advocate Advocate
9,826 Views
20 Replies
Message 1 of 21

Modify CropBox of Elevation View

grahamcook
Advocate
Advocate

I am having difficulty in modifying the cropbox of an elevation view.  The extract code below will place an elevation marker in a room and then create an elevation off index 0 of the marker.  I then get the existing cropbox and attempt to reduce the height by 3 feet (just as an example).  The code runs successfully (within a transaction) but the result is as per the original cropbox, ie, no change.  When an elevation marker is placed in a room using the User Interface Revit will automatically find the extents of the room and set the crop box accordingly.  I'm wondering if this behavior is overwriting the changes I make via the API?

 

ElevationMarker elevMarker = 
ElevationMarker.CreateElevationMarker(doc, vft.Id, roomCenter, scale);

ViewSection sv = elevMarker.CreateElevation(doc, viewPlan.Id, 0);
doc.Regenerate();

// get the bounding box of the section
BoundingBoxXYZ bb = sv.CropBox;

// by way of example reduce the section height by 3 foot
XYZ max = bb.Max;
max = new XYZ(max.X, max.Y - 3, max.Z);
bb.Max = max;

// set the new bounding box
sv.CropBox = bb;

 

0 Likes
9,827 Views
20 Replies
Replies (20)
Message 21 of 21

Anonymous
Not applicable

Thank you for the code.

As I had mentioned, the min and max of the crop box are assigned but the transform and origin are not changed.

Hence the detail view is not moved (re-positioned) to a new location (It has resized but stays in the same location)

I need to achieve:

 - resize the box - this is possible

 - re-position the box - does not happen though set property is present

 - change transform - does not happen though set property is present

 

Hope my query is clear.  I had given my code in my earlier post.

Any help would be much appreciated.

 

Thanks again for the sample class.  Now the class needs to achieve the other two parts.

 

0 Likes