明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1409|回复: 6

[基础] 坐标点的精度如何控制

[复制链接]
发表于 2011-1-3 13:40 | 显示全部楼层 |阅读模式
在拾取坐标时,想把坐标保留到一位小数该怎么表达,望高人指点。
 楼主| 发表于 2011-1-3 15:43 | 显示全部楼层
貌似斑竹不在啊
发表于 2011-1-4 10:35 | 显示全部楼层
修改设置就可以了
(command "text" ......... (rtos x 2 1))
  (command "text" ........ (rtos y 2 1))
发表于 2011-1-4 11:16 | 显示全部楼层
Math.Round
 楼主| 发表于 2011-1-7 16:20 | 显示全部楼层
帮我看一下坐标保留到一位小数 如何设置? 求高手帮帮忙!
[CommandMethod("LZ")]
        public void testfunction2()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            Database db = HostApplicationServices.WorkingDatabase;
            SelectionFilter sf = new SelectionFilter(new TypedValue[]{ new TypedValue(0, "Line") });
            PromptSelectionResult psr = ed.GetSelection(sf);
            if (psr.Status != PromptStatus.OK)
                return;
            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                BlockTableRecord curSpace = tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite) as BlockTableRecord;
                foreach (ObjectId id in psr.Value.GetObjectIds())
                {
                    Entity ent = tr.GetObject(id, OpenMode.ForRead) as Entity;
                    if (ent.GetType() == typeof(Line))
                    {
                        Line l = ent as Line;
                        Point3d pt1 = l.StartPoint;
                        Point3d pt2 = l.EndPoint;
                        ed.WriteMessage("\n" + pt1 + pt2);
                    }
                    else
                    {

                    }
                    
                }
                tr.Commit();
            }

        }
发表于 2011-1-7 18:14 | 显示全部楼层
            Point3d pt = new Point3d(12.345,56.567,0);
            ed.WriteMessage("\nPoint:{0:f2}", pt);
 楼主| 发表于 2011-1-8 13:51 | 显示全部楼层
问题解决,感谢飞狐大哥的帮忙
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-18 05:30 , Processed in 0.210150 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表