Insert an Image into a DCL box

#1
Following on from my post here -> http://forums.intellicadms.com/viewtopi ... 4149#p6664
I am trying to add a PREVIEW image to my DCL box.
Image

I have created a simple dcl/lsp to display a '.sld' file (50x50x6.sld, one I already had)
DCL

Code: Select all

new1 : dialog {					//dialog name
          label = "image" ;			//give it a label
         : row {					//begin row
        : image {				//define image tile
          key = "im3" ;				//give it a name
          height = 12.0 ;			//add a height
          width = 25.0 ;			//and now a width
          fixed_width = true;			//fix the width
          fixed_height = true;			//fix the height
          color = 251;				//graphics_background;		//set background color
        }					//end image
	}					//end row
        ok_cancel ;				//predefined OK/Cancel button
        }					//end dialog 
LSP

Code: Select all

(defun C:new1 ()
;define function	
  (setq dcl_id (load_dialog "new1.dcl"));load dialog
  (if (not (new_dialog "new1" dcl_id)  ;test for dialog
      )					;not
    (exit) 				;exit if no dialog
  )					;end of if
  (setq w (dimx_tile "im3")   		;get image tile width
        h (dimy_tile "im3")    		;get image tile height
  );end of setq
  (start_image "im3")			;start the image
  (slide_image 0 0 w h "50x50x6.sld")	;display a slide
  (end_image)				;end image
  (action_tile
      "accept"			     	;if O.K. pressed		
      "(done_dialog) (setq userclick T)"
      ;close dialog, set flag
   )					;end of action tile
    (action_tile
    "cancel" 				;if cancel button pressed
    "(done_dialog) (setq userclick nil)";close dialog, lower flag
    )					;end of action_tile
(princ)
)					;end defun
;(princ)
This works.
Image

Now to add this to the main project, see previous post!
Here is my DCL

Code: Select all

	
	 	:row {
		:column {	:text {label="PREVIEW";alignment=centered;}
			:image {
			height=16.0;
			width = 50.0 ;			
			color=1;			
			key="imagekey";	
			}
		:column {
			: list_box {
			label = "Sizes";
			width = 22;
			height = 12;
			key = "get_size";
			}
			}
			}


and my LSP

Code: Select all

) ;end CHECK_SELECTIONS
  ;--------------------------------------------------------------------;
  ;--------------------------------------------------------------------;
  ;--------------------------------------------------------------------;
  ;--------------------------------------------------------------------;
 (defun SET_IMAGE ()
  (setq w (dimx_tile "imagekey")   		;get image tile width
        h (dimy_tile "imagekey")    		;get image tile height

  )						;end of setq

  (start_image "imagekey")			;start the image
  (slide_image 0 0 w h "50x50x6.sld")		;display a slide
  (end_image)					;end image
 ) ;End SET_IMAGE
  ;--------------------------------------------------------------------;
  ;--------------------------------------------------------------------;
  ;--------------------------------------------------------------------;
  ;--------------------------------------------------------------------;
  ;--------------------------------------------------------------------;
  ;--------------------------------------------------------------------;
