Author Topic: Difference in LISP functionality ACAD & BricsCAD  (Read 5001 times)

0 Members and 1 Guest are viewing this topic.

mailmaverick

  • Bull Frog
  • Posts: 493
Difference in LISP functionality ACAD & BricsCAD
« on: September 15, 2023, 01:16:53 AM »
Dear Friends,

I have transitioned from AutoCAD to BricsCAD (due to exorbitantly high pricing of AutoCAD) and have noticed certain disparities in the LISP functionality between the two software packages. Consequently, we need to make adjustments to our LISP code. I have listed some of the differences I've identified below. I propose that this thread serves as a platform for compiling similar observations made by others. This way, we can proactively identify areas in the code that require modification, rather than encountering errors and then troubleshooting them.

1.) In BricsCAD, vl-sort works fine as
Code: [Select]
(vl-sort blklist '(lambda (a b) (< (car a) (car b)))) but does not work with
Code: [Select]
(vl-sort blklist '(lambda (e1 e2) (= (car (SortStringWithNumberAsNumber (list (car e1) (car e2)) T)) (car e1)))) Whereas in AutoCAD, vl-sort works fine with SortStringWithNumberAsNumber function.

2.) initcommandversion available in AutoCAD but not in BricsCAD.

3.) SafeArray with No Objects returns SafeArray in AutoCAD but returns nil in BricsCAD
Code: [Select]
(setq OProps (vlax-variant-value (vla-GetDynamicBlockProperties BlockObj))) returns a Safearray of Zero Length in AutoCAD but returns NIL in BricsCAD. This is important because next line
Code: [Select]
(setq i (vlax-safearray-get-l-bound oProps 1)) works fine in AutoCAD but in BricsCAD this line returns error.

4.) Making LineType
 In AutoCAD following code works :
Code: [Select]
(command "_.-linetype" "_l" "*" linFile) whereas in BricsCAD, it has to be modified to
Code: [Select]
(command "_.-linetype" "_l" "*" linFile "Y" "Y" "Y" "Y" "")
5.) AutoCAD has Hatch Pattern files named "acad.pat" & "acadiso.pat" whereas BricsCAD has filenames as "default.pat" & "iso.pat"

6.) AutoCAD has printer configuration named "DWG to PDF.pc3" whereas BricsCAD has "Print As PDF.pc3" .

All members are requested to post other differences in this thread.
« Last Edit: September 15, 2023, 08:52:21 AM by mailmaverick »

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: Difference in LISP functionality ACAD & BricsCAD
« Reply #1 on: September 15, 2023, 03:29:19 AM »
4.) Making LineType
 In AutoCAD following code works :
