How to call GetPoint method?

How to call GetPoint method?

Djordje.Spasic
Participant Participant
494 Views
2 Replies
Message 1 of 3

How to call GetPoint method?

Djordje.Spasic
Participant
Participant

Dear Autocad Experts,

I would like to call ThisDrawing.Utility.GetPoint method  in C#.

 

Autodesk documentation shows how this can be done in VBA:

a) With relative base point input
        basePnt(0) = 0#: basePnt(1) = 0#: basePnt(2) = 0#
        returnPnt = ThisDrawing.Utility.GetPoint(basePnt, "Enter a point: ")

 

b) Without relative base point input:
        returnPnt = ThisDrawing.Utility.GetPoint(, "Enter a point: ")

 


How to replicate the second (b) option in C#?
This option does not require 'basePnt' input.

I tried, using: null or 0, but then I get an error: 'Invalid argument Point in GetPoint'

I tried using an empty array, but then GetPoint method assumes that I supplied an array with 0,0,0 coordinates.

 

Does anyone know how to use the GetPoint method in C#, without the relative base point input?


I would be very grateful for any kind of help. Thank you in advance.

0 Likes
Accepted solutions (1)
495 Views
2 Replies
Replies (2)
Message 2 of 3

norman.yuan
Mentor
Mentor
Accepted solution

You might want to describe what kind of app you are writing? Why do you need to use AutoCAD COM API while writing code with C#? 

 

If you are doing AutoCAD .NET Plugin with C# or VB.NET (it is time to stop using VB.NET!), why do you want to use COM API's GetPoint(), rather than .NET API's GetPoint()? If you are calling AcadDocument.Utilities.GetPoint() from an app outside AutoCAD (stand-alone EXE, maybe?), then, the first thing you want to ask why you want a user, who is running an EXE app and goes to another application (AutoCAD) to pick a point, and then possibly goes back to your EXE to continue? Having to switching between different apps back and forth makes a bad user experience, and should be avoid as much as possible.

 

Now, if for whatever reason(s) you have to call COM API's GetPoint() with .NET language (C#, or VB.NET), and you do not want to pass an optional parameter, you can use Type.Missing in the palce:

 

var point=AcadDocObject.Utilities.GetPoint(Type.Missing, "\nSelect a point:");

 

 

Norman Yuan

Drive CAD With Code

EESignature

Message 3 of 3

Djordje.Spasic
Participant
Participant

Hi @norman.yuan ,
Thank you very much for the help and explanations!
Your Type.Missing worked perfectly!

We are successfully accessing the AutoCAD COM API from Revit, in order to make a production drawing from our Revit geometry.
I assume some kind of AutoCAD NET command addon could be created in AutoCAD. Then we would call a command, for each functionality needed - from Revit API. But why to overcomplicate the approach, when using COM directly requires no installation of anything on the AutoCAD part.
We also read your older suggestions on this topic.

COM API enables us to fully automate the drawing creation, without the need of any additional RealDWG API, Design Automation API, cloud... subscriptions.

Thank you very much for your help, once again.

0 Likes