Jump to content

change line and circle color based from text color


ktbjx

Recommended Posts

(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 by ktbjx
Link to comment
Share on other sites

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! ***|;

 

  • Like 1
Link to comment
Share on other sites

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! :)

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...