Nima2018 发表于 2019-2-15 10:34:33

GetPoint在AutoCAD.Interop

嗨,
我想在我的代码中通过Autodesk.AutoCAD.Interop使用GetPoint,但是我在以下行中收到有关缺少对象的错误:

            AcadPoint my_pt1 = default(AcadPoint);
            AcadPoint my_pt2 = default(AcadPoint);
            my_pt1 = AcadApp.ActiveDocument.Utility.GetPoint(, "Please click on the first point :"); // I get error at this line
               
            my_pt2 = AcadApp.ActiveDocument.Utility.GetPoint(my_pt1, "Please click on the second point :");

但是,在VBA中,对于可选参数不存在这样的限制。
另外,使用“ Introp Com”的原因是我想在Windows应用程序项目中使用它而不使用Netload命令。
请建议我 .
**** Hidden Message *****

kdub 发表于 2019-2-15 13:14:00


错误到底是什么
/-----
我假设AutoCAD已打开,您正试图通过Windows应用程序与它对话

Nima2018 发表于 2019-2-16 00:33:27

您好kdub
感谢您的回复。
在获取第一个点(my_pt1)的行中,我看到以下错误:
缺少参数

kdub 发表于 2019-2-16 01:16:15

你认为这可能是因为参数列表中有一个逗号,没有优先值吗??

Nima2018 发表于 2019-2-16 02:01:14

是的,Visual Studio在逗号下显示红色符号。
我在另一台机器上检查我的代码,结果与之前相同。

gile 发表于 2019-2-16 02:17:38

您好,
与VB(A)不同,C#不允许在逗号之前为可选参数设置空白。您必须指定一个Type.Missing参数。
my_pt1=AcadApp.ActiveDocument.Utility.GetPoint(Type.Missing,"请单击第一点:");
我唯一的建议应该是:在使用C#/. NET时,尽可能远离COM互操作...

Nima2018 发表于 2019-2-16 10:28:52

嗨,
是的,谢谢你的帮助,我一定会按照你的建议去做,亲爱的gile。
页: [1]
查看完整版本: GetPoint在AutoCAD.Interop