Author Topic: selecting equal z values text  (Read 1321 times)

0 Members and 1 Guest are viewing this topic.

bprabhakar001

  • Guest
selecting equal z values text
« on: March 18, 2014, 05:02:04 AM »
Hi..
I am trying to write a program to find the text having equal zvalues..but some where I was done wrong..please suggest where I have done mistake.
Code - Auto/Visual Lisp: [Select]
  1. (defun c:chlay (/ list1 set1 ename list2 set2)
  2. (if (SETQ list1(ENTGET(CAR(ENTSEL"/select text string" )))) ;select text to move new layer
  3.      (progn
  4.       (setq newlayer (cdr (assoc 1 list1)))
  5.       (command "_.Layer" "_Make" newlayer "_Color" "25" "" "LType" "Continuous" "" "");create layer from the selected string
  6.             (setq set1 (ssget "x" (list (assoc 0 list1) (assoc 1 list1)))); create selection set with selected string
  7.              (setq i -1)
  8.        (while (setq ename (ssname set1 (setq i (1+ i))))             ;get the z values from the selected string group
  9.               (setq list2(entget ename))
  10.               (setq set2 (ssget "x"  (list (assoc 11 list2))))
  11.               (command "_change" "P" "" "p" "_la" newlayer "" "")(princ)
  12.        )
  13.   );end progn
  14.        );end if
  15.   )

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: selecting equal z values text
« Reply #1 on: March 18, 2014, 06:18:28 AM »
It would be in the (setq set2 (ssget "x"  (list (assoc 11 list2)))) portion. You're filtering here for X, Y & Z at the same time.

To have it ignore the X & Y, you can add it like so:
Code: [Select]
(setq set2 (ssget "x"  (list '(-4 . "*,*,=") (assoc 11 list2))))BTW, why code 11? Why not 10? 11 only exists if the text isn't justified with normal Left.

And also, a possible problem you might run into is the restriction on active selection sets. You'll need to set the variable to nil and run gc to clear the selection sets as they're created within loops - so you can have many 1000's of selection sets - this will error.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

bprabhakar001

  • Guest
Re: selecting equal z values text
« Reply #2 on: March 18, 2014, 12:34:36 PM »
Hi..thank you for the vaild suggestions..after so many years I have done this for my friend request..some how activex not working in my 64bit os..thats why I restricted to this method..
Code - Auto/Visual Lisp: [Select]
  1. (defun c:chlay (/ list1 set1 ename list2 set2)
  2.  
  3. (if (SETQ list1(ENTGET(CAR(ENTSEL"/select text string" )))) ;select text to move new layer
  4.      (progn
  5.       (setq newlayer (cdr (assoc 1 list1)))
  6.       (command "_.Layer" "_Make" newlayer "_Color" "25" "" "LType" "Continuous" "" "");create layer from the selected string
  7.             (setq set1 (ssget "x" (list (assoc 0 list1) (assoc 1 list1)))); create selection set with selected string
  8.              (setq i -1)
  9.        (while (setq ename (ssname set1 (setq i (1+ i))))             ;get the z values from the selected string group
  10.               (setq list2(entget ename))
  11.               (setq elev (car(cdddr (assoc 10 list2))))
  12.               (setq set2 (ssget "X"
  13.                   (list '(-4 . "<OR")
  14.                         (cons 38 elev)
  15.                         '(-4 . "*,*,=")
  16.                         (list 10 0.0 0.0 elev)
  17.                         '(-4 . "*,*,=")
  18.                         (list 11 0.0 0.0 elev)
  19.                         '(-4 . "OR>")
  20.                   )
  21.            )
  22.   )
  23.               (command "_change" "P" "" "p" "_la" newlayer "" "")
  24.        )
  25.   );end progn
  26.        );end if
  27.   )