Author Topic: wcmatch special character problems  (Read 1933 times)

0 Members and 1 Guest are viewing this topic.

GDF

  • Water Moccasin
  • Posts: 2081
wcmatch special character problems
« 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  "[ , ]")
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

ronjonp

  • Needs a day job
  • Posts: 7526
Re: wcmatch special character problems
« Reply #1 on: December 07, 2015, 02:14:24 PM »
Maybe?
Code - Auto/Visual Lisp: [Select]
  1. (wcmatch txtx "*,*")

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

ribarm

  • Gator
  • Posts: 3225
  • Marko Ribar, architect
Re: wcmatch special character problems
« Reply #2 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
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: wcmatch special character problems
« Reply #3 on: December 07, 2015, 02:47:01 PM »
(wcmatch text "*`,*")
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

GDF

  • Water Moccasin
  • Posts: 2081
Re: wcmatch special character problems
« Reply #4 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)
)
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

ronjonp

  • Needs a day job
  • Posts: 7526
Re: wcmatch special character problems
« Reply #5 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 . "*`,*`,*")))

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

GDF

  • Water Moccasin
  • Posts: 2081
Re: wcmatch special character problems
« Reply #6 on: December 07, 2015, 04:16:08 PM »
Sweet

Thanks
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64