ktbjx Posted August 1, 2019 Posted August 1, 2019 (edited) (defun c:test(/ sel int ent str end hcol ss) (While T (setq ss (ssget "_:L" (list '(0 . "TEXT")))) (setq hcol (cdr (assoc 62 (Entget ss)))) (if (setq int -1 sel (ssget "_:S" '((0 . "LINE")))) (while (setq ent (ssname sel (setq int (1+ int)))) (setq str (cdr (assoc 10 (entget ent))) end (cdr (assoc 11 (entget ent))) ) (entmake (list '(0 . "CIRCLE") (cons 10 (mapcar '(lambda (q p) (* (+ q p) 0.5)) str end)) (cons 40 (/ (distance str end) 2.)) (cons 62 hcol) ) ) ) ) ) (princ) ) I am having trouble with my lousy coding, basically i need to get the color from TEXT and then use that color to the line and circle that im gonna be selecting i dont know whats wrong with this code here i added a sample file: sample.dwg my end result is hatch all the circles based from the text color but my question is just change circle color, because i have a routine that hatches all the circles based from the circle color Edited August 1, 2019 by ktbjx Quote
rrulep Posted August 1, 2019 Posted August 1, 2019 1 hour ago, ktbjx said: (defun c:test (/ sel int ent str end hcol ss) (while t (setq ss (ssget "_:L" (list '(0 . "TEXT")))) (progn (setq idx 0) (repeat (sslength ss) (setq ent (ssname ss idx)) (setq hcol (cdr (assoc 62 (entget ent)))) (if (setq int -1 sel (ssget "_:S" '((0 . "LINE"))) ) ;_ end of setq (while (setq ent (ssname sel (setq int (1+ int)))) (setq str (cdr (assoc 10 (entget ent))) end (cdr (assoc 11 (entget ent))) ) ;_ end of setq (entmake (list '(0 . "CIRCLE") (cons 10 (mapcar '(lambda (q p) (* (+ q p) 0.5)) str end)) (cons 40 (/ (distance str end) 2.)) (cons 62 hcol) ) ;_ end of list ) ;_ end of entmake ) ;_ end of while ) ;_ end of if (setq idx (1+ idx)) ) ;_ end of repeat ) ;_ end of progn ) ;_ end of While (princ) ) ;_ end of defun ;|«Visual LISP© Format Options» (100 1 2 2 T "end of " 100 9 1 1 1 T T nil T) ;*** DO NOT add text below the comment! ***|; I am having trouble with my lousy coding, basically i need to get the color from TEXT and then use that color to the line and circle that im gonna be selecting i dont know whats wrong with this code here i added a sample file: sample.dwg 138.34 kB · 1 download my end result is hatch all the circles based from the text color but my question is just change circle color, because i have a routine that hatches all the circles based from the circle color Try This (defun c:test (/ sel int ent str end hcol ss) (while t (setq ss (ssget "_:L" (list '(0 . "TEXT")))) (progn (setq idx 0) (repeat (sslength ss) (setq ent (ssname ss idx)) (setq hcol (cdr (assoc 62 (entget ent)))) (if (setq int -1 sel (ssget "_:S" '((0 . "LINE"))) ) ;_ end of setq (while (setq ent (ssname sel (setq int (1+ int)))) (setq str (cdr (assoc 10 (entget ent))) end (cdr (assoc 11 (entget ent))) ) ;_ end of setq (entmake (list '(0 . "CIRCLE") (cons 10 (mapcar '(lambda (q p) (* (+ q p) 0.5)) str end)) (cons 40 (/ (distance str end) 2.)) (cons 62 hcol) ) ;_ end of list ) ;_ end of entmake ) ;_ end of while ) ;_ end of if (setq idx (1+ idx)) ) ;_ end of repeat ) ;_ end of progn ) ;_ end of While (princ) ) ;_ end of defun ;|«Visual LISP© Format Options» (100 1 2 2 T "end of " 100 9 1 1 1 T T nil T) ;*** DO NOT add text below the comment! ***|; 1 Quote
ktbjx Posted August 1, 2019 Author Posted August 1, 2019 11 minutes ago, rrulep said: Try This (defun c:test (/ sel int ent str end hcol ss) (while t (setq ss (ssget "_:L" (list '(0 . "TEXT")))) (progn (setq idx 0) (repeat (sslength ss) (setq ent (ssname ss idx)) (setq hcol (cdr (assoc 62 (entget ent)))) (if (setq int -1 sel (ssget "_:S" '((0 . "LINE"))) ) ;_ end of setq (while (setq ent (ssname sel (setq int (1+ int)))) (setq str (cdr (assoc 10 (entget ent))) end (cdr (assoc 11 (entget ent))) ) ;_ end of setq (entmake (list '(0 . "CIRCLE") (cons 10 (mapcar '(lambda (q p) (* (+ q p) 0.5)) str end)) (cons 40 (/ (distance str end) 2.)) (cons 62 hcol) ) ;_ end of list ) ;_ end of entmake ) ;_ end of while ) ;_ end of if (setq idx (1+ idx)) ) ;_ end of repeat ) ;_ end of progn ) ;_ end of While (princ) ) ;_ end of defun ;|«Visual LISP© Format Options» (100 1 2 2 T "end of " 100 9 1 1 1 T T nil T) ;*** DO NOT add text below the comment! ***|; wow thanks so much! just what i need! 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.