TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: mailmaverick 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 (vl-sort blklist '(lambda (a b) (< (car a) (car b))))
but does not work with (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
(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 (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 : (command "_.-linetype" "_l" "*" linFile)
whereas in BricsCAD, it has to be modified to (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.
-
4.) Making LineType
In AutoCAD following code works : (command "_.-linetype" "_l" "*" linFile)
whereas in BricsCAD, it has to be modified to (command "_.-linetype" "_l" "*" linFile "Y" "Y" "Y" "Y" "")
; 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
)
-
Or Load Linetypes (http://lee-mac.com/loadlinetype.html)
-
Thanks dear friends for your wonderful codes for Linetypes.
Kindly post other differences that you have observed in the functionality of AutoCAD and BricsCAD.
-
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 (https://www.theswamp.org/index.php?topic=52260.msg605094#msg605094), so he might be able to explain.
-
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.
-
For DCL I am adding this code:
(if (= (strcase (getvar "PROGRAM")) "BRICSCAD")
(if (not ai_dcl) (load "lispex.lsx"))
)
-
If you use the (command), check the keywords because AutoCAD uses Entity somewhere and BricsCAD uses Object.
-
Polygon inside v's radius
Early Bricscad has no "Reverse" for plines use Pedit Pline "R" works both Bricscad and Acad.
-
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 (https://www.theswamp.org/index.php?topic=52260.msg605094#msg605094), so he might be able to explain.
Not my knowledge, but trial and error method used...
-
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.
-
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.
-
Get\Setpropertyvalue is in AutoCAD but not in BricsCAD.
https://help.autodesk.com/view/ACD/2024/ENU/?guid=GUID-8E5913FC-09ED-4C70-AFB7-2431C062E899
-
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.
-
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.
-
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.
Tested: only in >=V22
: (command "_circle" "2,2" 2) nil
: (getpropertyvalue (entlast) "radius") 2.0
-
I have been working with BricsCAD for many years (since V9 and before with LTExtender), I have extracted some annotations and conditions from my Lisp.
I apologize if they are not explained well, I will do so if requested. I hope it's useful.
#BCFlg = BricsCADFLag
(or #BCFlg (command "_.CONVERT" "_HATCH" or "_All" ...)) > not exits
(or cal (if #BCFlg (load "cadcal") (arxload "GEOMCAL")))
(if #BCFlg
(vl-cmdf "_.EXPLODE" SelSet) ; > better
(progn (setvar "QAFLAGS" 1) (vl-cmdf "_.EXPLODE" SelSet "") (setvar "QAFLAGS" 0)); to explode more objects
)
(if (and (null #BCFlg) (> (atof (getvar "ACADVER")) 23.0))
(command "_CLASSICINSERT")
(progn (initdia 1) (command "_.INSERT"))
)
(or #BCFlg (vl-cmdf "_.MLEADER" ... different))
(vl-cmdf "_.ZOOM" "_OBJECT" ...) only in new versions - AutoCAD >19.1 OK
(vla-put-GraphicsWinLayoutBackgrndColor AcDisp (if #BCFlg 255 16777215)) ; in Brics bianco = 255 - il nero è 0
(if #BCFlg (vl-cmdf "_WCLOSEALL" ...) (vl-cmdf "_CLOSEALL" ...))
"_.WBLOCK" (if #BCFlg (strcat FulNam "." FilTyp) FulNam) > BricsCAD need extension
(defun C:ALE_Utl_Redo ( )
(if #BCFlg (command "_redo")(command "_mredo" "1"))
(princ)
)
(if #BCFlg (command "_.PRINT") (progn (initdia) (command "_.PLOT")))
> BricsCAD use only English names
"ISO pagina intera A0 (841 x 1189 mm)" "ISO full bleed A0 (841.00 x 1189.00 MM)"
(if #BCFlg "Print As PDF.pc3" "DWG To PDF.pc3")
(command "_.ZOOM" (strcat "10" (if #BCFlg "XP" "X_P")))
(if #BCFlg
(command "_.POLYGON" "6" pt1 "_S" ...different)
(command "_.POLYGON" "6" pt1 "_C" ...different)
)
(if ;AutoCAD in W7-64 (getvar "PLATFORM") "Microsoft Windows NT Version 6.1 (x64)"
(and; PROCESSOR_ARCHITECTURE restituisce "AMD64" anche su processore Intel ma restituisce "x86" su Bricscad in W7 64bit
(setq PrcArc (getenv "PROCESSOR_ARCHITECTURE"))
(< 1 (strlen PrcArc))
(or (eq "64" (substr PrcArc (1- (strlen PrcArc)))) #BCFlg)
); da migliorare perchè in Bricscad su 32 bit non funziona
(setq SldLib "\\slidelib_x64.exe ")
(setq SldLib "\\slidelib.exe ")
)
#BCFlg > (getenv "DefaultFormatForSave") > nil
; Con BricsCAD (Ita/Eng) la scrittura di valori numerici in Excel (italiano) avviene con la sostituzione del punto
; decimale in virgola al contrario di AutoCAD (Ita/Eng) che lascia il punto
;
(defun MsX_AutoPutNumericValue2 (CelObj ImpVal DecPrc)
(cond
( (null ImpVal) )
( (= ImpVal "") (msxm-Clear CelObj) )
( #BCFlg (msxp-put-Value2 CelObj ImpVal) )
( (= 'STR (type ImpVal)) (msxp-put-Value2 CelObj (vl-string-translate "." "," ImpVal)) )
( T (msxp-put-Value2 CelObj (vl-string-translate "." "," (rtos ImpVal 2 DecPrc))) )
)
(vlax-release-object CelObj)
)
; Function: ALE_Dim_SetChildStyle
;
; Version 1.01 - 10/10/2010
; Description:
; Workaround for Bricscad to use Dimstyles child (0,3)
;
; Examples: (ALE_Dim_SetChildStyle "dimlinear") (ALE_Dim_SetChildStyle "dimangular")
;
;
(defun ALE_Dim_SetChildStyle (DimTyp / CurDSt BasNam)
(if #BCFlg
(progn
(setq
CurDSt (vla-get-Name (vla-get-activedimstyle *AcAcDwg*))
BasNam (vl-string-right-trim "$03" CurDSt)
)
(cond
( (= DimTyp "dimdiameter")
(cond ; $3 Stile per diametri
( (wcmatch CurDSt "*$3") )
( (tblsearch "DIMSTYLE" (strcat BasNam "$3"))
(command "_.DIMSTYLE" "_RESTORE" (strcat BasNam "$3"))
)
( (and (wcmatch CurDSt "*$#") (tblsearch "DIMSTYLE" BasNam))
(command "_.DIMSTYLE" "_RESTORE" BasNam)
)
)
)
( (wcmatch DimTyp "dimlinear,dimcontinue,dimaligned,dimbaseline")
(cond ; $0 Stile lineare ISO-25 (tipi allineati e ruotati)
( (wcmatch CurDSt "*$0") )
( (tblsearch "DIMSTYLE" (strcat BasNam "$0"))
(command "_.DIMSTYLE" "_RESTORE" (strcat BasNam "$0"))
)
( (and (wcmatch CurDSt "*$#") (tblsearch "DIMSTYLE" BasNam))
(command "_.DIMSTYLE" "_RESTORE" BasNam)
)
)
)
( (and (wcmatch CurDSt "*$#") (tblsearch "DIMSTYLE" BasNam))
(command "_.DIMSTYLE" "_RESTORE" BasNam)
)
)
)
)
(princ)
)
-
I have noticed that BricsCAD has additional functionality over AutoCAD in Supporting VisualLISP Extension Functions Library, which are not inbuilt in AutoCAD. See below link :-
https://developer.bricsys.com/bricscad/help/en_US/V23/DevRef/source/VLELISPFunctionLibrary.htm (https://developer.bricsys.com/bricscad/help/en_US/V23/DevRef/source/VLELISPFunctionLibrary.htm)
Correct me if I'm wrong.
-
I have noticed that BricsCAD has additional functionality over AutoCAD in Supporting VisualLISP Extension Functions Library, which are not inbuilt in AutoCAD. See below link :-
https://developer.bricsys.com/bricscad/help/en_US/V23/DevRef/source/VLELISPFunctionLibrary.htm (https://developer.bricsys.com/bricscad/help/en_US/V23/DevRef/source/VLELISPFunctionLibrary.htm)
Correct me if I'm wrong.
you wrote correctly:
As vle-extension.lsp uses pure AutoLISP code only, it will work not only under Windows, but also running Linux and Macintosh OS.
Compatibility with AutoCAD and other AutoLISP-compatible CAD systems
We provide an emulation Lisp file vle-extension.lsp, installed with each BricsCAD version, and part of this package - this defines all VLE functions, if not provided as built-in functions.
To keep AutoLISP code compatible under all BricsCAD and AutoCAD platforms and versions, AutoLISP applications can simply load the file vle-extension.lsp in AutoCAD and BricsCAD, under all versions; as BricsCAD V12.2 and higher provide these VLE functions 'built-in', loading this file has no impact at all (VLE functions from this file are only defined when the built-in functions are not present).
Because the BricscCAD built-in VLE function set will grow with each BricsCAD version, it is a good idea to load this file under BricsCAD always (taken from the latest version of BricsCAD, copied to the application).
All those VLE functions, which have no useful meaning under AutoCAD, are implemented as 'no operation', so AutoLISP code is not affected in negative sense.
-
where can I download the vle-extension.lsp file?
-
It is worth noting that the vle-extensions.lsp is provided purely to facilitate compatibility with AutoCAD and other platforms which support the LISP API; on BricsCAD, the functions defined within vle-extensions.lsp are implemented directly in C++, offering a significant performance advantage.
-
It is worth noting that the vle-extensions.lsp is provided purely to facilitate compatibility with AutoCAD and other platforms which support the LISP API; on BricsCAD, the functions defined within vle-extensions.lsp are implemented directly in C++, offering a significant performance advantage.
ok!
but where can I download vle-extensions.lsp ?
. . . just to take a look at it !
-
It is worth noting that the vle-extensions.lsp is provided purely to facilitate compatibility with AutoCAD and other platforms which support the LISP API; on BricsCAD, the functions defined within vle-extensions.lsp are implemented directly in C++, offering a significant performance advantage.
ok!
but where can I download vle-extensions.lsp ?
. . . just to take a look at it !
https://boa.bricsys.com/applications/a/?lisp-developer-support-package-(ldsp)-a720-al1176
-
@lee mac
Thank you
-
Has anyone tried BricsCAD v 24 Beta ?
Any significant improvements found with respect to VLisp ?