Image overlays instead of changing

Image overlays instead of changing

Anonymous
Not applicable
933 Views
8 Replies
Message 1 of 9

Image overlays instead of changing

Anonymous
Not applicable

I'm trying to create a .dcl, so when I click on an item in the list_box the image on the side will be changed.
because in my role she gets soreposta ??
is this the correct way to deal with it ??
How can I improve and leave the proof of failure ??

(defun c:demo (  )  
  
  (defun *error* ( msg )
    (and ofile (close ofile)) 
    (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
        (princ (strcat "\n** Error: " msg " **"))
    )
    (vl-file-delete file)
    (princ)
  )

  (defun :writedcl ( local )
    (setq file local)
    (setq ofile (open file "w"))
    (foreach line
      '(
        "butt01 : button { width = 15; height = 2; fixed_width = true; alignment = centered; }"
        "dcl_test : dialog { label = \" TEST \";"
        " spacer;"
        ": boxed_column"
        "{" 
        ": row"
        "{"
        ":list_box  { width = 20; height = 10; fixed_width = true; key = \"lst\";  }"
        ":image  { width = 20; height = 10; key = \"img\";  }"
        "}"        
        "}"
        "ok_cancel;"

        "} //_end"    
        )
      (write-line line ofile)
    )
    (not (setq ofile (close ofile)))    
  )  
  
  (cond 
    ( (not (:writedcl (setq file (vl-filename-mktemp nil nil ".dcl"))))
      (alert "it was not possible to record the dcl")
    )
    ( (<= (setq dcfname (load_dialog file)) 0)
      (alert "DCL not found")
    )
    ( (not (new_dialog "dcl_test" dcfname))
      (alert "DCL not found")
    )
    (t
      
      (setq tip '("quad" "figure 1" "figure 2"))
      (start_list "lst")
      (mapcar 'add_list tip)
      (end_list)
      
      (set_tile "lst" "0")
      (:vecimagem "img" quad)
      
      (action_tile "lst" 
        (vl-prin1-to-string 
          (quote
            (:vecimagem "img"
              (cond
                ( (= (nth (atoi $value) tip) "quad")
                  (setq temp quad)
                )
                ( (= (nth (atoi $value) tip) "figure 1")
                  (setq temp fig1)
                )
                ( (= (nth (atoi $value) tip) "figure 2")
                  (setq temp fig2)
                )
              ) ;;cond
            )
          )
        )
      )      
      
      
      (if (= (start_dialog) 1)
        (alert "Ok!")
        (alert "Cancel!")
      )
    )
  )
  (if (and file (setq file (findfile file)))(vl-file-delete file))
  (princ)
)

(defun :vecimagem ( key lst )
  (setq i (/ (dimx_tile key) 289.) j (/ (dimy_tile key) 170.))
  (start_image key)
  (foreach x lst
    (vector_image (fix (* (car x) i))(fix (* (cadr x) j))(fix (* (caddr x) i))(fix (* (cadddr x) j))(last x))
  )
  (end_image)
  (princ)
)
;;vector!! 
(setq quad '((11 80 107 80 240) (107 80 107 0 240) (107 0 11 0 240) (11 0 11 80 240)))
(setq fig1 '((11 80 107 80 240) (107 80 107 0 240) (107 0 11 0 240) (11 0 11 80 240) (11 80 59 0 240) (59 0 107 80 240)))
(setq fig2 '((11 80 107 80 240) (107 80 107 0 240) (107 0 11 0 240) (11 0 11 80 240) (11 0 107 80 240) (107 0 11 80 240)))
  
(c:demo)

 

 

 

934 Views
8 Replies
Replies (8)
Message 2 of 9

hak_vz
Advisor
Advisor

@AnonymousGood work. You just have to reset image before loading another one, so they don't overlap.

 

Also consult this post if you want to create bitmap style icons

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/dcl-button-images/m-p/9873106/highlight/true#M407589 

 

 

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 9

Anonymous
Not applicable

@hak_vz 
That's what I tried to do, generate a blank list and redefine the function: see the process, but without success! and it also doesn't seem like a good practice.

      (setq vas '())
      (action_tile "lst" 
        (vl-prin1-to-string 
          (quote
            (:vecimagem "img"
              (cond
                ( (= (nth (atoi $value) tip) "quad")
                  (progn
                    (:vecimagem "img" vas)
                    (setq temp quad)
                  )
                )
                ( (= (nth (atoi $value) tip) "figure 1")
                  (progn
                    (:vecimagem "img" vas)
                    (setq temp fig1)                    
                  )
                )
                ( (= (nth (atoi $value) tip) "figure 2")
                  (progn
                    (:vecimagem "img" vas)
                    (setq temp fig2)                    
                  )
                )
              ) ;;cond
            )
          )
        )
      ) 

 

0 Likes
Message 4 of 9

Anonymous
Not applicable

another question, I modified the DCl a little.
how would i do it when i press pick point it would allow me to go to my drawing space of the click and then go back to DCl ??

 

(defun c:demo (/ :writedcl nme lay rep )  
  
  (defun *error* ( msg )
    (and ofile (close ofile)) 
    (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
        (princ (strcat "\n** Error: " msg " **"))
    )
    (vl-file-delete file)
    (princ)
  )

  (defun :writedcl ( local )
    (setq file local)
    (setq ofile (open file "w"))
    (foreach line
      '(
        "butt01 : button { width = 15; height = 2; fixed_width = true; alignment = centered; }"
        "dcl_test : dialog { label = \" TEST \";"
        " spacer;"
        ": boxed_column"
        "{" 
        ": row"
        "{"
        ":list_box  { width = 20; height = 10; fixed_width = true; key = \"lst\";  }"
        ":image  { width = 20; height = 10; key = \"img\";  }"
        "}"
        ": row"
        "{"
        ":edit_box  { width = 20; fixed_width = true; key = \"local\";  }"
        ":butt01  { fixed_width = true; key = \"pick\"; label = \"pick point\"; }"
        "}"
        "}"
        "ok_cancel;"

        "} //_end"    
        )
      (write-line line ofile)
    )
    (not (setq ofile (close ofile)))    
  )  
  
  (cond 
    ( (not (:writedcl (setq file (vl-filename-mktemp nil nil ".dcl"))))
      (alert "it was not possible to record the dcl")
    )
    ( (<= (setq dcfname (load_dialog file)) 0)
      (alert "DCL not found")
    )
    ( (not (new_dialog "dcl_test" dcfname))
      (alert "DCL not found")
    )
    (t
      
      (setq tip '("quad" "figure 1" "figure 2"))
      (start_list "lst")
      (mapcar 'add_list tip)
      (end_list)
      
      (set_tile "lst" "0")
      (:vecimagem "img" quad)
      
      (setq vas '())
      (action_tile "lst" 
        (vl-prin1-to-string 
          (quote
            (:vecimagem "img"
              (cond
                ( (= (nth (atoi $value) tip) "quad")
                  (progn
                    (:vecimagem "img" vas)
                    (setq temp quad)
                  )
                )
                ( (= (nth (atoi $value) tip) "figure 1")
                  (progn
                    (:vecimagem "img" vas)
                    (setq temp fig1)                    
                  )
                )
                ( (= (nth (atoi $value) tip) "figure 2")
                  (progn
                    (:vecimagem "img" vas)
                    (setq temp fig2)                    
                  )
                )
              ) ;;cond
            )
          )
        )
      )
      
      (setq local '(3074.82 1485.53 0.0)) ;;initial coordinate will be 0.0 0.0 0.0
      (set_tile "local" (strcat (rtos (car local) 2 2) "," (rtos (cadr local) 2 2)))      
      (action_tile "local" (vl-prin1-to-string (quote (setq olt (get_tile "local")))))
      
      ;;if the user clicks on the point / marker
      (action_tile "pick" "(done_dialog 2)")
      (if (= (start_dialog) 2)
        (getpoint "pick point")
      )
      
      
      (if (= (start_dialog) 1)
        (alert "Ok!")
        (alert "Cancel!")
      )
    )
  )
  (if (and file (setq file (findfile file)))(vl-file-delete file))
  (princ)
)

(defun :vecimagem ( key lst )
  (setq i (/ (dimx_tile key) 289.) j (/ (dimy_tile key) 170.))
  (start_image key)
  (foreach x lst
    (vector_image (fix (* (car x) i))(fix (* (cadr x) j))(fix (* (caddr x) i))(fix (* (cadddr x) j))(last x))
  )
  (end_image)
  (princ)
)
;;vector!!
(setq vas '())
(setq quad '((11 80 107 80 240) (107 80 107 0 240) (107 0 11 0 240) (11 0 11 80 240)))
(setq fig1 '((11 80 107 80 240) (107 80 107 0 240) (107 0 11 0 240) (11 0 11 80 240) (11 80 59 0 240) (59 0 107 80 240)))
(setq fig2 '((11 80 107 80 240) (107 80 107 0 240) (107 0 11 0 240) (11 0 11 80 240) (11 0 107 80 240) (107 0 11 80 240)))
  
(c:demo)

 

0 Likes
Message 5 of 9

hak_vz
Advisor
Advisor

To reset image tile use this in your script before loading each vector tile

 

(fill_image 0 0 w h -15)	

 

where w and h are width and height of an image tile. Color -15 is color of GUI background

 

 

About working with dcl and alowing to go back and fort between DCL and drawing I'll post my concept later. I have to look in my previous posts to this forum.

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 6 of 9

hak_vz
Advisor
Advisor

Here is my post about saving dcl tile values. Method uses writing and reading  dcl tile values to txt file

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/remember-previous-dcl-values-default... 

 

Here is a sample dcl and lisp file to show a concept

 

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/remember-previous-dcl-values-default... 

 

There are other solutions in that post so you can use them to.

I prefer to close dcl and read it again with new value to avoid breaking display dialog chain

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 9

Anonymous
Not applicable

Thanks @hak_vz  I am grateful for the disposition.
I will analyze the links

 

I'm still trying to solve the problem of images.

 

I have already modified the function :vecimagem

(defun :vecimagem ( key lst )
  (setq dx (dimx_tile "img") dy (dimx_tile "img"))
  (setq i (/ (dimx_tile key) 289.) j (/ (dimy_tile key) 170.))
  (start_image key)
  (fill_image 0 0 dx dy 0)
  (foreach x lst
    (vector_image (fix (* (car x) i))(fix (* (cadr x) j))(fix (* (caddr x) i))(fix (* (cadddr x) j))(last x))
  )
  (end_image)
  (princ)
)

and action_tile even more unsuccessfully

(action_tile "lst" "(setq item (nth (atoi $value) tip))(:vecimagem \"img\" (read $value))")

 

0 Likes
Message 8 of 9

Anonymous
Not applicable

I did it !! Problem 1 solved !!!!

Message 9 of 9

hak_vz
Advisor
Advisor

Maybe

(fill_image 0 0 dx dy -15) instead (fill_image 0 0 dx dy 0)

 

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