kyle 发表于 2016-3-7 21:27:35

旋转纸张空间中的现有视口

大家好,我在C#NET代码中遇到了一个小问题,我希望有人能为我指出正确的方向。到目前为止,我已经成功地编写了代码,从模型空间中获取折线,并使用它来在新布局中创建该区域的裁剪视口。当我尝试在之后旋转此视口时,我的问题出现了(如果它比它宽高)。以下是我在事务中打开视口以进行写入后的代码片段...注意:'pl'是纸张空间中的一条折线,它已从模型空间中的原始折线缩放 acVport.ViewDirection = new Vector3d(0, 0, 1);。
acVport.CenterPoint = new Point3d(centerPoint.X, centerPoint.Y, 0);。
acVport.CustomScale = 0.01;。
pl.TransformBy(Matrix3d.Displacement(pSpaceDisplacementVector));。
acBlkTblRec.AppendEntity(pl);。
acTrans.AddNewlyCreatedDBObject(pl, true);。

acvport.NonRectClipEntityId = pl.对象 Id;。
acVport.NonRectClipOn = true;。
acVport.ViewCenter = new Point2d(modelCenter.X, modelCenter.Y);。

bool landscapeOrient = (acVport.Bounds.Value.MaxPoint.X - acVport.Bounds.Value.MinPoint.X) >= (acVport.Bounds.Value.MaxPoint.Y - acVport.Bounds.Value.MinPoint.Y);。
如果(!横向定向)。
{。
acDoc.Editor.WriteMessage(“Rotating Viewport...(90 摄氏度)\n“);。
Matrix3d acMat3d = Matrix3d.Rotation(Math.PI / 2.0, Vector3d.ZAxis, acVport.Bounds.Value.MinPoint);。
acVport.TransformBy(acMat3d);。
}。
在此之后,事务提交,并且除最终转换(90 度旋转)之外,一切按预期工作,编辑器确实吐出了消息“旋转视口...(90 度 CC)“,所以我知道该块正在执行,有谁知道为什么这种转变实际上并没有发生在纸质空间的视口?任何建议都非常感谢!编辑:我意识到我需要转换充当非矩形剪辑的折线,但我不确定如何在不弄乱视口的情况下应用此转换,(我想同时旋转它们,以便NORTH在paperspace中显示为West),我还尝试使用acVport.SetUcs()来更改x和y轴,但ucs没有更改。
**** Hidden Message *****

kyle 发表于 2016-3-8 12:04:03

我的问题被Autocad Developer Network Open NET论坛中的用户gile解决了...解决方案很简单:“您尝试更改Viewport.TwistAngle值了吗?”双旋转=-Math.PI/2.0;。
viewport.TwistAngle+=旋转;。
viewport.ViewCenter=viewport.ViewCenter.TransformBy(Matrix2d.Rotation(旋转,Point2d.Origin));谢谢,吉尔!。

Master_Shake 发表于 2016-3-8 16:48:39

欢迎凯尔!
吉尔有发布真正好东西的习惯。

kyle 发表于 2016-3-10 08:28:36


我个人认为Gile应该用C#book编写一个AutoCAD编程。

Master_Shake 发表于 2016-3-10 08:50:01


我个人认为Gile应该用C#书编写一个编程AutoCAD。

我会温习我的法语
页: [1]
查看完整版本: 旋转纸张空间中的现有视口