[求助]如何将DBText定位并缩放合适大小到屏幕中央
<p>如何将DBText定位并缩放合适大小到屏幕中央,其中缩放合式大小指比如说整个屏幕能放15同样的DBText;</p><p>在开发文档中有一个zoom方法,真不知这些参数如何设置;</p><p>我是新学,一些概念真不懂,谢谢了;</p><p></p> <p>就是缩放到整个屏幕一行能放15个“中国人民”字样,请高手指点</p> 简单的办法就是调用Zoom命令或者试下下面的ZoomWindow
public enum UcsCode
{
Wcs = 0,
Ucs,
MDcs,
PDcs
}
private static extern int acedTrans(
double[] point,
IntPtr fromResbuf,
IntPtr toResbuf,
int displacement,
double[] result
);
public static double[] Trans(double[] point, UcsCode from, UcsCode to)
{
ResultBuffer rbfrom = new ResultBuffer(new TypedValue((int)LispDataType.Int16, from));
ResultBuffer rbto = new ResultBuffer(new TypedValue((int)LispDataType.Int16, to));
double[] res = new double;
acedTrans(point, rbfrom.UnmanagedObject, rbto.UnmanagedObject, 0, res);
return res;
}
public static Point2d Wcs2Dcs(Point3d point, bool atPaperSpace)
{
double[] res =
Trans(
point.ToArray(),
UcsCode.Wcs, atPaperSpace ? UcsCode.PDcs : UcsCode.MDcs);
return new Point2d(res);
}
public void ZoomWindow(Point3d minPoint, Point3d maxPoint)
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
ViewTableRecord cvtr = ed.GetCurrentView();
ViewTableRecord vtr = new ViewTableRecord();
vtr.CopyFrom(cvtr);
Point3d[] oldpnts = new Point3d[] { minPoint, maxPoint };
Point3d[] pnts = new Point3d;
Point2d[] pnt2ds = new Point2d;
for (int i = 0; i < 2; i++)
{
for (int j = 0; j < 2; j++)
{
for (int k = 0; k < 2; k++)
{
int n = i * 4 + j * 2 + k;
pnts = new Point3d(oldpnts, oldpnts, oldpnts);
pnt2ds = Wcs2Dcs(pnts, false);
}
}
}
double xmin, xmax, ymin, ymax;
xmin = xmax = pnt2ds;
ymin = ymax = pnt2ds;
for (int i = 1; i < 8; i++)
{
xmin = Math.Min(xmin, pnt2ds);
xmax = Math.Max(xmax, pnt2ds);
ymin = Math.Min(ymin, pnt2ds);
ymax = Math.Max(ymax, pnt2ds);
}
vtr.Width = xmax - xmin;
vtr.Height = ymax - ymin;
vtr.CenterPoint = pnt2ds + (pnt2ds - pnt2ds) / 2;
ed.SetCurrentView(vtr);
ed.Regen();
}
学习
页:
[1]