Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

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).

  • 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.
Origami
Origami is the Japanese word for paper folding. ORI means to fold and KAMI means paper and involves the creation of paper forms usually entirely by folding.

Powered by VanillaForums, Designed by Steam