COM Programming

I have submitted the following as a support request but I thought that one of our resident brainiacs might be able to satiate my curiosity while I await an answer.

 

The following very simple code resides in a windows exe created in Delphi called qc.exe.

 

Var

App : IAutocadApplication;

Begin

  App := IDispatch(GetActiveOleObject('BricscadApp.AcadApplication')) as IAcadApplication; //Get the active application object

  App.ActiveDocument.SendCommand('5000,5000'#13#10);

End;

 

At this point the application does nothing more than return 5000,5000 to the command line (eventually the intention is that it returns a point transparently to an active command in BC eg line, polyline etc.

 

The exe is implemented through the following lisp:

 

(defun c:qc () (startapp "qc.exe") )

 

All files reside within the Bcad support path and run - (just not as i'd like). The output from a test run with the line command follows.

 

1. : line

2. ENTER to use last point/Follow/<Start of line>: 'qc

3. ENTER to use last point/Follow/<Start of line>: 2764

4. Angle/Length/Undo/<End point>: 5000,5000

5. Angle/Length/Follow/Undo/<End point>: 

 

If you look at line 3 of the output you will see that bricscad is echoing some kind of handle or process ID to the screen which interferes with the program.  Is there a way to turn this off or is it a bug?

 

Regards,

Comments

  • No: it's not a bug. If successful, startapp returns an integer greater than 2.
    You can stop your lisp from returning this value by using:

    (defun c:qc () (startapp "qc.exe") nil)

    But my guess is that your approach still won't work. I only know a few things about lisp though.

  • Or better still (?):

    (defun c:qc () (startapp "qc.exe") (princ))

  • Thanks a bunch Roy; after adding the nil parameter everything works perfectly.

  • Dear Roy, Dear Daniel,

    the last approach is formally correct, using (princ) to suppress any return;
    using NIL will return NIL, which might disturb sometimes ... so (princ) is safer + more correct.

This discussion has been closed.