DCL Button Images

DCL Button Images

nathanwheeler27
Advocate Advocate
3,880 Views
15 Replies
Message 1 of 16

DCL Button Images

nathanwheeler27
Advocate
Advocate

Hi,

 

I have been trying to figure out how to do images in DCL/LISP for awhile and can't get anything to work. Can anyone figure this out for me? My sample.dwg, lsp and dcl files are attached. What I really want is to replace the current dropdown boxes with two columns of images (as shown in CAD). Each row would be a button. It could be an image, then a radio button and text if required. But, I think you can make the images buttons, thus getting rid of radio buttons? 

 

This would be amazingly helpful since the drafter currently picks the holdown by reading a description of the image (ie, triangle / solid triangle, circle / triangle). That's clunky and not efficient.

 

nathanwheeler27_1-1605138110463.png

 

 Any help would be appreciated?

3,881 Views
15 Replies
Replies (15)
Message 2 of 16

john.uhden
Mentor
Mentor

I struggled with that idea years ago.  In DCL I think the only way to display an image is using a slide.

Now I may be using archaic terms ('cause I'm just getting into 2020 from 2002), but I found it easier and better looking to use menu picks that can simply provide return values in the middle of your program.  Of course, creating  the icons can be a challenge because the resolution is so low (unless that has been improved these days)

John F. Uhden

0 Likes
Message 3 of 16

diagodose2009
Collaborator
Collaborator

I can make you're -wish inside 100%Visual-Lisp.

Today I do not have your-program.lsp, but If you hire me 50$..80$ then you will got your program.lisp Why you need to pay me for your task?

Because I work 2-3 days for "compile&compress JPG images To VLisp%100"

You will get 100% VLisp-ascii source, without (doslib,arx,net)

If you are agree, then you send PM /here on autodesk-forum

Still your task "DCL-images" is not very easy, need hard work inside "VLisp".

 

0 Likes
Message 4 of 16

hak_vz
Advisor
Advisor

@nathanwheeler27 

 

There is another method to create icons that can be used with DCL buttons and other GUI elements.

It uses vector_image and fill_image method.

Tomorrow I'll post a set of autolisp scripts to create (draw) bitmaps like representation i.e. ACI color list representation of a  bitmap image on the DCL image tile or image_button tile  with the given key.

 

With it you will be able to create standard size  16×16, 32×32 or larger icons. Creation of icon

mimics the one that is used in icon generator applications, but inside Autocad environment.

It is not a converter, but it may be used. Created icons are not art masterpiece but that can be of some use. 

This method requires user to spend some time to create icons (max 5 mins) and how to use DCL. Bitmap representation is stored inside lisp file as a list stored inside variable (for better performance) or just temporary.

Icon will look like the on in attachment, but shown in pixels. Background gray color is replaced with the color of

gui element., ie. button or image_tile. In attachment is a sample 16×16 icon.

 

Untitled.pngUntitled16.png

 

 

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 5 of 16

chaitanya.chikkala
Enthusiast
Enthusiast

Hi...

Have you tried creating customized toolbar by creating a CUIX file as below?

 You can create Icons as shown in below picture (clouded in blue) and you can implement below tasks :

  1. Create custom toolbar with custom icons (.bmp format)
  2. Assign Macro for each icon to perform the task you specify.
  3. Provide description for each icon which will appear as Tooltip to guide the user

If you have not tried this option and interested to try, I will help you to implement your task using this method.

 
 

You can created ICONS as highlighted in the picture and assign Macro/Lisp Program for each icon to performYou can created ICONS as highlighted in the picture and assign Macro/Lisp Program for each icon to perform

 

 

 

Cuix file2.PNG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0 Likes
Message 6 of 16

hak_vz
Advisor
Advisor

@chaitanya.chikkalaI think @nathanwheeler27 is interested on how to use image elements inside DCL file. Your proposal is an option.

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 16

hak_vz
Advisor
Advisor

@nathanwheeler27 

Here is my follow up to @Lee_Mac solution to fill DCL image_tile or image button.

There are three functions BMPINIT, BMPDRAW and BMPGENERATE.

