yun111 发表于 2007-2-2 10:02:00

c#如何调用AutoCAD命令,让用户输入参数?

c#如何调用命令,让用户输入参数?
如使用pedit命令,需要选择是否转换多义线?
选择合并中,Y和J这两个参数都需要从命令行输入,C#程序如何实现呢?谢谢!

meworld 发表于 2007-2-6 12:48:00

以下是我的程序中的一段,应该能回答楼上的问题吧,不知道对楼上的有没有帮助。
   Database db = HostApplicationServices.WorkingDatabase;
   Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
&nbspromptDoubleOptions SourceOptions = new PromptDoubleOptions("\n请输入原中央经线");
   SourceOptions.DefaultValue = 123;
&nbspromptDoubleOptions DestinationOptions = new PromptDoubleOptions("\n请输入转换后中央经线");
   DestinationOptions.DefaultValue = 121.30;
&nbspromptResult GeoEllip = ed.GetKeywords("\n椭球体选择:1.WGS-84 2.Krassovsky",new string[]{"1","2"});
   if(GeoEllip.Status != PromptStatus.OK) return;
&nbspromptDoubleResult SourceCL = ed.GetDouble(SourceOptions);
   if(SourceCL.Status != PromptStatus.OK) return;
&nbspromptDoubleResult DestinationCL = ed.GetDouble(DestinationOptions);
   if(DestinationCL.Status != PromptStatus.OK) return;
   ed.WriteMessage("\n开始坐标换带,请稍候。");
   Transaction trans = db.TransactionManager.StartTransaction();
   BlockTableRecord btr = (BlockTableRecord)trans.GetObject(db.CurrentSpaceId,OpenMode.ForRead);

yun111 发表于 2007-4-13 15:59:00


感谢楼上meworld分享代码!能单独说明一下调用CAD中命令的实例吗?比如sendStringToExecute的用法?谢谢!

fairfanfan 发表于 2008-2-27 13:49:00

怎样用C#调用Addhacth()函数

wangfen_feng 发表于 2008-7-31 15:35:00

向2楼的多多学习!!!以后多多交流啊!!!!

genhao5 发表于 2010-8-17 17:03:00

唔 没看懂...是不是没有发完呢..

雪山飞狐_lzh 发表于 2010-8-17 21:18:00

http://bbs.mjtd.com/forum.php?mod=viewthread&tid=78074
页: [1]
查看完整版本: c#如何调用AutoCAD命令,让用户输入参数?