i am trying to rotate ucs to algine with rotated rectangle in modelspace but when using viewport.twistangle it affects viewport.viewcenter although it algin with center of view if i didnot use viewport.twist angle ot the angle is zero (horizontal rectangle as example)
Autodesk.AutoCAD.DatabaseServices.ObjectId vpid = layout1.GetViewports()[1];
Viewport vp = ts.GetObject(vpid, OpenMode.ForWrite) as Viewport;
var WCS2DCS =
Matrix3d.WorldToPlane(vp.ViewDirection) *
Matrix3d.Displacement(vp.ViewTarget.GetAsVector().Negate()) *
Matrix3d.Rotation(vp.TwistAngle, vp.ViewDirection, vp.ViewTarget);
var centertrans = centerpoint.TransformBy(WCS2DCS);
double vpRatio = vp.Width / vp.Height;
double extWidth = width;
double extHeight = height;
double extRatio = extWidth / extHeight;
double scale = extRatio < vpRatio ? vp.Height / extHeight : vp.Width / extWidth;
vp.TwistAngle = Math.PI * 2 - angle;
vp.ViewCenter = new Point2d(centertrans.X, centertrans.Y);
vp.ViewDirection = Vector3d.ZAxis;
vp.CustomScale=scale;
Solved! Go to Solution.
Solved by _gile. Go to Solution.
Solved by _gile. Go to Solution.
yes your idea has worked
thanks gile
but why it affects it
how just computing the transformation matirx overwrite anything
@mohamedalmaz6 wrote:
yes your idea has worked
thanks gile
but why it affects it
how just computing the transformation matirx overwrite anything
If you attentively read the transformation matrix code, you can see it is built from the the viewport ViewDirection, ViewTarget and TwistAngle values. That's why you have to set these properties before building the transformation matrix and use it to transform the 'centerpoint'.
Can't find what you're looking for? Ask the community or share your knowledge.