CAD.NET 缩放窗口
using Autodesk.AutoCAD.Colors;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.GraphicsInterface;
using Autodesk.AutoCAD.Runtime;
using System;
namespace Autodesk.AutoCAD.DatabaseServices
{
[Wrapper("AcDbAbstractViewTableRecord")]
public abstract class AbstractViewTableRecord : SymbolTableRecord
{
protected internal AbstractViewTableRecord(IntPtr obj, bool autoDelete);
public Color AmbientLightColor { get; set; }
[UnitType(UnitType.Distance)]
public double BackClipDistance { get; set; }
public bool BackClipEnabled { get; set; }
public ObjectId Background { get; set; }
[UnitType(UnitType.Unitless)]
public double Brightness { get; set; }
public Point2d CenterPoint { get; set; }
[UnitType(UnitType.Unitless)]
public double Contrast { get; set; }
public bool DefaultLightingOn { get; set; }
public DefaultLightingType DefaultLightingType { get; set; }
[UnitType(UnitType.Distance)]
public double Elevation { get; set; }
public bool FrontClipAtEye { get; set; }
[UnitType(UnitType.Distance)]
public double FrontClipDistance { get; set; }
public bool FrontClipEnabled { get; set; }
[UnitType(UnitType.Distance)]
public double Height { get; set; }
[UnitType(UnitType.Distance)]
public double LensLength { get; set; }
public bool PerspectiveEnabled { get; set; }
public ObjectId SunId { get; }
public Point3d Target { get; set; }
public ToneOperatorParameters ToneOperatorParameters { get; set; }
public CoordinateSystem3d Ucs { get; }
public ObjectId UcsName { get; }
public OrthographicView UcsOrthographic { get; }
public Vector3d ViewDirection { get; set; }
public OrthographicView ViewOrthographic { get; }
[UnitType(UnitType.Angle)]
public double ViewTwist { get; set; }
public ObjectId VisualStyleId { get; set; }
[UnitType(UnitType.Distance)]
public double Width { get; set; }
public ObjectId SetSun(DBObject sun);
public void SetUcs(ObjectId id);
public void SetUcs(OrthographicView view);
public void SetUcs(Point3d origin, Vector3d x, Vector3d y);
public void SetUcsToWorld();
public void SetViewDirection(OrthographicView view);
}
}
using Autodesk.AutoCAD.Runtime;
using System;
using System.Xml.Serialization;
namespace Autodesk.AutoCAD.DatabaseServices
{
[Wrapper("AcDbViewTableRecord")]
public class ViewTableRecord : AbstractViewTableRecord
{
public ViewTableRecord();
protected internal ViewTableRecord(IntPtr obj, bool autoDelete);
public AnnotationScale AnnotationScale { get; set; }
public string CategoryName { get; set; }
public bool IsPaperspaceView { get; set; }
public bool IsUcsAssociatedToView { get; }
public string LayerState { get; set; }
public ObjectId Layout { get; set; }
public ObjectId LiveSection { get; set; }
[XmlIgnore]
public System.Drawing.Bitmap Thumbnail { get; set; }
public bool ViewAssociatedToViewport { get; set; }
public void DisassociateUcsFromView();
}
}
/// <summary>
/// 设置窗口大小
/// </summary>
/// <param name="ptMin"></param>
/// <param name="ptMax"></param>
/// <param name="scale">图形窗口大小将被设置为指定大小的scale倍</param>
public static void Set(Point3d ptMin, Point3d ptMax, double scale)
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
ViewTableRecord view = ed.GetCurrentView();
view.Height = (Math.Abs(ptMax.Y - ptMin.Y) * scale);
view.Width = (Math.Abs(ptMax.X - ptMin.X) * scale);
view.CenterPoint = new Point2d((ptMax.X + ptMin.X) / 2, (ptMax.Y + ptMin.Y) / 2);
//设为当前视图
ed.SetCurrentView(view);
Application.UpdateScreen();
}
一切皆有可能,不是吗?时间会给你答案!
本文介绍了使用CAD.NET进行窗口缩放和设置窗口大小的操作方法,通过ViewTableRecord和AbstractViewTableRecord等技术实现对CAD界面的精细化控制。
1707

被折叠的 条评论
为什么被折叠?



