ktbjx Posted August 7, 2018 Share Posted August 7, 2018 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? new block.dxf Quote Link to comment Share on other sites More sharing options...
maratovich Posted August 7, 2018 Share Posted August 7, 2018 In what form should the final result be? Quote Link to comment Share on other sites More sharing options...
BIGAL Posted August 7, 2018 Share Posted August 7, 2018 Try this ; 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) Quote Link to comment Share on other sites More sharing options...
ktbjx Posted August 7, 2018 Author Share Posted August 7, 2018 Try this ; 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 >. Quote Link to comment Share on other sites More sharing options...
ktbjx Posted August 7, 2018 Author Share Posted August 7, 2018 In what form should the final result be? nothing sir, i just want to select them so i could change, move rotate or anything Quote Link to comment Share on other sites More sharing options...
maratovich Posted August 7, 2018 Share Posted August 7, 2018 Check this out: Quote Link to comment Share on other sites More sharing options...
ktbjx Posted August 7, 2018 Author Share Posted August 7, 2018 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 Quote Link to comment Share on other sites More sharing options...
maratovich Posted August 7, 2018 Share Posted August 7, 2018 o you mean which are the ones i need to select? Can not you see the red arrow? Check the selection ".30 / 17.13" Quote Link to comment Share on other sites More sharing options...
ronjonp Posted August 7, 2018 Share Posted August 7, 2018 Try this .. it's not perfect, but neither is the data. (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) ) Quote Link to comment Share on other sites More sharing options...
BIGAL Posted August 8, 2018 Share Posted August 8, 2018 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. Quote Link to comment Share on other sites More sharing options...
ktbjx Posted August 8, 2018 Author Share Posted August 8, 2018 Try this .. it's not perfect, but neither is the data. (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) ) Yes! exactly what i need, i love it! at least selecting those text will be easier! thank you so much! Quote Link to comment Share on other sites More sharing options...
ronjonp Posted August 8, 2018 Share Posted August 8, 2018 Yes! exactly what i need, i love it! at least selecting those text will be easier!thank you so much! You're welcome! Quote Link to comment Share on other sites More sharing options...
ronjonp Posted August 8, 2018 Share Posted August 8, 2018 Just another thought, but why don't you use an attributed block for this? It would make your drawings quite a bit more consistent. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.