Author Topic: create selection set of block attribute value range.  (Read 10670 times)

0 Members and 1 Guest are viewing this topic.

krzysiek_jsn

  • Mosquito
  • Posts: 3
Re: create selection set of block attribute value range.
« Reply #15 on: March 21, 2018, 06:33:11 AM »
Hello
I know it's an old post but I have one problem with the attached lisp
it works well with normal blocks but unfortunately dynamic blocks are not selected
I do not know lisp and this program would be very helpful to me
Could you help me?

I'm attaching a test file with my dynamic block
block name "E_dyn"
tag "NR"

(defun c:ssnum ( / num_l num_h )
    (if
        (and
            (setq num_l (getreal "\nEnter min value: "))
            (setq num_h (getreal "\nEnter max value: "))
        )
        (sssetfirst nil (_SelectBlockIfAttInRange "E_dyn" "NR" num_l num_h))
    )
    (princ)
)

Thanks
Krzysiek

ronjonp

  • Needs a day job
  • Posts: 7533
Re: create selection set of block attribute value range.
« Reply #16 on: March 21, 2018, 09:36:43 AM »
Try this mod:
Code - Auto/Visual Lisp: [Select]
  1. (defun _selectblockifattinrange (blk tag lo hi / o s)
  2.   (setq blk (strcase blk)
  3.         tag (strcase tag)
  4.   )
  5.   (cond
  6.     ((setq s (ssget "_X" (list '(0 . "INSERT") '(66 . 1) (cons 2 (strcat "`*U*," blk)))))
  7.      (foreach e (mapcar 'cadr (ssnamex s))
  8.        (cond
  9.          ((or (not (wcmatch
  10.                      (strcase
  11.                        (vlax-get (setq o (vlax-ename->vla-object e))
  12.                                  (cond ((vlax-property-available-p o 'effectivename) 'effectivename)
  13.                                        ('name)
  14.                                  )
  15.                        )
  16.                      )
  17.                      blk
  18.                    )
  19.               )
  20.               (not (vl-some (function (lambda (a)
  21.                                         (and (eq tag (strcase (vla-get-tagstring a)))
  22.                                              (<= lo (atof (vla-get-textstring a)) hi)
  23.                                         )
  24.                                       )
  25.                             )
  26.                             (vlax-invoke o 'getattributes)
  27.                    )
  28.               )
  29.           )
  30.           (ssdel e s)
  31.          )
  32.        )
  33.      )
  34.      (if (< 0 (sslength s))
  35.        s
  36.      )
  37.     )
  38.   )
  39. )
  40. (defun c:test nil (sssetfirst nil (_selectblockifattinrange "E_DYN" "NR" 1. 5.)) (princ))
« Last Edit: March 21, 2018, 09:56:15 AM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

krzysiek_jsn

  • Mosquito
  • Posts: 3
Re: create selection set of block attribute value range.
« Reply #17 on: March 21, 2018, 10:50:08 AM »
Now it is working
You are great :)

Thanks

ronjonp

  • Needs a day job
  • Posts: 7533
Re: create selection set of block attribute value range.
« Reply #18 on: March 21, 2018, 10:54:46 AM »
Now it is working
You are great :)

Thanks
Glad to help :)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Lee Mac

  • Seagull
  • Posts: 12928
  • London, England
Re: create selection set of block attribute value range.
« Reply #19 on: March 21, 2018, 01:33:57 PM »
Just the change from < to <=?

Thanks Ron for replying in my absence.  :-)

krzysiek_jsn

  • Mosquito
  • Posts: 3
Re: create selection set of block attribute value range.
« Reply #20 on: March 21, 2018, 03:24:36 PM »
Thanks Lee
You are doing a great job here