Jump to content

how to change a color of a line previusly drawn with Autolispp


danyra

Recommended Posts

Im a begginer, I drawn a line in autolisp with this "code":

 

(setq p1 (getpoint "\nPunto Inicial:"))
      (setq p2 (polar p1 (* 1.5 pi) 0.18))
        (command "line" p1 p2 "")
  

but, how can I change the color of this line?? For example I want yellow

Thanks for your help.

Edited by danyra
Link to comment
Share on other sites

  1. You could change your current layer to a layer that is yellow before creating the line.
  2. You could use (entmake) instead of (command) and set the color during creation time. (sample below)
  3. You could run (command "._change) after (command ._line") and change the color of (entlast) to yellow, or move it to a yellow layer.

 

(setq p1 (getpoint "\nPunto Inicial:"))
(setq p2 (polar p1 (* 1.5 pi) 0.18))
(entmake
  (list
    (cons 0 "LINE")
    (cons 8 "0")
    (cons 62 2)
    (cons 10 p1)
    (cons 11 p2)
  )
)

 

  • Thanks 1
Link to comment
Share on other sites

As @rkmcswain mentioned you could do something like so:

(if (setq p1 (getpoint "\nPunto Inicial:"))
  (progn (setq p2 (polar p1 (* 1.5 pi) 0.18))
	 ;; (command "line" p1 p2 "")
	 (entmakex (list '(0 . "line") (cons 10 p1) (cons 11 p2) '(62 . 2)))
  )
)

 

  • Like 1
Link to comment
Share on other sites

8 minutes ago, ronjonp said:

(entmakex (list '(0 . "line") (cons 10 p1) (cons 11 p2) '(62 . 2)))

Ok, its works, thanks you both. 

But, how can I change to a blue color now?

Link to comment
Share on other sites

26 minutes ago, rkmcswain said:

(list     (cons 0 "LINE")     (cons 8 "0")     (cons 62 2)     (cons 10 p1)     (cons 11 p2)   ) )

Thank you a lot, can you explain me how its works? what does each of those numbers mean?

Becaause I have a lot of lines and they have different colors, for example blue.

Link to comment
Share on other sites

21 minutes ago, danyra said:

Ok, its works, thanks you both. 

But, how can I change to a blue color now?

The '(62 . #) is the index color. Make this change for blue: '(62 . 5)

image.png.19d03a5be0821066c2d1b01fc4ef1946.png

Edited by ronjonp
  • Thanks 1
Link to comment
Share on other sites

38 minutes ago, danyra said:

ok thanks you, I get it 

Glad to help :)

 

You could use something like this to be able to choose your color before drawing the line:

(defun c:foo (/ c p1)
  (if (and (setq c (acad_colordlg 1)) (setq p1 (getpoint "\nPunto Inicial:")))
    (entmakex (list '(0 . "line") (cons 10 p1) (cons 11 (polar p1 (* 1.5 pi) 0.18)) (cons 62 c)))
  )
  (princ)
)

 

  • Like 1
Link to comment
Share on other sites

A command style version

 

(defun c:foo2 (/ c p1)
  (if (and (setq c (acad_colordlg 1)) (setq p1 (getpoint "\nPunto Inicial:")))
  (progn
  (setq p2 (polar p1 (* 1.5 pi) 0.18))
  (command "line" p1 p2 "")
  (command "chprop" (entlast) "" "c" c "")
  )
  )
  (princ)
)

 

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...