Create Named View from object in UCS

Create Named View from object in UCS

ediloreto8W6MG
Participant Participant
300 Views
1 Reply
Message 1 of 2

Create Named View from object in UCS

ediloreto8W6MG
Participant
Participant

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:

 

aCZxErGWzc.png

 

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.

 

 

0 Likes
301 Views
1 Reply
Reply (1)
Message 2 of 2

ediloreto8W6MG
Participant
Participant

Anyone has an idea on how to do it? I couldn't solve it yet...

0 Likes