(defun DIALOG ()
But my slide file "50x50x6.sld" is not displayed, just a grey box (color 251)

Any pointers to where I'm going wrong?
Thanks
S

Re: Insert an Image into a DCL box

#6
You did not post full code, maybe some mistakes (syntax/spelling) in your code.

Here's the minimum code, it works as should be.

Code: Select all

(defun SET_IMAGE ()
  (setq w (dimx_tile "imagekey")   		;get image tile width
        h (dimy_tile "imagekey")    		;get image tile height
  )						;end of setq

  (start_image "imagekey")			;start the image
  (slide_image 0 0 w h "50x50x6.sld")		;display a slide
  (end_image)					;end image
 ) ;End SET_IMAGE

(defun C:fredsingle3 (/ DCL_ID )
  (setq DCL_ID (load_dialog "fredsingle2.dcl")) ;load the DCL file
  (if (not (new_dialog "fredsingle2" DCL_ID)) ;initialize the DCL file
    (exit) ;exit if this doesn't work
  ) ;end if

  (SET_IMAGE)

  (action_tile "accept" "(exit)")
  (action_tile "cancel" "(exit)")
  (start_dialog) ;display the dialog box
  (unload_dialog DCL_ID) ;unload the DCL file
  (princ)
)
The fredsingle2.dcl

Code: Select all

// fredsingle2-120
// Revision: 
//   25 Oct  2019 - SLN

fredsingle2 : dialog {
	label = "Steve's Cable Tray menu - fredsingle2";
	: text {
	  label = "Revision A : October 2019 : ";
	}

	 :row {
		:column {	:text {label="PREVIEW";alignment=centered;}
			:image {
			height=16.0;
			width = 50.0 ;			
			color=1;			
			key="imagekey";
			}

			}
			}
			
	: row {
		children_alignment = top;
		:column {
		: boxed_column {
			label = "Light Duty Cable Tray";
			: button {
			key = "ldct1";
			label = "Straight Tray Runs";
			}
			: button {
			key = "ldct2";
			label = "Straight Tray Runs 2";
			}
			}
                	}

		:column {
			: list_box {
			label = "Width Sizes (mm)";
			width = 25;
			height = 10;
			key = "get_size";
			}
			}
			}

	:row {
		fixed_width = true;
		alignment = centered;
		ok_cancel;
		}
	}

Re: Insert an Image into a DCL box

#7
Hi
Thanks for that, it's working now :)

The location for this was the missing link:

Code: Select all

  ) ;end if
  (SET_IMAGE)
  (action_tile "accept" "(exit)")
Now for me to try to add the sld image to the list file
("LD-900mm Straight Run 3mtr" "LD-900mm-tray-run-3000" "ldtr.sld")
("LD-750mm Straight Run 3mtr" "LD-750mm-tray-run-3000" "ldtr.sld")
and make that work. :)

S

Re: Insert an Image into a DCL box

#8
Need more help please.

Here is what I have tried:

Code: Select all

  ;----------------------------------------------------------------------;
 (defun SET_IMAGE ()
; (princ IMG) 					; print the content of IMG variable to the command line.
  (setq IMG  (nth 2 SIZE_DIMS)
  ) ;end setq
 (princ IMG) 					; print the content of IMG variable to the command line.
  (INSERT_IMAGE)				;GOTO INSERT IMAGE
 ) ;End SET_IMAGE
  ;-----------------------------------------------------------------------;
 (defun INSERT_IMAGE ()
 (princ IMG) 					; print the content of IMG variable to the command line.
  (setq w (dimx_tile "imagekey")   			;get image tile width
        h (dimy_tile "imagekey")    			;get image tile height

  )							;end of setq

  (start_image "imagekey")				;start the image
;  (slide_image 0 0 w h (" IMG "))			;display a slide  ;   TOGGLE ';' WITH BELOW
;  (slide_image 0 0 w h  IMG )				;display a slide  ;   TOGGLE ';' WITH BELOW
  (slide_image 0 0 w h "LDCT1.sld")			;display a slide  ;   TOGGLE ';' WITH ABOVE
  (end_image)						;end image
 ) ;End INSERT_IMAGE
  ;----------------------------------------------------------------------;
  ;--------------------------------------------------------------------;
(defun DIALOG ()
  (setq DCL_ID (load_dialog "fredsingle2.dcl")) ;load the DCL file
  (if (not (new_dialog "fredsingle2" DCL_ID)) ;initialize the DCL file
    (exit) ;exit if this doesn't work
  ) ;end if
  (INSERT_IMAGE)				; GOTO INSERT IMAGE  TOGGLE ';' WITH BELOW
;  (SET_IMAGE)					 ; GOTO SET IMAGE    TOGGLE ';' WITH ABOVE

With the two toggle as they are the image 'LDCT1' is displayed :)
If I reverse the toggles (move the ';' at the begining of the line/row) in an attempt to use the variable 'IMG' no image is displayed.
Note: (princ IMG) is blank!
Also neither option for the IMG variable, IMG or (" IMG ") work

