Author Topic: Where is the error?  (Read 2015 times)

0 Members and 2 Guests are viewing this topic.

andy_lee

  • Newt
  • Posts: 147
Where is the error?
« on: November 24, 2014, 06:27:06 AM »
Code - Auto/Visual Lisp: [Select]
  1.       (if (progn (princ "\nSelect the block<Enter to Select Range>...")
  2.                  (setq blk (car (ssget ":S" '((0 . "insert")))))
  3.           )
  4.         (progn
  5.           (vla-getboundingbox
  6.             (vlax-ename->vla-object (ssname blk 0))
  7.             'bp
  8.             'up
  9.           )
  10.           (setq scl (list (safearray-value bp) (safearray-value up)))
  11.         )
  12.         (setq scl (_rectang:scale))
  13.       )
  14.  

When choose the block,  Error: bad argument type: consp <Selection set: 2>

try again:
bad argument type: consp <Selection set: 17>
try again:
 bad argument type: consp <Selection set: 22>

Use Vlide ---> debug, break at :
(setq blk (car (ssget ":S" '((0 . "insert")))))

How modify it ?
andy.
Best regards.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Where is the error?
« Reply #1 on: November 24, 2014, 06:47:27 AM »
What does this return ?

Code - Auto/Visual Lisp: [Select]
  1. (ssget ":S" '((0 . "insert")))


Is it a list ?

If not, why use car ?

Would this do the job ?

Note that the ":S" may not mean what you think it means.

Code - Auto/Visual Lisp: [Select]
  1.  
  2. (if (progn (princ "\nSelect the block<Enter to Select Range>...")
  3.            (setq ss (ssget ":S" '((0 . "insert"))))
  4.     )
  5.   (progn (vla-getboundingbox (vlax-ename->vla-object (ssname ss 0))
  6.                              'bp
  7.                              'up
  8.          )
  9.          (setq scl (list (safearray-value bp) (safearray-value up)))
  10.   )
  11.   (setq scl (_rectang:scale))
  12. )
  13.  
  14.  
  15.                "\n"
  16.                (vl-prin1-to-string (safearray-value up))
  17.        )
  18. )
  19.  
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Where is the error?
« Reply #2 on: November 24, 2014, 06:57:34 AM »
I suspect this may also do the job

Code - Auto/Visual Lisp: [Select]
  1. (if (setq ent (car (entsel "\nSelect Block: ")))
  2.   (progn (vla-getboundingbox (vlax-ename->vla-object ent) 'bp 'up)
  3.          (setq scl (list (safearray-value bp) (safearray-value up)))
  4.   )
  5.   (setq scl (_rectang:scale))
  6. )
  7.  
  8.                "\n"
  9.                (vl-prin1-to-string (safearray-value up))
  10.        )
  11. )
  12.  
  13.  
  14.  
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

andy_lee

  • Newt
  • Posts: 147
Re: Where is the error?
« Reply #3 on: November 24, 2014, 07:40:47 AM »
Hi kerry !
Thank you very much!

Take a look
Code - Auto/Visual Lisp: [Select]
  1. (defun c:tt (/                _string:decimal              _changescale
  2.              _rectang:scale           scl              height         str
  3.              ds                nscl           kw              bp         up
  4.              blk
  5.             )
  6.   (defun _string:decimal (val / str)
  7.     (setvar "dimzin" 0)
  8.     (setq str (rtos val 2 2)
  9.           str (vl-string-right-trim "0" str)
  10.           str (vl-string-right-trim "." str)
  11.     )
  12.   )
  13.   (defun _changescale (h str)
  14.     (vlax-for obj (fy:cset)
  15.       (if (wcmatch (vla-get-objectname obj) "*Text")
  16.         (vlax-put obj 'height h)
  17.         (vlax-put obj 'stylename str)
  18.       )
  19.     )
  20.   )
  21.   (defun _rectang:scale        (/ p1 p2 str lst v scl kw)
  22.     (if
  23.       (and
  24.         (setq p1 (getpoint "\nSpecify first corner: "))
  25.         (setq p2 (getcorner p1 "\nSpecify opposite corner: "))
  26.         (progn (initget "0 1 2 3 4")
  27.                (setq kw        (getkword
  28.                           "\nDrawing frame size [A0(0)/A1(1)/A2(2)/A3(3)/A4(4)]: "
  29.                         )
  30.                )
  31.         )
  32.         (setq lst (assoc kw
  33.                          '(("0" 1089 841)
  34.                            ("1" 841 594)
  35.                            ("2" 594 420)
  36.                            ("3" 420 297)
  37.                            ("4" 297 210)
  38.                           )
  39.                   )
  40.         )
  41.       )
  42.        (progn (setq v        (apply 'max (mapcar 'abs (mapcar '- p2 p1)))
  43.                     scl        (/ v (apply 'max (cdr lst)))
  44.               )
  45.               (list (distof (rtos scl 2 1)) p1 p2)
  46.        )
  47.     )
  48.   )
  49.   (fy:begin)
  50.   (if
  51.     (and
  52.       (if (progn (princ "\nSelect the drawing frame(block) Or <Enter to Specify window>...")
  53.                  (setq blk (car (ssget ":S" '((0 . "insert")))))
  54.           )
  55.         (progn
  56.           (vla-getboundingbox
  57.             (vlax-ename->vla-object (ssname blk 0))
  58.             'bp
  59.             'up
  60.           )
  61.           (setq scl (list (safearray-value bp) (safearray-value up)))
  62.         )
  63.         (setq scl (_rectang:scale))
  64.       )
  65.       (progn (princ "\nPrint Scale = ")
  66.              (if (car scl)
  67.                (progn (princ (car scl))
  68.                       (initget 128 "Y N")
  69.                       (setq kw (getkword "\nWhether to accept [Yes(Y)/No(N)]<Y>: "))
  70.                )
  71.                (setq kw "N")
  72.              )
  73.              (if (or (= kw "Y") (= kw ""))
  74.                t
  75.                (if (setq nscl (getreal "\nEnter a new scale : "))
  76.                  (setq (distof (rtos scl 2 1)) (cons nscl (cdr scl)))
  77.                )
  78.              )
  79.       )
  80.       (setq height (getdist "\nText height: "))
  81.       (setq height (fix (+ height 0.5)))
  82.     )
  83.      (progn (setq
  84.               str (vl-string-translate "." "-" (_string:decimal (car scl)))
  85.             )
  86.             (xd::doc:createDimstyleFrom
  87.               nil
  88.               (strcat "FY-" str)
  89.               (cons (list "dimtxt" height)
  90.                     (cons (list "dimscale" (car scl))
  91.                           '(("dimdli" 1.0)
  92.                             ("dimexe" 1.5)
  93.                             ("dimexo" 1.0)
  94.                             ("dimasz" 1.5)
  95.                             ("dimtad" 1)
  96.                             ("dimtix" 1)
  97.                             ("dimtofl" 1)
  98.                             ("dimgap" 1.0)
  99.                             ("dimtih" 0)
  100.                             ("dimdsep" ".")
  101.                             ("dimlunit" 2)
  102.                             ("dimdec" 2)
  103.                            )
  104.                     )
  105.               )
  106.             )
  107.             (mapcar '(lambda (x)
  108.                        (xd::doc:createSubDimstyle
  109.                          (strcat "FY-" str)
  110.                          (car x)
  111.                          (cadr x)
  112.                        )
  113.                      )
  114.                     '(("$2" nil)
  115.                       ("$3" nil)
  116.                       ("$4" (("DIMTOH" 1) ("DIMTIH" 0)))
  117.                       ("$6" nil)
  118.                      )
  119.             )
  120.             (if        (ssget "_C"
  121.                        (cadr scl)
  122.                        (caddr scl)
  123.                        '((0 . "dimension,*text"))
  124.                 )
  125.               (_changescale (* height (car scl)) (strcat "FY-" str))
  126.             )
  127.      )
  128.   )
  129.   (fy:end)
  130.   (princ)
  131. )
  132.  
andy.
Best regards.

ribarm

  • Gator
  • Posts: 3225
  • Marko Ribar, architect
Re: Where is the error?
« Reply #4 on: November 24, 2014, 07:46:26 AM »
emk2012, have you understand what Kerry explained to you? You haven't modified your code according to Kerry's suggestions...
And you are missing some subs like (fy:begin/end)...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Where is the error?
« Reply #5 on: November 24, 2014, 07:47:21 AM »
Quote
Take a look
What am I supposed to be looking at ??
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

andy_lee

  • Newt
  • Posts: 147
Re: Where is the error?
« Reply #6 on: November 24, 2014, 08:01:04 AM »
 :lol:
emk2012, have you understand what Kerry explained to you? You haven't modified your code according to Kerry's suggestions...
And you are missing some subs like (fy:begin/end)...

Hi ribarm , Thank you for your help , you mean lack function ?  name ???

I konw some function need appload XD function lib and FY function lib  eg: xd::doc:createSubDimstyle   , fly:begin/end
That function is not open source .

« Last Edit: November 24, 2014, 08:11:44 AM by emk2012 »
andy.
Best regards.