Message 1 of 2
Create Named View from object in UCS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm trying to create named views from objects (for example a rectangle). Right now I'm using the object extends to get the view's centerpoint, widht and height using the following code.
public static ViewTableRecord CreateFromEntity(Entity entity)
{
ViewTableRecord viewTableRecord = new ViewTableRecord();
AssignEntityCoords(entity, ref viewTableRecord);
return viewTableRecord;
}
private static void AssignEntityCoords(Entity entity, ref ViewTableRecord viewTableRecord)
{
Extents3d ext = entity.GeometricExtents;
Point2d centerPoint = new Point2d((ext.MinPoint.X + ext.MaxPoint.X) * 0.5, (ext.MinPoint.Y + ext.MaxPoint.Y) * 0.5);
double width = Math.Abs(ext.MinPoint.X - ext.MaxPoint.X);
double height = Math.Abs(ext.MinPoint.Y - ext.MaxPoint.Y);
viewTableRecord.CenterPoint = centerPoint;
viewTableRecord.Width = width;
viewTableRecord.Height = height;
}
This is working great when using the WCS, but if I have a rotated rectangle the view is created like this:
I have tried applying trasformation to the entity before creating the view but didnt get any luck:
Matrix3d transf = Editor.CurrentUserCoordinateSystem; // Using a UCS
Entity newEntity = entity.GetTransformedCopy(transf);
ViewTableRecord view = CreateFromEntity(newEntity);
In short, I am trying to make a view that aligns with UCS. This can be done easily from the view manager but it becomes tedious to make many views.