CAD.NET图像的缩放Scale

操作方法

在CAD操作中SCALE缩放命令的用法:输入SC或SCALE命令,选择要缩入的对象-选择基点-输入缩放比例参数-空格完成。

代码实现

使用API实现的关键点:调用Entity的TransformBy方法。如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/// <summary>
/// 缩放
/// </summary>
/// <param name="id">数据ID</param>
/// <param name="basePoint">基点</param>
/// <param name="scale">缩放比例参数-</param>
public static void Scale(ObjectId id, Point3d basePoint, double scale)
{
    Matrix3d transform = Matrix3d.Scaling(scale, basePoint);
 
    Database db = id.Database;
 
    using (Transaction tr = db.TransactionManager.StartTransaction())
    {
        try
        {
            Entity ent = (Entity)tr.GetObject(id, OpenMode.ForWrite);
 
            if (ent != null)
            {
                ent.TransformBy(transform);
            }
 
            tr.Commit();
 
        }
        catch (Autodesk.AutoCAD.Runtime.Exception ex)
        {
            AcadApp.ShowAlertDialog(ex.Message);
        }
    }
}
posted @   我也是个傻瓜  阅读(410)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 提示词工程——AI应用必不可少的技术
· 地球OL攻略 —— 某应届生求职总结
· 字符编码:从基础到乱码解决
· SpringCloud带你走进微服务的世界
历史上的今天:
2015-02-28 栅格计算器函数之Con
点击右上角即可分享
微信分享提示