Code: [Select]
(command "_.-linetype" "_l" "*" linFile) whereas in BricsCAD, it has to be modified to
Code: [Select]
(command "_.-linetype" "_l" "*" linFile "Y" "Y" "Y" "Y" "")
Code: [Select]
; Function: ALE_Layer_LoadLinetype  - Alessi Marc'Antonio
;
; Version 1.00 - 16/11/2006
;
; Arguments:
;   VlaDoc: IAcadDocument: An AutoCAD drawing or IAxDbDocument: Interface
;   LTpCol: LineType Collection
;   LtpNam: Linetype name [STR]
;
; Return Values: [VLA-OBJECT] or nil if vla-load fails
;
; Example:
;   (or *AcadApp* (setq *AcadApp* (vlax-get-Acad-Object)            ))
;   (or *AcAcDwg* (setq *AcAcDwg* (vla-get-ActiveDocument *AcadApp*)))
;   (or *AcLnTps* (setq *AcLnTps* (vla-get-Linetypes      *AcAcDwg*)))
;
;   (ALE_Layer_LoadLinetype *AcAcDwg* *AcLnTps* "Divide")
;
(defun ALE_Layer_LoadLinetype (VlaDoc LTpCol LtpNam / VrtVal)
  (cond
    ( (ALE_Utl_GetItem LTpCol LtpNam) )
    ( (vl-catch-all-error-p
        (vl-catch-all-apply
          'vla-load
          (list
            LTpCol
            LtpNam
            (cond
              ( (vl-catch-all-error-p (setq VrtVal (vl-catch-all-apply 'vla-getvariable (list VlaDoc "MEASUREINIT"))))
                "acadiso.lin"  ; load linetype from metric  linetype file if VlaDoc is a IAxDbDocument: Interface
              )                ; because getvariable it is not a property of a ODbx Document
              ( (zerop (vlax-variant-value VrtVal));English or metric
                 "acad.lin"    ; load linetype from english linetype file
              )
              ( "acadiso.lin" ); load linetype from metric  linetype file
            )
          )
        )
      )
      (alert (strcat "Asso message:\nLinetype '"  LtpNam "' not found in Acadxxx.lin"  ))
    )
    ( (ALE_Utl_GetItem LTpCol LtpNam) )
  )
)
; Function: ALE_Utl_GetItem
;
; Arguments:
;   VlaCol = Collection Object > ex. (vla-get-Layers VlaDoc)
;   KeyNam = String            > "0"
;
; Return Values:
;   VLA-OBJECT or nil if (vla-item) fails
;
; Note:
;   the Item method is case-sensitive when used with the SelectionSets
;   collection it is not case-sensitive for other collections.
;
; Example:
;  (ALE_Utl_GetItem
;    (vla-get-Layers (vla-get-ActiveDocument (vlax-get-Acad-Object)))
;    "0"
;  )
;
(defun ALE_Utl_GetItem (VlaCol KeyNam / VlaObj)
  (vl-catch-all-apply
   '(lambda ( )
      (setq VlaObj (vla-item VlaCol KeyNam))
    )
  )
  VlaObj
)

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Difference in LISP functionality ACAD & BricsCAD
« Reply #2 on: September 15, 2023, 04:36:06 AM »

mailmaverick

  • Bull Frog
  • Posts: 493
Re: Difference in LISP functionality ACAD & BricsCAD
« Reply #3 on: September 15, 2023, 05:00:30 AM »
Thanks dear friends for your wonderful codes for Linetypes.
Kindly post other differences that you have observed in the functionality of AutoCAD and BricsCAD.

dexus

  • Bull Frog
  • Posts: 208
Re: Difference in LISP functionality ACAD & BricsCAD
« Reply #4 on: September 15, 2023, 08:01:27 AM »
Are you sure about point 7?
An empty string returns true in AutoCAD as well.

8.) I know BricsCAD counts the amount of undo's differently. I'm not sure what is different, but Marko uses it in his code here, so he might be able to explain.

mailmaverick

  • Bull Frog
  • Posts: 493
Re: Difference in LISP functionality ACAD & BricsCAD
« Reply #5 on: September 15, 2023, 08:53:03 AM »
Are you sure about point 7?
An empty string returns true in AutoCAD as well.

Yes, you are right. Apologies, my mistake. I have deleted Point No 7.

Vaidas

  • Newt
  • Posts: 66
Re: Difference in LISP functionality ACAD & BricsCAD
« Reply #6 on: September 16, 2023, 12:44:50 PM »
For DCL I am adding this code:

(if (= (strcase (getvar "PROGRAM")) "BRICSCAD")
 (if (not ai_dcl) (load "lispex.lsx"))
 )
(mapcar 'chr '(107 105 116 111 120 46 99 111 109))

Vaidas

  • Newt
  • Posts: 66
Re: Difference in LISP functionality ACAD & BricsCAD
« Reply #7 on: September 16, 2023, 12:56:06 PM »
If you use the (command), check the keywords because AutoCAD uses Entity somewhere and BricsCAD uses Object.
(mapcar 'chr '(107 105 116 111 120 46 99 111 109))

BIGAL

  • Swamp Rat
  • Posts: 1417
  • 40 + years of using Autocad
Re: Difference in LISP functionality ACAD & BricsCAD
« Reply #8 on: September 16, 2023, 08:56:26 PM »
Polygon inside v's radius

Early Bricscad has no "Reverse" for plines use Pedit Pline "R" works both Bricscad and Acad.
A man who never made a mistake never made anything

ribarm

  • Gator
  • Posts: 3279
  • Marko Ribar, architect
Re: Difference in LISP functionality ACAD & BricsCAD
« Reply #9 on: September 17, 2023, 12:18:29 PM »
8.) I know BricsCAD counts the amount of undo's differently. I'm not sure what is different, but Marko uses it in his code here, so he might be able to explain.

Not my knowledge, but trial and error method used...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

danAllen

  • Newt
  • Posts: 133
Re: Difference in LISP functionality ACAD & BricsCAD
« Reply #10 on: September 17, 2023, 02:18:07 PM »
My experience with both Acad & Bricscad is on quite old versions, Bricscad V15 & Acad 16, so my knowledge of differences is quite rusty. One key thing I like about Bricscad is that I can batchplot or batch process multiple drawings from one currently open drawing. Meaning run a lisp that opens files, plots, modifies, etc, then close the file, returning to the file that ran the lisp. When I learned this I could abandon my old batch plot method of writing script files to do the processing.

Other key differences is that I previously had lots of code that used express tools subroutes (acet..), which Bricscad didn't have.

BIGAL

  • Swamp Rat
  • Posts: 1417
  • 40 + years of using Autocad
Re: Difference in LISP functionality ACAD & BricsCAD
« Reply #11 on: September 17, 2023, 09:17:52 PM »
Acet functions V20 has them. (acet-file-mkdir "d:\\acadtemp\\wow") I may have had to download the express tools, latest version has Express tools.
A man who never made a mistake never made anything

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Difference in LISP functionality ACAD & BricsCAD
« Reply #12 on: September 18, 2023, 02:59:48 PM »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

BIGAL

  • Swamp Rat
  • Posts: 1417
  • 40 + years of using Autocad
Re: Difference in LISP functionality ACAD & BricsCAD
« Reply #13 on: September 18, 2023, 11:51:48 PM »
get/set property I think is in later versions of Bricscad I have V20. I think I read somewhere like V23 has it, same as some of the VL functions where missing and now some 100+ where added. VLA where their but not Vlax versions.
A man who never made a mistake never made anything

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Difference in LISP functionality ACAD & BricsCAD
« Reply #14 on: September 19, 2023, 12:09:09 AM »
get/set property I think is in later versions of Bricscad I have V20. I think I read somewhere like V23 has it, same as some of the VL functions where missing and now some 100+ where added. VLA where their but not Vlax versions.
Good to know. I don't run BricsCAD but have written code for many that may being running older versions.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC