Rotating Elevation CropBox

Rotating Elevation CropBox

miketurpin_innovatingfutures
Enthusiast Enthusiast
371 Views
1 Reply
Message 1 of 2

Rotating Elevation CropBox

miketurpin_innovatingfutures
Enthusiast
Enthusiast

Hi All,

Wondering if anyone can help shed some light on rotating cropboxes in an elevation view?...

I'm sure its something to do with coordinate systems but feel like ive tried everything so far.

 

I can get the cropbox to rotate 180 degrees in a couple of views but never in all of them, it seems the rotation isnt using the correct center point in some views.

 

Basically I am trying to find all of the elevations which have the word rotate in the viewname.

I then want to create a callout of these elevations with the same cropbox extents.

This is the bit i have no problem with.

Next i try and rotate the cropbox of the new callout 180 degrees so that its upside down. I can do the rotation but it rotates around a different center point in every view. How can i find the center point of the view to rotate around?

 

Any help greatly appreciated

 

Transaction t = new Transaction(doc);
t.Start("spin");
foreach (View v in views)
{
if (v.ViewName.Contains("rotate")) { XYZ top = v.CropBox.Max; XYZ bottom = v.CropBox.Min; View newsec = ViewSection.CreateCallout(doc, v.Id, v.GetTypeId(), top, bottom); newsec.CropBox = v.CropBox;
newsec.ViewName = v.ViewName + "New";
FilteredElementCollector fec = new FilteredElementCollector(doc);
Element TheBox = fec.WhereElementIsNotElementType().OfCategory(BuiltInCategory.OST_Viewers).ToElements().Where(e => e.Name == newsec.ViewName).First();

XYZ center = 0.5 * (bottom + top);
XYZ centerPlus = center + XYZ.BasisY;
Line axis = Line.CreateBound(center, centerPlus);
ElementTransformUtils.RotateElement(doc, TheBox.Id, axis, Math.PI);
}
}
t.commit();
0 Likes
372 Views
1 Reply
Reply (1)
Message 2 of 2

thomas
Advocate
Advocate

Hi Mike

 

I hope you are well. Its going to be a problem with your axis line. You need to make the axis you are using to generate the line endpoint (i.e. the axis pointing towards you - you can't assume XYZ.BasisY is always normal to the view plane) relative to the view plane. This may explain why you are getting seemingly inconsistent results. 

0 Likes