Community
AutoCAD Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problem with getpoint on AutoCAD 2015 when the function is called by OLE

3 REPLIES 3
Reply
Message 1 of 4
s0m3body
862 Views, 3 Replies

Problem with getpoint on AutoCAD 2015 when the function is called by OLE

Hi,
I'm watching a problem with the Lisp function "getpoint" when AUTOSNAP is set to 0 and the function is called by OLE function "SendCommand". The function will not wait for a mouse click. It returns immediately, the result is point where the cursor is. The problem is highly reproducible with AutoCAD 2015. On older AutoCAD versions it works like expected.

Here a short sample script:

(defun C:TEST_GET (/ kword p1)
    (setvar "AUTOSNAP" 0) 
    (initget 0 "A B")
    (setq kword (getkword "A or B? ")) ;; ask something to see that the

                                       ;; function is running
    (princ "\nGot kword: '")(prin1 kword)(princ "'\n")
    (initget 😎
    (setq p1 (getpoint "Point: ")) ;; returns immediately without user

                                   ;; interaction when the function is

                                   ;; called via OLE "SendCommand"
    (princ "\nGot point: '")(prin1 p1)(princ "'\n")
    (princ)
)    

When the function above is called from command line or from VLIDE it works like expected (ask for a keyword, user types A or B and <Enter>, result is printed, ask for point, user clicks in drawing window, point is printed)

When the function is called via OLE function SendCommand("TEST_GET\n") the function will ask for a keyword, the input is printed and it will not wait for a mouse click. It returns the point where the mouse cursor is immediately.

Is it a bug? Is there a workaround known?
Thanks for any suggestion.

3 REPLIES 3
Message 2 of 4
hgasty1001
in reply to: s0m3body

Hi,

 

I suggest you to post the problem in the Autolisp forum (VisualLisp/Autolisp, doing so you ensure more people with programming knowledge will read your post.

Anayway, can you post the caller function? (what language?), I assume you are using VB/VBA to send the command, but why?, VB/VBA has its own method to adquire points, without need to send commands.

 

Gaston Nunez

Message 3 of 4
s0m3body
in reply to: hgasty1001

Hello Gaston,

you are right, the Autolisp forum may be a better place. I'll post the message there again. The caller function is made in Perl. It is finally the same like in VBA. Both Perl and VBA are using OLE (so far as I know).

Here the calling function in Perl, quite simple and easy to understand without Perl knowledge:

 

use strict;
use Win32::OLE;

my $ACAD = Win32::OLE->GetActiveObject('AutoCAD.Application','Release');
# connect to already opened AutoCAD, # don't close AutoCAD on exit
die "No ACAD object" unless $ACAD;
# die with error message on connection failure
$ACAD->ActiveDocument()->SendCommand("TEST_GET\n");

 

 

The other question is: Why do we use Lisp, not the OLE function to get a point. We have a complex application with some thousands lines of lisp code. We use other tools to trigger native AutoCAD commands or own commands (written in Lisp like the example) by other applications under some circumstances. We have seen that it was not longer working with AutoCAD 2015 and we tried to find out what is going on here. The sample above is the result. This is reproducible with a new AutoCAD 2015 installation without any customization.

 

Bye

Message 4 of 4
martti.halminen
in reply to: s0m3body

This may be related to this:

 

http://adndevblog.typepad.com/autocad/2014/04/migration-after-fiber-is-removed-in-autocad-2015.html

 

- or on Lisp side compare COMMAND-S vs. COMMAND.

 

Regrettably I have no idea what to do if this is the problem.

 

--

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost