Rotating Elevation CropBox
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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();