TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: GDF on December 07, 2015, 02:10:18 PM

Title: wcmatch special character problems
Post by: GDF on December 07, 2015, 02:10:18 PM
doing:
(setq TXTX (cdr (assoc 1 (entget (entlast)))))

gets this string:
"7'-0" CLEAR HEAD HEIGHT, CLEARANCE AT TOP STAIR, LANDING @ 11'-3 7/8" AFF"

can't get this to work:
(wcmatch TXTX  "[ , ]")
Title: Re: wcmatch special character problems
Post by: ronjonp on December 07, 2015, 02:14:24 PM
Maybe?
Code - Auto/Visual Lisp: [Select]
  1. (wcmatch txtx "*,*")
Title: Re: wcmatch special character problems
Post by: ribarm on December 07, 2015, 02:30:47 PM
Code: [Select]
Command: (vl-string-search "," txtx)
23

Command: (vl-string-search "," txtx 24)
47

Command: (wcmatch txtx "*, *")
T
Title: Re: wcmatch special character problems
Post by: MP on December 07, 2015, 02:47:01 PM
(wcmatch text "*`,*")
Title: Re: wcmatch special character problems
Post by: GDF on December 07, 2015, 03:42:42 PM
Thanks
I thought I had tried all of the options.
Only have two "," in the text placed in the drawing from another routine.
This is an old clunky routine, but for now it works.

result:
7'-0" CLEAR HEAD HEIGHT
CLEARANCE AT TOP STAIR
LANDING @ 11'-3 7/8" AFF

from the original post above:
7'-0" CLEAR HEAD HEIGHT, CLEARANCE AT TOP STAIR, LANDING @ 11'-3 7/8" AFF

This code used twice in the main routine:
Code: [Select]
(setq TXTX (cdr (assoc 1 (entget (entlast)))))
 (if (wcmatch TXTX "*`,*")(BTXit))
     

   

Code: [Select]
;;;Break text original by
;;;written: Andrzej GUMULA     agumula@transprojekt.com.pl

(defun BTXIT (/ ELEM ETYK CM OS OLDERR PTW PT10 TMP ODL OPIS TBOX ITEM)
  (defun XY (A) (list (car A) (cadr A))) ;end xy
  (defun DXF (A B) (cdr (assoc A B))) ;end dxf
  (defun STRIM (A)
    (while (member (substr A 1 1) (list " " "." ";" ","))
      (setq A (substr A 2))
    ) ;_ end of while
    A
  ) ;end strim
  (defun PRPT (A B)
    (if (not (assoc A ELEM))
      (setq ELEM (append ELEM (list (cons A B))))
    ) ;_ end of if
    ELEM
  ) ;end prpt 
  (setvar "CMDECHO" 0)
  (setvar "OSMODE" 0)
  (setvar "UCSFOLLOW" 0)
  (command "_undo" "_be")
 
     (if (and (setq ELEM (entget (entlast)))
     (eq (DXF 0 ELEM) "TEXT")
)
      (progn (setq PTW (XY (trans (cdr (assoc 10 ELEM)) 1 0)))
     (command "_ucs" "_ob" (cdar ELEM))
     (setq PTW (trans PTW 0 1)
   OPIS (DXF 1 ELEM)
   ITEM 1
   TEMP 0.0
     )

     (while (or (not (member (substr OPIS ITEM 1)
     (list ",")
     )
)
(< TEMP (car PTW))
    ) ;_ end of or
       (setq TBOX (textbox (subst (cons 1 (substr OPIS 1 ITEM))
  (assoc 1 ELEM)
  ELEM
   )
  ) ;_ end of textbox
     TEMP (- (caadr TBOX) (caar TBOX))
     ITEM (1+ ITEM)
       )
     )
             
     (entmod (subst (cons 1 (substr OPIS 1 (1- ITEM)))
    (cons 1 OPIS)
    ELEM
     )
     )
     (setq A (append A (list '(62 . 4))))
     (PRPT 62 256)
     (PRPT 6 "BYLAYER")
     (entmake
       (subst (cons 1 (STRIM (substr OPIS (1+ ITEM))))
      (cons 1 OPIS)
      ELEM
       )
     )
     (command "_move"
      (entlast)
      ""
      "0,0"
      (list 0 (- (* 1.4 (DXF 40 ELEM))))
     )         
      )     
    )   
    (command "_ucs" "_p")   
  (command "_undo" "_e")
  (princ)
)
Title: Re: wcmatch special character problems
Post by: ronjonp on December 07, 2015, 03:59:39 PM
If you're looking for text with two commas, you could use a filter like so:
Code - Auto/Visual Lisp: [Select]
  1. (SSGET "_x" '((0 . "TEXT")(1 . "*`,*`,*")))
Title: Re: wcmatch special character problems
Post by: GDF on December 07, 2015, 04:16:08 PM
Sweet

Thanks