Change image_button background color in lisp

Change image_button background color in lisp

darkfprh
Advocate Advocate
1,748 Views
6 Replies
Message 1 of 7

Change image_button background color in lisp

darkfprh
Advocate
Advocate

Hi I'm making an lisp with dcl.

 

and I want to display color and change it.

so I use image_button's background color.

But I can't change color in lisp.

 

So How can I display and change its color?

 

DCL)

:image_button{key=img_color; width=4; aspect_ratio=1;}

 

LISP)

(set_tile "img_color" col) <- But It's not answer...

 

2.png

0 Likes
Accepted solutions (2)
1,749 Views
6 Replies
Replies (6)
Message 2 of 7

hak_vz
Advisor
Advisor
(defun change_button_color ( / new_color)(setq new_color (acad_colordlg 1)) (set_tile "img_color" new_color))


;.....
(action_tile "img_color" "change_button_color")
(start_dialog)

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 3 of 7

darkfprh
Advocate
Advocate

I tried it already. But It doesn't change color....

 

20210307_222020.png

0 Likes
Message 4 of 7

andkal
Collaborator
Collaborator
Accepted solution

Try fill_image.

Example:

(defun DCL_FILLIMAGE (Im_key ClrIndex1 / )
    (start_image Im_key)
    (fill_image 0 0 (dimx_tile Im_key) (dimy_tile Im_key) ClrIndex1 )
    (end_image)
);defun

• www.autolisps.blogspot.com - Productivity plugins for Autocad and Autocad MEP
• Autodesk AppStore
0 Likes
Message 5 of 7

pbejse
Mentor
Mentor
Accepted solution

You may have to close the dcl and rebuild with a different color assignment to the image box

 

(defun _StartDia ( clr / f new_color dcl_id)
    (setq dcl_id (load_dialog "Dark.dcl"))
    (if	(not (new_dialog "Dark" dcl_id))
      (exit)
    )
   (start_image "img_color")
    (fill_image 0 0 (dimx_tile "img_color") (dimy_tile "img_color") clr )
      (end_image)
    (action_tile "img_color" "(done_dialog 2)")
    (action_tile "accept" "(done_dialog 1)")
    (action_tile "close" "(done_dialog 0)")
    (setq f (start_dialog))
    (unload_dialog dcl_id)
;; you do the rest here for 1 and 0 ;;;
    (if (= f 2)
      (progn
       (setq new_color (acad_colordlg 1))
       (_StartDia new_color)
      )
    )
  )

 

like this

(_StartDia 1)

1 as initial color

 

HTH

 

0 Likes
Message 6 of 7

hak_vz
Advisor
Advisor

Sorry for not instant reply I was out.

Please attach your DCL so we can see what you want to achieve.

In my previous code you should probably change ass follow but I have to guess what tile we are scripting.

(set_tile "img_color" new_color)
to 
(set_tile "img_color" (itoa new_color))

 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 7 of 7

darkfprh
Advocate
Advocate

Thank you But It doesn't work...

 

(set_tile "img_color" "1") -> change text

 

(set_tile "img_color" 1) -> wrong type argument error

0 Likes