TheSwamp

Code Red => .NET => Topic started by: Nima2018 on February 15, 2019, 10:34:33 AM

Title: GetPoint in AutoCAD.Interop
Post by: Nima2018 on February 15, 2019, 10:34:33 AM
Hi,
I want to use GetPoint via Autodesk.AutoCAD.Interop in my codes, but I get an error about missing object in the following line :

Code: [Select]

            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 :");


However, in VBA such a limitation does not exist for an optional argument.
Also, the reason for using " Introp Com " is that I want to use it in a Windows application project without using Netload command .
Please advice me .
Title: Re: GetPoint in AutoCAD.Interop
Post by: kdub_nz on February 15, 2019, 01:14:00 PM


Quote
// I get error at this line

What exactly is the error ??

//----

I assume AutoCAD is open and you are trying to talk to it from yourWindows App. ??

Title: Re: GetPoint in AutoCAD.Interop
Post by: Nima2018 on February 16, 2019, 12:33:27 AM
Hi kdub
Thanks for your reply .
At LINE of getting first point (my_pt1) I see this error :

      Argument missing
Title: Re: GetPoint in AutoCAD.Interop
Post by: kdub_nz on February 16, 2019, 01:16:15 AM
Do you think it may be because you have a comma with no prior value in the parameter list??
Title: Re: GetPoint in AutoCAD.Interop
Post by: Nima2018 on February 16, 2019, 02:01:14 AM
Yes, visual studio show red sign under comma.
I check my code on another machine and results was same as previous .
Title: Re: GetPoint in AutoCAD.Interop
Post by: gile on February 16, 2019, 02:17:38 AM
Hi,

Unlike VB(A), C# does not allow a blank for an optional argument before a comma. You have to specify a Type.Missing argument.

Code - C#: [Select]
  1. my_pt1 = AcadApp.ActiveDocument.Utility.GetPoint(Type.Missing, "Please click on the first point :");

My only advice shoud be: while using C#/.NET keep as far as you can away from the COM interop...
Title: Re: GetPoint in AutoCAD.Interop
Post by: Nima2018 on February 16, 2019, 10:28:52 AM
Hi,

Yes, I thank you for your helps, and I will definitely act on your advice, dear gile .