First one creates raster of hatch elements where each hatch rectangle mimics a pixel. You can use any size you want, resulting icons (image tiles ) are of rectangular shape.

Use command BMP draw to change color of individual "pixel" and draw your icon.

To change color just change current system color.

Command BMPGENERATE creates text file and renders the supplied ACI color list representation of a
bitmap image on the DCL image tile or image_button tile with the given key.

 

Generated code  looks like this:

 

(setq back_img
       '(
           001 005 192 192 192 192 192 005
           001 005 192 192 004 004 192 005
           001 005 192 004 004 004 192 005
           001 005 004 004 004 004 192 005
           001 005 004 004 004 004 192 005
           001 005 192 004 004 004 192 005
           001 005 192 192 004 004 192 005
           001 005 192 192 192 192 192 005
     )
)
 
 
: image
{
key = "back_img";
width = 1.33;
aspect_ratio = 1.0;
fixed_width = true;
fixed_height = true;
color = -15;
}

 

First section is a definition of a variable that holds image definition. Second part is one that goes into DCL file.

Change image to image_button if needed. This would be a definition of an 8×8 px icon that looks like this

 

Untitled.png

 

Included is @Lee_Mac 's function DisplayBitmap that you include inside your lisp file.

To populate DCL image tile after you load  DCL you just have to do this:

 

.....
(new_dialog "band_beams" dcl_id_band_beams)
(DisplayBitmap "back_img" back_img)
.....
(action_tile "back_img" "(back)")
.....
(start_dialog) 
.....

 

 

Always work inside a new dwg file.  Work seequence is BMPINIT, BMPDRAW, BMPGENERATE.

Here is the code:

 

