Author Topic: Need some lisp code error message help:  (Read 1249 times)

0 Members and 1 Guest are viewing this topic.

dubb

  • Swamp Rat
  • Posts: 1105
Need some lisp code error message help:
« on: December 16, 2016, 06:32:09 PM »
Code: [Select]
(vl-load-com)
(setq acadObj (vlax-get-acad-object))
(setq acDoc (vlax-get-property acadObj 'ActiveDocument))
(setq acDocSumInfo (vlax-get-property acDoc 'SummaryInfo))
(setq stdsearch (cdr (assoc style jur)))
(cond ((/= (tblsearch "dimstyle" stdsearch) nil)
       (setq dstyl (vla-item (vla-get-dimstyles acDoc) stdsearch))
       (vla-put-activedimstyle acDoc dstyl)
       )
      )
(cond ((/= (tblsearch "style" stdsearch) nil)
       (setvar "textstyle" stdsearch)     
    )
      )
  (princ)
  )
(setq sd-std (list
        (cons 'dim "sd-anno-dim")
        (cons 'txt "simplex_sd_anno-0.08")
        (cons 'address "simplex_sd_anno-0.10")         
        (cons 'street "simplex_sd_anno-0.125")
        )
      )
(setq jurstd "sd-std") ;registry
  (cond
    ((= style standard)
     (std 'txt jurstd))
    ((= style street)
     (std 'street jurstd))
    ((= style address)
     (std 'address jurstd))
        )
  (command "clayer" "label")
  (COMMAND "MTEXT" PAUSE "r" pause "c" "n" "w" "0")
  (princ)
    )

The error  :tickedoff:
Code: [Select]
; error: bad argument type: listp "sd-std"
I tried to convert with (read) but still not working. The above is a snippet of the portion of the code I need to get working. This is my first time really getting into constructing lists. Please help, thanks.
« Last Edit: December 17, 2016, 09:14:08 AM by CAB »

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2148
  • class keyThumper<T>:ILazy<T>
Re: Need some help:
« Reply #1 on: December 16, 2016, 06:58:59 PM »

Firstly, your sample has a couple of additional parenthesis ....

Second : It's difficult to test code that isn't complete.
What are the parameters style and jur ?

Code: [Select]
(setq stdsearch (cdr (assoc style jur)))
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2148
  • class keyThumper<T>:ILazy<T>
Re: Need some help:
« Reply #2 on: December 16, 2016, 07:05:13 PM »

Code: [Select]
(setq sd-std (list (cons 'dim "sd-anno-dim")
   (cons 'txt "simplex_sd_anno-0.08")
   (cons 'address "simplex_sd_anno-0.10")
   (cons 'street "simplex_sd_anno-0.125")
     )
)

Returns
Code: [Select]
((DIM . "sd-anno-dim") (TXT . "simplex_sd_anno-0.08") (ADDRESS . "simplex_sd_anno-0.10") (STREET . "simplex_sd_anno-0.125"))


What do you imagine this should do ?

Code: [Select]
(cond ((= style standard) (std 'txt jurstd))
      ((= style street) (std 'street jurstd))
      ((= style address) (std 'address jurstd))
)


Could you be a little more explicit regarding the location of the cause error message. ?
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2148
  • class keyThumper<T>:ILazy<T>
Re: Need some help:
« Reply #3 on: December 16, 2016, 07:11:03 PM »

I'm guessing :

Is this what you are trying to achieve ?

Code: [Select]
(cdr (assoc 'txt sd-std))  ;-> "simplex_sd_anno-0.08"
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

dubb

  • Swamp Rat
  • Posts: 1105
Re: Need some help:
« Reply #4 on: December 16, 2016, 07:56:34 PM »
Sorry for the confusion. I have multiple lisp files. I combined them into one.
Code: [Select]
;;start of
;;sup-registry.lsp
;setup registry
(setq SUPReg (strcat "HKEY_CURRENT_USER\\" (vlax-product-key)"\\Profiles\\"(getvar "cprofile") "\\SUP-Settings")) ;registry to be created
;make registry
(defun regMk (name value /)
  (vl-registry-write SUPReg name value)
  (princ)
  )
;check if a registry exist
(defun regchk (name /)
  (print (vl-registry-read SUPReg name))
  (princ)
  )
;list registry available
(defun reglist ()
  (print (vl-registry-descendents SUPReg ""))
  (princ)
  )

;;start of
;;standards.lsp
(vl-load-com)
(setq acadObj (vlax-get-acad-object))
(setq acDoc (vlax-get-property acadObj 'ActiveDocument))
(setq acDocSumInfo (vlax-get-property acDoc 'SummaryInfo))
(setq sd-std (list
  (cons 'dim "sd-anno-dim")
  (cons 'txt "simplex_sd_anno-0.08")
  (cons 'address "simplex_sd_anno-0.10")        
  (cons 'street "simplex_sd_anno-0.125")
  )
      )
(setq sd-full (list
  (cons 'dim "sd-anno-dim-full")
  (cons 'txt "simplex_sd_anno-0.10")
  (cons 'address "simplex_sd_anno-0.15")        
  (cons 'street "simplex_sd_anno-0.20")
)
      )
 ;general standard list
 (setq gen-std (list
  (cons 'dim "sup-anno-dim")
  (cons 'tc-dim "sup-anno-tc-dim")
  (cons 'profile-dim "sup-anno-dim-profile")
  (cons 'txt "SIMPLEX_ANNO-0.08")
  (cons 'address "SIMPLEX_ANNO-0.10")        
  (cons 'street "SIMPLEX_ANNO-0.125")
  )
      )

(defun std (style jur / )

;san diego standard list
  (setq stdsearch (cdr (assoc style jur)))
(cond ((/= (tblsearch "dimstyle" stdsearch) nil)
       (setq dstyl (vla-item (vla-get-dimstyles acDoc) stdsearch))
       (vla-put-activedimstyle acDoc dstyl)
       )
      )
(cond ((/= (tblsearch "style" stdsearch) nil)
       (setvar "textstyle" stdsearch)     
    )
      )
  (princ)
  )

;;start of
;;drwtxt.lsp
;;this function needs to be rwritten so that I can pull registry entry. depending on the registry entry the styles will be set accordinly
;;I am trying to shorten my conditional statements from a value I call from reading from the registry
(defun drwtxt(style)
(setq jurs (vl-registry-read SUPReg "std"))
  (if (= jurs "gen-std")
    (cond   
     ((= style "standard")
  (std 'txt gen-std))
    ((= style "street")
  (std 'street gen-std))
    ((= style "address")
  (std 'address gen-std))
        )
    )
    (if (= jurs "sd-std")
    (cond   
     ((= style "standard")
  (std 'txt sd-std))
    ((= style "street")
  (std 'street sd-std))
    ((= style "address")
  (std 'address sd-std))
        )
    )
      (if (= jurs "sd-full")
    (cond   
     ((= style "standard")
  (std 'txt sd-full))
    ((= style "street")
  (std 'street sd-full))
    ((= style "address")
  (std 'address sd-full))
        )
    )
  (command "clayer" "label")
  (COMMAND "MTEXT" PAUSE "r" pause "c" "n" "w" "0")
  (princ)
    )

In drwtxt.lsp I am trying to shorten that code up more. but I am having trouble with using a value in registry.

I am trying to use
Code: [Select]
  (cond
    ((= style standard)
  (std 'txt jurs))
    ((= style street)
  (std 'street jurs))
    ((= style address)
  (std 'address jurs))
        )
« Last Edit: December 16, 2016, 08:04:06 PM by dubb »

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2148
  • class keyThumper<T>:ILazy<T>
Re: Need some help:
« Reply #5 on: December 16, 2016, 09:49:51 PM »
I believe you will be more joyful if the keys atr strings rather than symbols.
This seems to work for me with limited testing.

I've made no attempt to optimise the code

Code - Auto/Visual Lisp: [Select]
  1. (setq SUPReg (strcat "HKEY_CURRENT_USER\\"
  2.                      (vlax-product-key)
  3.                      "\\Profiles\\"
  4.                      (getvar "cprofile")
  5.                      "\\SUP-Settings"
  6.              )
  7. )                                                           ;registry to be created
  8.                                                             ;make registry
  9. (defun regMk (name value /)
  10.   (vl-registry-write SUPReg name value)
  11.   (princ)
  12. )
  13.                                                             ;check if a registry exist
  14. (defun regchk (name /) (print (vl-registry-read SUPReg name)) (princ))
  15.                                                             ;list registry available
  16. (defun reglist () (print (vl-registry-descendents SUPReg "")) (princ))
  17.  
  18. ;;start of
  19. ;;standards.lsp
  20. (setq acDoc (vlax-get-property acadObj 'ActiveDocument))
  21. (setq acDocSumInfo (vlax-get-property acDoc 'SummaryInfo))
  22. (setq sd-std (list (cons "DIM"          "sd-anno-dim")
  23.                    (cons "TXT"          "simplex_sd_anno-0.08")
  24.                    (cons "ADDRESS"      "simplex_sd_anno-0.10")
  25.                    (cons "STREET"       "simplex_sd_anno-0.125")
  26.              )
  27. )
  28. (setq sd-full (list (cons "DIM"         "sd-anno-dim-full")
  29.                     (cons "TXT"         "simplex_sd_anno-0.10")
  30.                     (cons '"ADDRESS"    "simplex_sd_anno-0.15")
  31.                     (cons "STREET"      "simplex_sd_anno-0.20")
  32.               )
  33. )
  34.                                                             ;general standard list
  35. (setq gen-std (list (cons "DIM"         "sup-anno-dim")
  36.                     (cons "TC-DIM"      "sup-anno-tc-dim")
  37.                     (cons "PROFILE-DIM" "sup-anno-dim-profile")
  38.                     (cons "TXT"         "SIMPLEX_ANNO-0.08")
  39.                     (cons "ADDRESS"     "SIMPLEX_ANNO-0.10")
  40.                     (cons "STREET"      "SIMPLEX_ANNO-0.125")
  41.               )
  42. )
  43.  
  44. (defun std (key data / stdsearch)                                   ;san diego standard list
  45.   (setq stdsearch (cdr (assoc key data)))
  46.   (cond ((/= (tblsearch "dimstyle" stdsearch) nil)
  47.          (setq dstyl (vla-item (vla-get-dimstyles acDoc) stdsearch))
  48.          (vla-put-activedimstyle acDoc dstyl)
  49.         )
  50.   )
  51.   (cond ((/= (tblsearch "style" stdsearch) nil)
  52.          (setvar "textstyle" stdsearch)
  53.         )
  54.   )
  55.   (princ)
  56. )
  57.  
  58. ;;start of
  59. ;;drwtxt.lsp
  60. ;;this function needs to be rwritten so that I can pull registry entry. depending on the registry entry the styles will be set accordinly
  61. ;;I am trying to shorten my conditional statements from a value I call from reading from the registry
  62. ;;
  63. (defun drwtxt (style / jurs)
  64.   (setq jurs (vl-registry-read SUPReg "std"))
  65.   (if (= jurs "gen-std")
  66.     (cond ((= style "standard") (std "TXT" gen-std))
  67.           ((= style "street")   (std "STREET" gen-std))
  68.           ((= style "address")  (std "ADDRESS" gen-std))
  69.     )
  70.   )
  71.   (if (= jurs "sd-std")
  72.     (cond ((= style "standard") (std "TXT" sd-std))
  73.           ((= style "street")   (std "STREET" sd-std))
  74.           ((= style "address")  (std "ADDRESS" sd-std))
  75.     )
  76.   )
  77.   (if (= jurs "sd-full")
  78.     (cond ((= style "standard") (std "TXT" sd-full))
  79.           ((= style "street")   (std "STREET" sd-full))
  80.           ((= style "address")  (std "ADDRESS" sd-full))
  81.     )
  82.   )
  83.   (command "clayer" "label")
  84.   (COMMAND-s "MTEXT" PAUSE "r" pause "c" "n" "w" "0")
  85. )
  86.  
  87. ;;//-------------------------------
  88.  
  89.  
  90.  
  91.  
  92. ;; (regMk "std" "gen-std")
  93. ;; (regchk "std")  ;-> "gen-std"
  94.  
  95.  
  96. ;; (drwtxt "standard")
  97.  
  98.  
  99.  
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

dubb

  • Swamp Rat
  • Posts: 1105
Re: Need some help:
« Reply #6 on: December 16, 2016, 10:58:46 PM »
Thanks, I kinda had a feeling it had something to do with how I cons the lists. And thanks, now I know they are called symbols. This seems like it will work. I haven't tested it. I thought using symbols in a dotted pair was a preferred method.