Re: Insert an Image into a DCL box

#10
Hi

Thanks for the help again!!:)

I made your changes but it still failed:(

Here is the command promp history

Code: Select all

Command: 
Command: 
Rendering support loaded.
Raster image support loaded.
Command: nil
error: null function: INSERT_IMAGE
Command: fredsingle2
Unable to recognize command "fredsingle2".  Please try again.
Command: '_PMTHIST
I googled 'sldFile' but found nothing?

S

Re: Insert an Image into a DCL box

#12
Thank you again.

The dialogue now loads but does not display the 'sld'
When I select the "Straight Tray Runs" the dialogue closes without displaying the list.

This is the code in the 'dim' file
("LD-75mm Straight Run 3mtr" "LD-75mm-tray-run-3000" "50x50x6.sld")
50x50x6.sld exists and has been displayed in the past.

is that what you intended by this:
"Note: Be sure the sldFile is existing otherwise the image will be blank."

S

Re: Insert an Image into a DCL box

#13
Try this:
- copy to previous code lisp.
- load and run the command : fredsingle4

Code: Select all

(defun DIALOG4 ()
  (setq DCL_ID (load_dialog "fredsingle2.dcl")) ;load the DCL file
  (if (not (new_dialog "fredsingle2" DCL_ID)) ;initialize the DCL file
    (exit) ;exit if this doesn't work
  ) ;end if
  (DEFAULTS)
  (action_tile
    "ldct2"
    (strcat
      "(setq newtile $key)"
      "(READ_DIM_FILE)"
    ) ;_ end of strcat
  ) ;_ end of action_tile
  (action_tile
    "ldct1"
    (strcat
      "(setq newtile $key)"
      "(READ_DIM_FILE)"
    ) ;_ end of strcat
  ) ;_ end of action_tile
  (action_tile
    "get_size"
    (strcat
      "(setq index (atoi $value))"
      "(setq size (strcase (nth index display_list)))"
      "(DIM_LIST)" "(SET_IMAGE4)"
    ) ;_ end of strcat
  ) ;_ end of action_tile
  (action_tile "accept" "(CHECK_SELECTIONS)")
  (action_tile
    "cancel"
    (strcat "(done_dialog)" "(setq newtile nil size nil )" "(exit)")
  ) ;_ end of action_tile
  (action_tile "help" "(help)")
  (start_dialog) ;display the dialog box
  (unload_dialog DCL_ID) ;unload the DCL file
) ;end DIALOG


(defun SET_IMAGE4 ()
  (setq w (dimx_tile "imagekey")   		;get image tile width
        h (dimy_tile "imagekey")    		;get image tile height
  )						;end of setq

  (setq sldFile(nth 2 SIZE_DIMS))
  (if (not (findfile sldFile))
    (progn
      (alert (strcat "Not found file: " sldFile))
      (setq sldFile "default.sld")))

  (start_image "imagekey")			;start the image
  ;(slide_image 0 0 w h "50x50x6.sld")		;display a slide
  (fill_image 0 0 w h 9)
  (slide_image 0 0 w h sldFile)			;display a slide
  (end_image)					;end image
  
 ) ;End SET_IMAGE


(defun C:fredsingle4 (/ NEWTILE SIZE DISPLAY_LIST INDEX D DIM_FILE )
  (setq
    OLDERR *ERROR*
    *ERROR* ERR
  ) ;_ end of setq
  (setq OS (getvar "OSMODE"))
  (setvar "OSMODE" 111)
  (DIALOG4)
  (DRAW_SHAPE)
  (setvar "OSMODE" OS)
  (setq *ERROR* OLDERR) ; Restore old *error* handler
  (princ)
) ;end 
cron