+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13
  1. #1
    Senior Member
    Using
    AutoCAD 2015
    Join Date
    Mar 2016
    Posts
    155

    Default Select text below a LINE

    Registered forum members do not see this ad.

    is it possible on autolisp to select all text below the line? we always deal with data like these, and I'm just thinking maybe i could ask your help if it is possible to select all text below a line...
    BTW, the dxf/dwg files are always in clockwise, and due north(270)
    and all lines starts from north going down, so that all angles will never be GREATER THAN 270 OR LESSER THAN 90

    i attached a sample dxf and that is just a tiny portion, does anyone know a way?
    Attached Files

  2. #2
    Senior Member
    Using
    AutoCAD 2009
    Join Date
    Oct 2012
    Posts
    355

    Default

    In what form should the final result be?
    Software development
    Batch printing drawings from model and printing PDF to different printers
    https://www.kdmsoft.net

  3. #3
    Quantum Mechanic BIGAL's Avatar
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    10,792

    Default

    Try this

    Code:
    ; look for text below a line
    ; by alan H Aug 2018
    (defun c:test ( / ss sstxt endpt stpt pt pt2)
    (setq ss (ssget (list (cons 0 "Line"))))
    (setq oldsnap (getvar 'osmode))
    (setvar 'osmode 0)
    (repeat (setq x (sslength ss))
    (setq obj (vlax-ename->vla-object (ssname ss (setq x (- x 1)))))
    (setq stpt   (vlax-curve-getstartPoint Obj)
        endpt  (vlax-curve-getEndPoint Obj)
    	ang (angle stpt endpt)
    	dist (/ (distance stpt endpt) 2.0)
    )
    (setq pt (polar stpt ang dist))
    (setq pt (polar pt(+ ang (/ pi 2.0)) 0.001))
    (setq pt2 (polar pt (+ ang (/ pi 2.0))0.5))
    (setq sstxt (ssget "F" (list pt pt2) ))
    (if (/= sstxt nil)
    (progn
    (setq obj (vlax-ename->vla-object(ssname sstxt 0)))
    (if (= (vla-get-objectname obj)"AcDbText")
    (alert (vla-get-textstring obj))
    (alert (vla-get-objectname obj))
    )
    )
    )
    )
    )
    (c:test)
    A man who never made mistakes never made anything

  4. #4
    Senior Member
    Using
    AutoCAD 2015
    Join Date
    Mar 2016
    Posts
    155

    Default

    Quote Originally Posted by BIGAL View Post
    Try this

    Code:
    ; look for text below a line
    ; by alan H Aug 2018
    (defun c:test ( / ss sstxt endpt stpt pt pt2)
    (setq ss (ssget (list (cons 0 "Line"))))
    (setq oldsnap (getvar 'osmode))
    (setvar 'osmode 0)
    (repeat (setq x (sslength ss))
    (setq obj (vlax-ename->vla-object (ssname ss (setq x (- x 1)))))
    (setq stpt   (vlax-curve-getstartPoint Obj)
        endpt  (vlax-curve-getEndPoint Obj)
    	ang (angle stpt endpt)
    	dist (/ (distance stpt endpt) 2.0)
    )
    (setq pt (polar stpt ang dist))
    (setq pt (polar pt(+ ang (/ pi 2.0)) 0.001))
    (setq pt2 (polar pt (+ ang (/ pi 2.0))0.5))
    (setq sstxt (ssget "F" (list pt pt2) ))
    (if (/= sstxt nil)
    (progn
    (setq obj (vlax-ename->vla-object(ssname sstxt 0)))
    (if (= (vla-get-objectname obj)"AcDbText")
    (alert (vla-get-textstring obj))
    (alert (vla-get-objectname obj))
    )
    )
    )
    )
    )
    (c:test)

    BIGAL thank you! this is the one, though i only want to select them not prompt me the value.
    i need to select them so i can do stuffs with them... sorry, that sounded weird >.<"

  5. #5
    Senior Member
    Using
    AutoCAD 2015
    Join Date
    Mar 2016
    Posts
    155

    Default

    Quote Originally Posted by maratovich View Post
    In what form should the final result be?
    nothing sir, i just want to select them so i could change, move rotate or anything

  6. #6
    Senior Member
    Using
    AutoCAD 2009
    Join Date
    Oct 2012
    Posts
    355

    Default

    Check this out:
    Attached Images
    Software development
    Batch printing drawings from model and printing PDF to different printers
    https://www.kdmsoft.net

  7. #7
    Senior Member
    Using
    AutoCAD 2015
    Join Date
    Mar 2016
    Posts
    155

    Default

    Quote Originally Posted by maratovich View Post
    Check this out:
    o you mean which are the ones i need to select?
    its the texts below


    no matter the orientation i need to select only the text below the lines

  8. #8
    Senior Member
    Using
    AutoCAD 2009
    Join Date
    Oct 2012
    Posts
    355

    Default

    Quote Originally Posted by ktbjx View Post
    o you mean which are the ones i need to select?
    Can not you see the red arrow?
    Check the selection ".30 / 17.13"
    Software development
    Batch printing drawings from model and printing PDF to different printers
    https://www.kdmsoft.net

  9. #9
    Super Member
    Computer Details
    ronjonp's Computer Details
    Operating System:
    Windows 10
    Using
    AutoCAD 2018
    Join Date
    Apr 2009
    Location
    Colorado
    Posts
    948

    Default

    Try this .. it's not perfect, but neither is the data.
    Code:
    (defun c:foo (/ _dxf _x c l r s tx x)
      ;; RJP ยป 2018-08-07
      ;; Finds text equal to a distance found to the closest line
      (defun _x (s) (cond ((= 'pickset (type s)) (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))))))
      (defun _dxf (c e) (cdr (assoc c (entget e))))
      (setq r (ssadd))
      (cond
        ((and (setq s (_x (ssget "_X" '((0 . "line") (8 . "850L 802 AR CuAu")))))
    	  (setq tx (_x (ssget "_X" '((0 . "text") (8 . "850L 802 AR CuAu")))))
    	  (setq tx (mapcar '(lambda (x) (list (_dxf 10 x) x)) tx))
         )
         (foreach l	tx
           (setq c (mapcar '(lambda (x) (distance (car l) (vlax-curve-getclosestpointto x (car l)))) s))
           ;; If there is a line within 0.2 and 0.5 distance
           (if (equal (car (vl-sort c '(lambda (a b) (< a b)))) 0.35 0.15)
    	 ;; Add the text to the selection
    	 (ssadd (cadr l) r)
           )
         )
         (sssetfirst nil r)
        )
      )
      (princ)
    )
    Attached Images

  10. #10
    Quantum Mechanic BIGAL's Avatar
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    10,792

    Default

    Registered forum members do not see this ad.

    Like all the posts here ktbjx you did not say what you wanted to actually do with what was picked hence I just displayed the value its was up to you to do something with it. like Ronjonp I had some problems with crossing data.
    A man who never made mistakes never made anything

Similar Threads

  1. Select either Doted line or full line of the same Layer in AUTOCAD?
    By tipu_sultane in forum AutoCAD Beginners' Area
    Replies: 2
    Last Post: 19th Apr 2014, 03:20 pm
  2. Select text and create layer with text name
    By BrianTFC in forum AutoLISP, Visual LISP & DCL
    Replies: 2
    Last Post: 28th Feb 2012, 03:05 pm
  3. Select one line of a Polyline
    By guitarguy1685 in forum AutoLISP, Visual LISP & DCL
    Replies: 2
    Last Post: 13th Jul 2011, 09:01 pm
  4. How to select more than one line?
    By oldcodger in forum AutoCAD General
    Replies: 4
    Last Post: 9th Jun 2010, 03:53 pm
  5. draw line on line (auto select previous pick points)
    By deano33 in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 4
    Last Post: 10th Dec 2009, 09:59 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts