View Crop Region Shape Manager of Elevation View locking the crop view

View Crop Region Shape Manager of Elevation View locking the crop view

karol.wozniak
Contributor Contributor
3,358 Views
3 Replies
Message 1 of 4

View Crop Region Shape Manager of Elevation View locking the crop view

karol.wozniak
Contributor
Contributor

Hi,

I have a small add-in, which creates an elevation and places it on a sheet. Everything works fine and is generated as expected.

Unfortunately, the elevations created by this method lock the control of their extent from within the plan view (i.e. these small blue circles, as per attached screenshot).Control circles lockedControl circles locked

The way to unlock it is to edit the crop of elevation with 'Edit Crop' and confirm with the green tick (i.e. 'Finish Edit Mode'). *Note: This does not even require any changes to the shape.Finish Edit ModeFinish Edit Mode I have no problem doing this, but it may be confusing for other users, or sometimes simply forgotten locking the elevation for future users.

Below is the code generating the issue.

 

...

doc.Regenerate(); // Create elevation using the marker ViewSection elevationView = marker.CreateElevation(doc, newVPId, i); // Set the crop to elevation accordingly ViewCropRegionShapeManager crsm = elevationView.GetCropRegionShapeManager(); crsm.SetCropShape(cl_0_2); // Refresh the document doc.Regenerate(); // Create the location object for the elevation var locationElev = new XYZ(elevX, elevY, 0); Viewport vPortElev = Viewport.Create(doc, sheet.Id, elevationView.Id, locationElev); // Refresh the document doc.Regenerate();

Is there anything that could be done to solve this issue? Or maybe it's an internal Revit bug?

Thanks

 

OS: Windows 10

Revit: 2018

0 Likes
Accepted solutions (2)
3,359 Views
3 Replies
Replies (3)
Message 2 of 4

Moustafa_K
Collaborator
Collaborator
Accepted solution

hi,

I recall this happened to me when i created the elevation bounded to Scope box. it introduced the same behaviour. however, try to set the view depth based on Boundingbox and not CropShapManager

something like this:

var vbx = room.get_BoundingBox(null);
//then change the Minimum and Maximum to identify the the Elevation start/End Point and the Depth
//set the cropbox option true
elev.CropBoxActive = true;
//Remember to Regenerate the document here
doc.Regenerate();
//finally assign the boundingbox to the view.
elev.CropBox = vbx;

hope that helps

 

 

Moustafa Khalil
Cropped-Sharp-Bim-500x125-Autodesk-1
Message 3 of 4

karol.wozniak
Contributor
Contributor

Hello,

Thanks for the tip. This should actually solve the issue. Although, I do not currently have time to rewrite my code. The only alteration I have to make is to cut the room bounding box in half, so the internal elevations are positioned in the middle of the room.

But most importantly, you made me realise I've done something stupid - I've not been using the room bounding box to find the crop shape. Instead, I've been using the room boundary curves loop and manually finding the XYZ min and max using the room elevation and height (for the Z coordinate). I did not realise this is built-in into the room boundary box property. The only justification I have for this blunder is that it was my first exposure to Revit API.

Thanks again for help. I will update the progress and accept your answer once I rewrite the code and it works.

 

Here's a sample of the aforementioned code:

 

 // Create elevation view bounds for elevation pairs 1, 3 and 0, 2
List<Curve> lc_1_3 = new List<Curve>();
List<Curve> lc_0_2 = new List<Curve>();

XYZ p1 = new XYZ(startX - 0.5, startY - 0.5, roomLev.Elevation - 0.5);
XYZ p2 = new XYZ(endX + 0.5, startY - 0.5, roomLev.Elevation - 0.5);
XYZ p3 = new XYZ(endX + 0.5, startY - 0.5, roomHeight + roomLev.Elevation + 0.5);
XYZ p4 = new XYZ(startX - 0.5, startY - 0.5, roomHeight + roomLev.Elevation + 0.5);

XYZ p5 = new XYZ(startX - 0.5, endY + 0.5, roomHeight + roomLev.Elevation + 0.5);
XYZ p6 = new XYZ(startX - 0.5, endY + 0.5, roomLev.Elevation - 0.5);

lc_1_3.Add(Line.CreateBound(p1, p2));
lc_1_3.Add(Line.CreateBound(p2, p3));
lc_1_3.Add(Line.CreateBound(p3, p4));
lc_1_3.Add(Line.CreateBound(p4, p1));

lc_0_2.Add(Line.CreateBound(p1, p4));
lc_0_2.Add(Line.CreateBound(p4, p5));
lc_0_2.Add(Line.CreateBound(p5, p6));
lc_0_2.Add(Line.CreateBound(p6, p1));

CurveLoop cl_1_3 = CurveLoop.Create(lc_1_3);
CurveLoop cl_0_2 = CurveLoop.Create(lc_0_2);

where startX/Y and endX/Y are smallest and biggest XY coordinates of room boundary respectively.

As you can see, I've been using the same CurveLoops for the opposite elevations.

 

Regards,

Karol

0 Likes
Message 4 of 4

karol.wozniak
Contributor
Contributor
Accepted solution

Right, I found the solution. Because I use a curve to create an Elevation (CurveLoop to be specific), the shape is not recognised as rectangular shape (even though it is rectangular). Adding:

 

// Remove non-rectangular boundary
crsm.RemoveCropRegionShape();

solves the problem. It is equivalent to 'Reset Crop' button.