Converting from AutoCAD to BricsCAD

I have a custom command previously used in AutoCAD but now am getting some errors when the same command is used in BricsCAD. Just wondering if someone would be able to help me out here as I have next to no experience in writing up commands in LISP/other.
the error in the prompt when the command is initiated is:

; ----- LISP : Call Stack -----
; [0]...C:WBL
; [1].....HMSTXT <<--
;
; ----- Error around expression -----
(CHR 39)
;
; error : immutable-binding <T> ; expected NIL at [setq]
: 

(DEFUN c:WBDL ()
(modes '("cmdecho" "osmode"))
(setvar "CMDECHO" 0)
;(checkplan)
(if (= wbdl1 nil) (progn
(setq sc (getreal "\n* Enter Plotting Scale [100,200,500,etc] : "))
(setq th (* (/ sc 1000.0) 2))
(command "style" "bearing" "" th 0.8 0.0 "" "" "")
(command "style" "distance" "" th 0.8 15.0 "" "" "")
(setq layb (getstring "\n* Enter layer for bearings : ")
layd (getstring "\n* Enter layer for distances : ")
wbdl1 1)
))

; (command "layer" "M" lay "")
(setq ll (sslength (setq l (ssget))))
(while (/= 0 ll)
(setq ll (1- ll))
(setq le (entget (ssname l ll )))
(SETQ P1 (CDR (assoc 10 le)) )
(SETQ P2 (CDR (assoc 11 le)) )
(SETQ DST (DISTANCE P1 P2))
(SETQ BRG (+ (getvar "userr4") (cts (ANGLE P1 P2))))
(SETQ BRGTXT (HMSTXT BRG))
(ls layb)
(wtxt brgtxt p1 p2 "Above" "BEARING" -0.5)
(SETQ DSTTXT (RTOS DST 2 3))
(ls layd)
(wtxt dsttxt p1 p2 "Below" "DISTANCE" -0.5)
)
(moder)
nil

)

Comments

  • According to the 'Call stack' the error occurs in the HMSTXT function which has not been supplied. Judging from the error message an attempt is made to change the value of the T variable which is not allowed as it has a special meaning (T=True).

  • kyleelkenhans
    edited June 2017

    @Roy Klein Gebbinck said:
    According to the 'Call stack' the error occurs in the HMSTXT function which has not been supplied. Judging from the error message an attempt is made to change the value of the T variable which is not allowed as it has a special meaning (T=True).

    Here's the function for HMSTXT;

    ;(DEFUN HMSTXT (B / t h ms m s rs acc)
     (defun hmstxt (b)
        (SETQ ACC (getvar "USERI1"))
        (SETQ H (FIX B ))
        (SETQ MS (* (FRC B ) 60.0))
        (SETQ M (FIX MS))
        (SETQ S (* (FRC MS) 60.0))
        (SETQ RS (RNDOFF S acc))
        (if (= rs 60) (progn (setq rs 0)
                             (setq m (1+ m))
                       ))
        (if (= m 60) (progn (setq m 0)
                            (setq h (1+ h))
                       ))
        (setq t (STRCAT (ITOA H) "%%d" (ITOA M) (CHR 39) ))
        (IF (/= RS 0 ) (setq t (STRCAT t (ITOA RS) (CHR 34) )))
        t
    )
    

    would it be the variable "t" causing the issue?

  • Yes, try avoiding all lisp variables for your variables.
  • Same applies for the 'nil' variable/symbol ... both 't' and 'nil' are protected symbols (not so in AutoLISP) ...
    when 't' is redefined like here, some other Lisp code could fail :
    (if (= myVar t) ....

    as 't' is now a string :-)

This discussion has been closed.

Howdy, Stranger!

It looks like you're new here. Click one of the buttons on the top bar to get involved!