Compare Autocad lisp code To Bricscad

aridzv
edited August 2023 in LISP Codes
Hi.
Following this issue and other cases,
I thought it would be helpful to create a topic that would get the comparison between Autocad lisp code and Bricscad lisp code.
I will start with these two cases:

1. Get CAD object:
Autocad: (vlax-get-object "AutoCAD.Application")
Bricscad: (vlax-get-object "BricscadApp.AcadApplication")

2. get Effective block name from anonymous block:
Autocad: (setq bname (vla-get-effectivename (vlax-ename->vla-object ent_n)))
Bricscad: (setq bname (getpropertyvalue ent_n "EffectiveName~Native")))

Comments

  • 1. You would normally use (vlax-get-acad-object) which works in both AutoCAD and BricsCAD.
    2. (setq bname (vla-get-effectivename (vlax-ename->vla-object ent))) works in BricsCAD as well.
  • aridzv
    edited August 2023

    1. You would normally use (vlax-get-acad-object) which works in both AutoCAD and BricsCAD.
    2. (setq bname (vla-get-effectivename (vlax-ename->vla-object ent))) works in BricsCAD as well.

    about No.1 ((vlax-get-acad-object)):
    when you access from within bricscad That's probably true,
    but when you try to access bricscad from other programs you must use BricscadApp.AcadApplication - from experience.

    About No.2:
    No, categorically not.
    In order to get the block name from an anonymous block and not the *U name you must use:
    (getpropertyvalue ent_n "EffectiveName~Native")).
    I tried to use (vla-get-effectivename (vlax-ename->vla-object ent)) for an anonymous block and it gave the *U name and not the block name.
    agian - see this topic.
  • 1. In your example you are using Lisp code. This code cannot be used in other programs. As such this information is confusing.
    2. You have to be more specific here. vla-get-effectivename works in BricsCAD as it works in AutoCAD (or it should). Of course anonymous blocks are not only used for AutoCAD's dynamic blocks. Many other applications rely on them, including some BricsCAD implementations. For BricsCAD-only solutions vla-get-effectivename will not work either in AutoCAD or in BricsCAD. So the information you are giving is incomplete and therefore, again, confusing.
  • aridzv
    edited August 2023
    @Roy Klein Gebbinck

    1. About (vlax-get-acad-object) Vs. (vlax-get-object "BricscadApp.AcadApplication") -
    I agree with you that it may be little confusing, but when I needed to
    get access from other software to bricscad,where the code was writen to access autocad, that was the
    solution, a solution that was not easy to find and I saw it in lisp as well.
    2. about the anonymous blocks:
    a. anonymous blocks are dynamic blocks in autocad,parametric blocks in bricscad and probebly there are more.
    b. when the parameters of a parametric block are changed or dynamic block is streched,it's effective name
    reset to a *U name,and then it is a problem to get it's real (Effective) name.
    c. in order to get the block name - NOT THE *U name which is the prefix *U and a number (*U22 for example) - but the block name it self,
    in bricscad you need to use (getpropertyvalue ent_n "EffectiveName~Native")) when in autocad it is different.
    I don't have autocad so I can't realy check which of the code lines given to me in attempt to help me actually works in autocad,but this is a bricscad forum and I refer to bricscad.
    from experience, Despite the many attempts and the many questions I asked, no one knew the answer,
    And without the help from bricscad technical support I would not have been able to solve the problem.

    in this topic I'm trying to spare other bricscad users from such an ordeal.

    *EDIT:
    If you or any other user here have more examples on lisp differences between autocad and bricscad please raise them.

    *2nd EDIT:
    And here is a simple lisp that demonstrates it:
    (defun c:test ( / bname bname1 ensel obj )
    (vl-load-com)
       (setq ensel (entsel "\nSelect Block: ")) ;;select an anonymous block (*U TYPE) to get it's name
       (setq obj (car ensel)) ;;set the block object to an Entity name varaible
       (setq bname1 (vla-get-effectivename (vlax-ename->vla-object obj))) ;; get the *U name 
       (princ bname1)
       (setq bname (getpropertyvalue obj "EffectiveName~Native")) ;; get the effective name
    
       ;;(princ bname) ;; print the effective name
    )
    
  • 1, is correct, that’s just the COM API, every application can’t be named AutoCAD : ) (vlax-get-object "Excel.Application")

    2, The block you posted in another thread was not an AutoCAD compatible dynamic block, it was created with some Bricsys tech, which is perfectly okay, if Bricsys wants to do things their way, However, it is unfortunate the lack of API documentation

    IMHO (getpropertyvalue ent_n "EffectiveName~Native")) is yukky. Bricsys probably could make vla-get-effectivename detect if it’s their tech or not. It probably hasn’t been thought of until your SR
    For the most part, Bricsys API’s are pretty good, it’s hard work on their part, things get missed. In that case, report it.
  • aridzv
    edited August 2023
    Hi @NigelTufnel and thanks for the reply.

    1. you wrote:
    The block you posted in another thread was not an AutoCAD compatible dynamic block, it was created with some Bricsys tech
    ofcourse - I'm a bricscad user... :) and parametric blocks are major element in bricscad,not a side effect.

    2. you wrote:
    However, it is unfortunate the lack of API documentation
    - I think that this is the issue. if there was some documentation for it, I belive that it whould be a big part of eliminating this kind of problems.

    3. you wrote:
    It probably hasn’t been thought of until your SR
    - here I don't think it is true,because if that was the case Bricscad should have released a software update to include this method. I believe it has always been there,just going back to the documentation issue.



  • In my V20 the Reverse command does not exist, probably does now, so use Pedit R. Another is Polygon I seem to remember a difference between in and out.
  • aridzv
    edited August 2023
    how to check if parameter proprty exist (Lee Mac's code):
    (defun c:test ( / ent )
        (if (setq ent (car (entsel)))
            (if (ispropertyvalid ent "d1~MCAD")
                (print (getpropertyvalue ent "d1~MCAD"))
                (princ "\nProperty not valid.")
            )
        )
        (princ)
    )
    to check what parameters are part of the object run this code:
    (dumpallproperties (entlast))
    it will print the full list of the object properies to the command line.
    the parameters are at the end in the "MCAD Properties" section.

    In autocad it will probably be something like this:
    (vlax-property-available-p obj "d1")
    And again the issue of the lack of documentation comes up...