Author Topic: Mtext lwpolyine search  (Read 1568 times)

0 Members and 1 Guest are viewing this topic.

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Mtext lwpolyine search
« on: July 07, 2008, 04:42:00 PM »

I need to be able to search through a series of lwpolylines and check to see if more then 1 (one) instance of mtext resided within it's boundary. Once found it will hatch the all pertinent lwpolylines if any. Any ideas?

Thanks,

Donald
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023

Arch_Eric

  • Guest
Re: Mtext lwpolyine search
« Reply #1 on: July 07, 2008, 05:03:22 PM »
Got a DWG for an example?

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Mtext lwpolyine search
« Reply #2 on: July 07, 2008, 05:19:09 PM »
Give this a whirl:

Code: [Select]
;;all object must be visible on screen when selected
(defun c:textinpoly (/ ss ss2 pl)
  (if (setq ss (ssget '((0 . "LWPOLYLINE"))))
    (foreach pl (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
      (if (and (setq ss2 (ssget "wp"
(rjp-getpolypoints pl)
(list (cons 0 "MTEXT"))
)
       )
       (> (sslength ss2) 1)
  )
(command "-hatch" "s" pl "" "")
      )
    )
  )
  (princ)
)

(defun rjp-getpolypoints (ent / e lst)
  (foreach e (entget ent)
    (if (member (car e) '(10))
      (setq lst (cons (list (cadr e) (caddr e)) lst))
    )
  )
  (reverse lst)
)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Re: Mtext lwpolyine search
« Reply #3 on: July 08, 2008, 01:49:20 PM »
Code: [Select]
;;all object must be visible on screen when selected
(defun c:textinpoly (/ ss ss2 pl)
  (if (setq ss (ssget '((0 . "LWPOLYLINE"))))
    (foreach pl (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
      (if (and (setq ss2 (ssget "wp"
(rjp-getpolypoints pl)
(list (cons 0 "MTEXT"))
)
       )
       (> (sslength ss2) 1)
  )
(command "-hatch" "s" pl "" "")
      )
    )
  )
  (princ)
)

(defun rjp-getpolypoints (ent / e lst)
  (foreach e (entget ent)
    (if (member (car e) '(10))
      (setq lst (cons (list (cadr e) (caddr e)) lst))
    )
  )
  (reverse lst)
)

Thanks Ronjonp, This did the trick. Now I just need to reverse engineer your code to see how it works.

Thanks again.

Donald
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Mtext lwpolyine search
« Reply #4 on: July 08, 2008, 01:52:00 PM »
You're welcome.  :-)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC