ojacomarket Posted April 9, 2020 Posted April 9, 2020 Dear friends, Thank you for your help with last topic, I got so many good ideas of code. I created also one, which works: it construct line segments (by click on text nearby) between circles with specific text element nearby. (defun c:PLtrace () (setq list_circle_coords_1 '()) (setq list_circle_coords_2 '()) ; ;(setq lay (assoc 8 (entget (car (entsel)))) lay2 (assoc 0 (entget (car (entlast))))) (setq circle_set_selection_1 (ssget "x" (list (cons 0 (cdr (assoc 0 (setq entget_circle1 (entget (car (entsel))))))) (cons 8 (cdr (assoc 8 entget_circle1))) (cons 1 (cdr (assoc 1 entget_circle1)))))) ;O_o; created selection set of all objects that contain DXF codes 0 and 8 on selection by user (setq circle_set_selection_length_1 (sslength circle_set_selection_1)) ;O_o; investigate how many objects are included into selection set (setq circle_num_1 (- 1 )) ;just variable that will be used as startpoint of polyline (setq circle_num_2 0) (repeat circle_set_selection_length_1 ;repeat loop as many times as written in the selection set length (setq circle_num_1 (1+ circle_num_1)) ;new value of variable (setq circle_num_2 (1+ circle_num_2)) (setq circle_names_1 (entget (ssname circle_set_selection_1 circle_num_1))) ;get entity name of every member of selection set (setq circle_names_2 (entget (ssname circle_set_selection_1 circle_num_2))) (setq circle_coords_1 (cdr (assoc 10 circle_names_1))) ;taking coordinates of centers of the circles (setq circle_coords_2 (cdr (assoc 10 circle_names_2))) (setq circle_coords_1_Y (+ 0.05 (cadr circle_coords_1))) (setq circle_coords_2_Y (+ 0.05 (cadr circle_coords_2))) (setq circle_NEW_coords_1 (list (car circle_coords_1) circle_coords_1_Y)) (setq circle_NEW_coords_2 (list (car circle_coords_2) circle_coords_2_Y)) (setq poly_make_1 (entmake (list (cons 0 "LINE") (cons 8 "0") (cons 10 circle_NEW_coords_1) (cons 11 circle_NEW_coords_2)))) ) (princ) ) But for now I would like to AutoCAD to recognize what is written in "TEXT" element and convert the line to the specific layer and linetype. For example, when I use my code with clicking on "TEXT" with name "H1" it create line segments between all circles where nearby is text "H1", but I want also to match for that line segments specific linetype, let's say "Continuous" and layer "0". And this should be on one click, so desired routine> click on "TEXT" element, for ex., "H1" and it creates line segment with SPECIFIC layer and linetype. test.dwg Quote
devitg Posted April 9, 2020 Posted April 9, 2020 Hi ojacomarket, as far as I can see , there is no any line where you can pick to a TEXT , furthermore that are , at least , 3 text nearby each circle. Each text is in its layer: 3 text 3 layers. All this layer has color bylayer to color 250 , black for me , as I use an almost white modelspace screen . It will be nice , if you can upload a sample dwg with a BEFORE , and AFTER , so it will be clear what to be do. Quote
ojacomarket Posted April 9, 2020 Author Posted April 9, 2020 1 hour ago, devitg said: Hi ojacomarket, as far as I can see , there is no any line where you can pick to a TEXT , furthermore that are , at least , 3 text nearby each circle. Each text is in its layer: 3 text 3 layers. All this layer has color bylayer to color 250 , black for me , as I use an almost white modelspace screen . It will be nice , if you can upload a sample dwg with a BEFORE , and AFTER , so it will be clear what to be do. Hi, thank you very much for the feedback. My text above is very long, and explanation is poor, so I apologize for that. I pinned two dwg, what is before and after what is expected. Also I pinned my lisp which works for creation lines between circle centers with specified text nearby. testAFTER.dwg test.dwg asap.lsp Quote
devitg Posted April 9, 2020 Posted April 9, 2020 As in your post on april 8 , dlanorh state Quote I think you'll find that the insertion point of the text is the same as the centre of the circle (Top Left) and each text is preceeded by a space. So I guess you want to make the lines as the mootnr at it's Layer , and to follow it's order , as you can see if the lines are by the circle ssget , it's handle are not in order m the first line was from 141 to 142 , the second from 142 to 141 , and the 3 rd fom 141 to 139 Handle number give the order how they had be done . Quote
devitg Posted April 9, 2020 Posted April 9, 2020 As I can see, there is no a regular or congruent way to follow the nro at the "mootnr" layer nro 55 is lost test-beforepoint 55 is lost-s1 as nro and nro lost.dwg Quote
ojacomarket Posted April 9, 2020 Author Posted April 9, 2020 19 minutes ago, devitg said: As I can see, there is no a regular or congruent way to follow the nro at the "mootnr" layer nro 55 is lost test-beforepoint 55 is lost-s1 as nro and nro lost.dwg 645.18 kB · 0 downloads Thank you for feedback! As I said before, sorry for poor explanantion.The main goal of that code is: a) I select with mouse cursor the text, for example, "kill1" b)"kill1" is nothing more that "kill + order nr." - it is just text, but this text SHOULD assign the linetype and layer of the future lines, that will join ALL circles nearby this "kill" text. c) So I want AutoCAD to recognize that I have selected "kill1", then it knows that FUTURE LINES, THAT WILL JOIN EVERY CIRCLE , which have nearby text "kill + order nr." it should be at Layer "0" with Linetype "Continuous" (I mean those lines should be at "0" layer and "Continuous" linetype, the TEXT "kill + order nr." should stay at current layer with no changes) Quote
Jonathan Handojo Posted April 9, 2020 Posted April 9, 2020 Well, your code is prompting for the selection of a circle, not text, so how should it recognise the texts? If I'm understanding right, you prefer the same texts in the same unique layer with the linetype "CONTINUOUS". If that's the case, you can simply put it in, for example, "PLTRACE-kill1" layer or something like that. In my case... (defun c:textcircle ( / circles dets ent i pl ss texts txt unique) (defun unique (lst / rtn) (while lst (setq rtn (cons (car lst) rtn) lst (vl-remove (car lst) lst) ) ) (reverse rtn) ) (if (setq ss (ssget '((0 . "CIRCLE,TEXT,MTEXT")))) (progn (repeat (setq i (sslength ss)) (if (eq (cdr (assoc 0 (entget (setq ent (ssname ss (setq i (1- i))))))) "CIRCLE") (setq circles (cons ent circles)) (setq texts (cons ent texts)) ) ) (foreach x circles (if (setq txt (car (vl-member-if '(lambda (y) (equal (cdr (assoc 10 (entget x))) (cdr (assoc 11 (entget y))) 1e-8 ) ) texts ) ) ) (setq dets (cons (cons (cdr (assoc 1 (entget txt))) x) dets)) ) ) (foreach x (unique (mapcar 'car dets)) (if (> (length (setq pl (vl-remove-if-not '(lambda (y) (eq x (car y))) dets))) 1) ; If statement added to escape one-vertex segments (entmake (append '( (0 . "LWPOLYLINE") (100 . "AcDbEntity") (100 . "AcDbPolyline") (6 . "Continuous") ; <--- Adjusted linetype to Continuous ) (list (cons 90 (length pl)) (cons 8 (strcat "TEXTCIRCLE-" x)) ; <--- Line added, put in layer "TEXTCIRCLE-" followed by the text name. ) (apply 'append (mapcar '(lambda (y) (list (assoc 10 (entget (cdr y))) '(40 . 0) '(41 . 0) '(42 . 0) '(91 . 0) ) ) pl ) ) ) ) ) ; Close if ) ) ) ) 1 Quote
devitg Posted April 9, 2020 Posted April 9, 2020 Ojacomarket, please upload such dwg with kill1+xxx number Quote
ojacomarket Posted April 9, 2020 Author Posted April 9, 2020 Yes, sure, look at that file, I actually added it before as well, on drawing there are kill1 is joined by line already test.dwg Quote
BIGAL Posted April 10, 2020 Posted April 10, 2020 I posted an answer to this maybe here recently or else it was forums/Autodesk it asks for the text and uses that to join the circles the add layer linetype could be done easy. 1 Quote
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.