Compatibility problem between AutoCAD and Bricscad?

I am learning Lisp programming in Bricscad.
Uses Bricscad 18.2 for Linux and uses LinuxMint Mate 19.

I have trouble with a code that works well in AutoCAD 2004. The
not working subroutine looks like this:

    (defun draw_pline (/ p v)
      (setq ptlist nil)
      (foreach el objlist
        (setq ptlist (append ptlist (vlax-get el "center")))
      )
      (setq vl (add3dpoly ptlist))
      (vlax-put-property vl 'layer' xxx ')
    )

The error occurs in the last line because the variable "vl" is NIL in Bricscad,
but shows an object in AutoCAD 2004.

Is there any compatibility problem between AutoCAD and Bricscad?

Bricscad also often crashes when I debug code.
Thanks in advance.

Greetings
Alf

Comments

  • First, I recommend reviewing http://www.lee-mac.com/localising.html It is generally better to pass things like 'objlist' as an argument rather than working with it as global. Also, the local variables you declared do not match the variables you actually used. I suspect your crashes may be associated with improperly or incompletely declared variables.

    For the problem at hand try 'vla-add3dpoly' instead of 'add3dpoly'. I cannot guarantee that this will fix the issue, but 'add3dpoly' is an ActiveX method and most ActiveX methods prepend 'vla-' when used in lisp.

  • @H Martin Shoemaker said:
    First, I recommend reviewing http://www.lee-mac.com/localising.html It is generally better to pass things like 'objlist' as an argument rather than working with it as global. Also, the local variables you declared do not match the variables you actually used. I suspect your crashes may be associated with improperly or incompletely declared variables.

    For the problem at hand try 'vla-add3dpoly' instead of 'add3dpoly'. I cannot guarantee that this will fix the issue, but 'add3dpoly' is an ActiveX method and most ActiveX methods prepend 'vla-' when used in lisp.

    Thanks for your reply. The Council to avoid global variables I take to myself, but it does not seem to affect my problem.
    In my original code, the error occurred here:

         (vlax-put-property vl 'layer' xxx ') because "vl" was NIL.
    

    My PolyLine was drawn, but on the default layer.

    After changing "add3dpoly" to "vla-add3dpoly" an error occurs there instead and no PolyLine was drawn. It appears that these commands require different arguments. Perhaps "ptlist" must be converted with commands like "SafeArray" or "Variant"?

    If I add "(setq vl (vlax-ename-> vla-object (entlast)))" after "add3dpoly" works as I want.

    Can I not assume that AutoLisp and Bricscad Lisp have the same syntax?

    Greetings
    Alf

  • You must use a custom function called add3dpoly. Can you post it?

  • @Roy Klein Gebbinck said:
    You must use a custom function called add3dpoly. Can you post it?

    Hi, Roy!

    No I have not written such a function myself. I found this command in an AutoCAD site and thougt I could use it also in Bricscad. The problem is that it reports NIL instead of an ObjectName. "Add3dpoly" draws a polyline in my drawing also in Bricscad. Perhaps it is an undocumented function.

    "(setq vl (vlax-ename->vla-object (entlast)))"

    reports the ObjectName I need in the last line.

    Now I have also found another problem. This example creates a layer with color "red" in AutoCAD 2004, but not in Bricscad. "VLA-ADD" is not accepted.

    (defun test ( / lay)
    (vl-load-com)
    (setq lay (vla-add
    (vla-get-layers
    (vla-get-activedocument
    (vlax-get-acad-object)
    )
    )
    "xxx"
    )
    )
    (vlax-put-property lay 'color acred)
    )

    /Alf

  • Dear Alf,

    "VLA-ADD"

    that part was broken here in the forum display ...
    (vla-add3dPoly) should indeed work, it is implemented for Linux/Mac ...

    So maybe you can open a support request, and also add your (simplified) Lisp code there, so that we can try to reproduce ?

    Just for you as some background :
    all the VLA/VLAX based Lisp stuff is COM based, so it works primarily on AutoCAD (on WIndows only !! not on Mac !!), but we have a kind of emulation for such Windows COM based Lisp functions under Linux + Mac ... so for us it mostly works there
    (and not for AutoCAD at all, under Mac)

    So probably best to send us a support request ...
    many greetings !

This discussion has been closed.