Author Topic: GetPoint in AutoCAD.Interop  (Read 471 times)

0 Members and 1 Guest are viewing this topic.

Nima2018

  • Newt
  • Posts: 28
GetPoint in AutoCAD.Interop
« 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 .
« Last Edit: February 15, 2019, 10:40:26 AM by Nima2018 »

kdub

  • Mesozoic relic
  • SuperMod
  • Swamp Rat
  • Posts: 1367
  • class keyThumper<T>:ILazy<T>
Re: GetPoint in AutoCAD.Interop
« Reply #1 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. ??

called Kerry in my other life

Sometimes the question is more important than the answer.
#ridesober

Nima2018

  • Newt
  • Posts: 28
Re: GetPoint in AutoCAD.Interop
« Reply #2 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

kdub

  • Mesozoic relic
  • SuperMod
  • Swamp Rat
  • Posts: 1367
  • class keyThumper<T>:ILazy<T>
Re: GetPoint in AutoCAD.Interop
« Reply #3 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??
« Last Edit: February 16, 2019, 01:20:24 AM by kdub »
called Kerry in my other life

Sometimes the question is more important than the answer.
#ridesober

Nima2018

  • Newt
  • Posts: 28
Re: GetPoint in AutoCAD.Interop
« Reply #4 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 .

gile

  • Water Moccasin
  • Posts: 2224
  • Marseille, France
Re: GetPoint in AutoCAD.Interop
« Reply #5 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...
« Last Edit: February 16, 2019, 02:34:35 AM by gile »
Speaking English as a French Frog

Nima2018

  • Newt
  • Posts: 28
Re: GetPoint in AutoCAD.Interop
« Reply #6 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 .