;;--------------------=={ Display Bitmap }==------------------;;
;;                                                            ;;
;;  Renders the supplied ACI colour list representation of a  ;;
;;  Bitmap image on the DCL image tile or image_button tile   ;;
;;  with the given key.                                       ;;
;;------------------------------------------------------------;;
;;  Author: Lee Mac, Copyright © 2012 - www.lee-mac.com       ;;
;;------------------------------------------------------------;;
    (defun DisplayBitmap ( key lst / i j s x y )
        (setq s (fix (sqrt (length lst))))
        (repeat 
            (setq i s)
            (setq j 1)
            (repeat s
                (setq x (cons j x)
                      y (cons i y)
                      j (1+ j)
                )
            )
            (setq i (1- i))
        )
        (start_image key)
        (fill_image 0 0 (dimx_tile key) (dimy_tile key) -15)
        (mapcar 'vector_image x y x y lst)
        (end_image)
    )
	

;hak_vz
;16.11.2020
;https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/dcl-button-images/td-p/9863170

(defun c:bmpinit( /  lst)
(setq bitmap_size (getint "Bitmap square size 16 24 32 48 >")); this is global variable
(setvar 'CECOLOR "7")
(setvar 'cmdecho 0)
(command "rectangle" '(0 0) '(2 2))
(setq lst (entlast))
(command "-bhatch" "p" "solid" "s" lst "" "")
(entdel lst)
(command "-array" (entlast) "" "R" bitmap_size bitmap_size 2.1 2.1 )
(command "zoom" "w" '(0 0) (list (* 2.1 bitmap_size)(* 2.1 bitmap_size)))
(command "zoom" "s" 0.85x)
(setvar 'cmdecho 1)
(princ)
)

(defun c:bmpdraw ( / e *error*)
(defun *error* () (princ))
	(while(setq e (car(entsel "\nSelect object to change color >")))
		(cond ((and e)
			(vlax-put (vlax-ename->vla-object e) 'Color (atoi(getvar 'cecolor)))
			(sssetfirst nil nil)
		)
	)
	)
(princ)
)

(defun c:bmpgenerate ( / chunks ss i clr clr_list out f file1 row erow str) 
(defun transp ( m )(apply 'mapcar (cons 'list m)))
(defun chunks (lst n / sub ret)
  (while lst
    (while (< (length sub) n)(setq sub (cons (car lst) sub) lst (cdr lst)))
    (setq ret (cons (reverse sub) ret) sub nil)
  )
 (reverse ret)
)

(setq ss (ssget "_W" '(0 0)(list (* 2.1 bitmap_size)(* 2.1 bitmap_size))'((0 . "HATCH"))) i 0)
(while (< i (* bitmap_size bitmap_size))
	(setq clr (vlax-get (vlax-ename->vla-object (ssname ss i)) 'Color))
	(if (= clr 7) (setq clr -15))
	(setq clr_list (cons clr clr_list) i(+ i 1))
)
(setq 
	tilename (getstring "\nName of image tile > ")
	f (getfiled "Output file:" (getvar "dwgprefix") "txt" 3) 
	out f
	clr_list (reverse(transp(chunks clr_list bitmap_size)))
)
(cond 
	((and f)
		(setq file1 (open f "w"))
		(write-line (strcat "(setq " tilename) file1)
		(write-line (strcat "       '(") file1)
		(foreach row clr_list
			(setq row (mapcar 'itoa row) erow nil)
			(foreach str row
				(if (= (strlen str) 1) (setq erow (cons (strcat "00" str) erow)))
				(if (= (strlen str) 2) (setq erow (cons (strcat "0" str) erow)))
				(if (= (strlen str) 3) (setq erow (cons str erow)))
			)
			(setq str (car erow))

			(foreach itm (cdr erow) (setq str (strcat str " " itm)))
			(write-line (strcat "           " str) file1)
		)
		(write-line  "     )" file1)
		(write-line  ")" file1)
		(write-line   " " file1)
		(write-line   " " file1)
		(write-line   ": image" file1)
		(write-line   "{" file1)
		(write-line   (strcat "key = \"" tilename "\";") file1)
        (write-line   (strcat "width = " (rtos (/ bitmap_size 6.0) 2 2) ";") file1)
        (write-line   "aspect_ratio = 1.0;" file1)
		(write-line   "fixed_width = true;" file1)
		(write-line   "fixed_height = true;" file1)
		(write-line   "color = -15;" file1)
        (write-line   "}" file1)
		(write-line   " " file1)
		(close file1)
		(startapp "explorer" out)
	)
)
(princ)
)
(princ "\nUse commands BMPINIT, BMPDRAW and BMPGENERATE to creatre DCL bitmap image")
(princ)

 

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 8 of 16

nathanwheeler27
Advocate
Advocate

Thank you all for your input, when I get a minute I will go through these suggestions and see what happens.

 

@chaitanya.chikkala The toolbar buttons won't work for this lisp, it will need to be inside the dcl popup.

0 Likes
Message 9 of 16

Sea-Haven
Mentor
Mentor

Have you thought about a child dcl that is multi images, dcl can open a sub dcl open a sub dcl etc. I have 2x2 3x2 4x4 etc you fill the dcl with slide images very easy todo.

 

This is 3x3

 

screenshot292.png

0 Likes
Message 10 of 16

Sea-Haven
Mentor
Mentor

Change the dcl to a button

 

screenshot292.pngscreenshot293.png

0 Likes
Message 11 of 16

nathanwheeler27
Advocate
Advocate

Hmm, that looks like a promising idea. Can you post the dcl/lsp files for that? 

0 Likes
Message 12 of 16

hak_vz
Advisor
Advisor

@nathanwheeler27Here is a lisp file with auto generated DCL for my method.

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 13 of 16

Sea-Haven
Mentor
Mentor

Here is multiple dcl's in the zip file.

 

This is example code to run as a stand alone dcl note written in 1990's  for rel 12. You would just pass the ai_pts _list with your slide names 

 

Can be called though as a sub dcl need to have  a think. I have sub dcl but no call the dd3x3 etc.

 

;;;               Uses DD3X3.DCL for the dialogue definition.  The
;;;               slide images are in list ai_pts_lst.120
;;;              for release 12

; xxxx is slb library name (tlds) is slide name in library
; use individual slide name if no library
(setq ai_pts_lst '("xxxx(TLDS)" "xxxx(dsdn)" "xxxx(trds)"
                   "xxxx(dsr)" "Alblank" "xxxx(DSL)"
                   "xxxx(blds)" "xxxx(dsup)" "xxxx(brds)")
)


(setq ai_pts_lst2 '("33sq1" "33sq2" "33sq3" "33sq4" "33sq5" "33sq6""33sq7" "33sq8" "33sq9" ))

(defun sq_pick ()
  (cond 
    ((= ans "33sq1")(setq ang1 4.7125)(setq ang2 0.0)(tr))
    ((= ans "33sq2")(tm))
    ((= ans "33sq3")(setq ang1 3.1417)(setq ang2 4.7125)(tr))
    ((= ans "33sq4")(tm))
    ((= ans "33sq5")(princ "run other clean up"))
    ((= ans "33sq6")(tm))
    ((= ans "33sq7")(setq ang1 1.5708)(setq ang2 0.0)(tr))
    ((= ans "33sq8")(tm))
    ((= ans "33sq9")(setq ang1 1.5708)(setq ang2 3.1417)(tr))
    )
)

; calculates next slide
(defun alan4 ()
(setq x (+ x 1))
(setq sldname (nth x ai_pts_lst))
)

; third step
; set up slide libraray 
(defun ai_ptype_start ()
  (setq x -1)
  (foreach pts0 ai_pts_lst2
      (alan4)
      (start_image pts0)
      (slide_image 0 0 (- (dimx_tile pts0) 1) (- (dimy_tile pts0) 1) sldname)
      (end_image)
  )
)

; this is second step
(defun ai_ptype_main (/ globals)
  (ai_ptype_start)
;now check each sq if picked then run alan2
  (foreach pd0 ai_pts_lst2
    (action_tile  pd0  "(done_dialog)(setq ans $key)")
  )
  (start_dialog)

)

; this is first step

  (if (= w2 nil)(setw2))      
  
  (setq app "dd3x3.dcl")
  (if (= id_3x3 nil)
    (progn
    (setq dcl_id (load_dialog app))
    (setq id_3x3 dcl_id)
    )
  )
  (if (not (new_dialog "dd3x3" id_3x3))
  (exit))
  (ai_ptype_main)
  (sq_pick)
  (setq *error* old_error old_error nil)

 

Post again if you dont know how to do a sub dcl.

 

 

 

0 Likes
Message 14 of 16

J_Spurgeon
Enthusiast
Enthusiast

@hak_vz wrote:

@nathanwheeler27Here is a lisp file with auto generated DCL for my method.


I am using this exact same method but my images are coming out flipped on the Y axis. Any idea how I could fix this? If I reverse the list it just flips it on the X axis. 

 

J_Spurgeon_0-1657891566548.png

This is supposed to be a "P"

0 Likes
Message 15 of 16

hak_vz
Advisor
Advisor

@J_Spurgeon 

I didn't mentioned before, but you have to mirror your image definition over y axis. That is the way it works in Autocad.

In my code above I have created arrow pointing to the left (code) to create right side arrow.

 

(setq back_img
       '(
           001 005 192 192 192 192 192 005
           001 005 192 192 004 004 192 005
           001 005 192 004 004 004 192 005
           001 005 004 004 004 004 192 005
           001 005 004 004 004 004 192 005
           001 005 192 004 004 004 192 005
           001 005 192 192 004 004 192 005
           001 005 192 192 192 192 192 005
     )
)

 

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 16 of 16

J_Spurgeon
Enthusiast
Enthusiast

@hak_vz wrote:

@J_Spurgeon 

I didn't mentioned before, but you have to mirror your image definition over y axis. That is the way it works in Autocad.

In my code above I have created arrow pointing to the left (code) to create right side arrow.

 

 

(setq back_img
       '(
           001 005 192 192 192 192 192 005
           001 005 192 192 004 004 192 005
           001 005 192 004 004 004 192 005
           001 005 004 004 004 004 192 005
           001 005 004 004 004 004 192 005
           001 005 192 004 004 004 192 005
           001 005 192 192 004 004 192 005
           001 005 192 192 192 192 192 005
     )
)

 

 


Ahh dang, that is going to be tough, I have 48x48 images lol 

J_Spurgeon_0-1657911860166.png

 

0 Likes