许可优化
许可优化
产品
产品
解决方案
解决方案
服务支持
服务支持
关于
关于
软件库
当前位置:服务支持 >  软件文章 >  基于C#的AutoCAD二次开发:获取用户输入信息、选择集、访问CAD内部命令

基于C#的AutoCAD二次开发:获取用户输入信息、选择集、访问CAD内部命令

阅读数 2
点赞 0
article_banner

基于C#的AutoCAD二次开发之获取用户输入 信息 、选择集、访问CAD内部命令

   在 CAD 创建图形对象时,经常需要和用户进行交互,例如:直线创建时需要用户输入起点和终点(或长度)信息,复制对象时需要指定源对象等。

   我的开发环境为Visual Studio 2017 & AutoCAD 2014 & AutoCAD 2020。

  1. 点拾取
  • 实现方法

方式一

PromptPointResult retStPoint = ed.GetPoint(("请输入点")); 

方式二

PromptPointOptions ppo = new PromptPointOptions("请输入点"); 
PromptPointResult retStPoint = ed.GetPoint(ppo);
  • 效果展示
  • 实例代码(获取手动交互的某点坐标,并标注)

类  

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.DatabaseServices;

代码

[CommandMethod("PointCreated")]
public void ComputePointCreate()
{
   
   
    Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.
        DocumentManager.MdiActiveDocument.Editor;
    PromptPointResult retStPoint = ed.GetPoint(("获得起点坐标"));
    if (retStPoint.Status != PromptStatus.OK)
        return;
    DBPoint pt = new 
免责声明:本文系网络转载或改编,未找到原创作者,版权归原作者所有。如涉及版权,请联系删


相关文章
QR Code
微信扫一扫,欢迎咨询~
customer

online

联系我们
武汉格发信息技术有限公司
湖北省武汉市经开区科技园西路6号103孵化器
电话:155-2731-8020 座机:027-59821821
邮件:tanzw@gofarlic.com
Copyright © 2023 Gofarsoft Co.,Ltd. 保留所有权利
遇到许可问题?该如何解决!?
评估许可证实际采购量? 
不清楚软件许可证使用数据? 
收到软件厂商律师函!?  
想要少购买点许可证,节省费用? 
收到软件厂商侵权通告!?  
有正版license,但许可证不够用,需要新购? 
联系方式 board-phone 155-2731-8020
close1
预留信息,一起解决您的问题
* 姓名:
* 手机:

* 公司名称:

姓名不为空

姓名不为空

姓名不为空
手机不正确

手机不正确

手机不正确
公司不为空

公司不为空

公司不为空