I am still unable to get slide library images to view?

I am still unable to get slide library images to view?

DC-MWA
Collaborator Collaborator
3,311 Views
26 Replies
Message 1 of 27

I am still unable to get slide library images to view?

DC-MWA
Collaborator
Collaborator

Hello all,

I am back again with this routine. Despite my efforts and input from others I am still unable to get the slide library to display images. It's not the end of the world but having dozens of separate slide files to babysit is kind of a pain.

Wondering if I could get some more input from the gurus to assist me with this.

The lisp and the slide library file are attached. 

Thanks in advance for your assistance.

-DC

0 Likes
Accepted solutions (2)
3,312 Views
26 Replies
Replies (26)
Message 2 of 27

scot-65
Advisor
Advisor
Without too much code digging...

In your slide sub, did findfile find the file?

(for me,) action_tile can only have two sets of quotes (" ") total.
You show an apostrophe (') followed by a bunch of quotes and
the entire statement is not wrapped inside quotes.
I am not familiar with this type of structure.

(action_tile "accept" "(callSub \"with escaped quotes\")(done_dialog 1)")

???

Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

0 Likes
Message 3 of 27

DC-MWA
Collaborator
Collaborator

Thank you for your response. The program does not have an external dcl file, it writes the dcl file on the fly at time of use. That's why the "escaped quotes" are there. It works great with separate slide files. I just can't seem to get it to read from a slide library file. 

Again, thank you for your response.

-DC

0 Likes
Message 4 of 27

scot-65
Advisor
Advisor

Escaped quotes inside the action_tile is what I was focusing on.

 

Personally I would keep as separate slides, and in a dedicated directory.

Have you considered what it would take to expand/reduce the available

list of blocks as the utility as what you show is static.

How many times will you be updating the utility and deploying?

 

How about this strategy [assuming slide names are the same as block names]:

Create a "dashboard" section (below the start_dialog)

- Check registry for path to slide library directory.

 -- If not there, prompt user for location (use browse for folder).

 -- Record path to registry [profiles/dialog section -or- HKCU/software section].

- Use vl-directory-files to gather all of the slide names.

 -- Strip off file extension.

 -- Sort the list.

 -- Check for existing blocks of same name [findfile].

 --- If no matching names, remove slide name from list.

- Write temporary dialog.

- Display dialog.

 -- Set initial values to both the list box and image tile.

 -- Fetch list box position and save as session gremlin.

- Check if start_dialog/done_dialog is 1 and enter main program.

 

 

Replace what you have for the list box action_tile with this:

(action_tile "lst" "(slide (nth (atoi $value) lst))")

...temporarily change "slide" with "alert" to see the results.

I envision a 30% total character count reduction in your code

if you employ the line above as is, with no changes.

 

(start_list key)(foreach itm lst (add_list itm))(end_list)

replace with (start_list "lst")(mapcar 'add_list lst)(end_list)

You do not have multiple list boxes to populate.

 

You use ok_cancel however there is no OK button in your dcl.

(action_tile "accept" "(setq SessionGremlin (get_tile \"lst\"))(done_dialog 1)")

You do not need to remember the file name for next time. Just the

position of the list box. [also part of the 30% character count reduction]

 

To repeat, add a checkbox to the dialog?

Allow the user to be able to change the directory of the slide library.

 

(slide_image 1 1 (- (dimx_tile key) 2) (- (dimy_tile key) 2) file)

Your reply mentioned SLB. The variable "file" is not in that format.

 

???

 


Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

0 Likes
Message 5 of 27

DC-MWA
Collaborator
Collaborator

That is a lot to digest. Let me play around with some your ideas/suggestions.

thanks.

0 Likes
Message 6 of 27

Moshe-A
Mentor
Mentor

@DC-MWA  hi,

 

i'll start by answering to your question in title:

 

there is noting wrong with (slide_image) function and it works as expected the only issue is with slidelib.exe... it is old and it does not support spaces in slide file names so what you have to do is replace spaces with dashs or underlines and  recreate SLB file 😀

 

here is my version to your program. made massive changes to the code and structure so you have to follow the code and if you do not understand something, do not hesitate to ask.

 

some comments though:

1. it's better to save the slb file in a folder which is under AutoCAD support file search path.

   anyway if the file is not found no harm is made to the program (only the image won't show)

3.  there is a huge advantage in creating the dcl on the fly only if the dcl is changing at run time. in your case the dcl layout is steady so better create a dcl file and wrap the lsp + dcl in a vlx file.

2.  As for the control of the dialog box, it's better to put the all process in a (while) function and temporary close the dialog to run standard AutoCAD command and reopen the dialog if needed (with out invoking the lisp again).

the while starts by opening the dialog then set default tiles values then defines the (action_tile) and last (start_dialog) under that (and after the dialog is closed) a (cond) function to respond to user selection and execute (command) function. 

in (action_tile) call, do not implement all your code on one line, better call a callback function to do your work.

this way as you can see, the code under (while) is not to much loaded and very easy to read and debug.

3.  any dialog has 2 buttons by default: OK and Cancel. the default behavior for OK and Cancel button is to close the dialog. so if you have a simple dialog and all you want a simple close, you do not have to implement code for these 2 button but if you want to retrieve some tiles value, you need to define a callback function for the "accept" key and there retrieve tiles value and call (done_dialog 1) to close the dialog (the same for "cancel" key)

4. see how i cut the code to local functions\procedures to make the program more easily read and maintain.

 

enjoy

moshe

 

 

;;;Wall routine for MWA

(defun c:WA (/ *error* show_image create_dcl make_data init_tiles ctrl_list ctrl_accept ; local functions
                lst shoutback what_next dch des dcl selLst_item)

 (defun *error* (msg)
  (if (> dch 0)
   (unload_dialog dch)
  )
   
  (if (= (type des) 'FILE)
   (close des)
   )
   
  (if (and (= (type dcl) 'STR)
           (findfile dcl)
      )
   (vl-file-delete dcl)
  )
   
  (if (and msg
	   (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*"))
      )
   (princ (strcat "\nError: " msg))
  )
  (princ)
 ); *error*
  
 (defun show_image (key file)
  (start_image key)
  (fill_image 0 0 (dimx_tile key) (dimy_tile key) 0) 
  (slide_image 1 1 (- (dimx_tile key) 2) (- (dimy_tile key) 2) file)
  (end_image)
 ); show_image
  
 (defun create_dcl ()
  (and
    (setq dcl (vl-filename-mktemp nil nil ".dcl"))
    (setq des (open dcl "w"))
    (foreach str '(
                    "listbox : dialog"
                    "{"
                    "    label = \"SELECT WALL STYLE\";"
                    "    spacer;"
                    ":row{"
                    "    : column"
                    "    {"
                    "        : list_box"
                    "        {label = \"Select from list\";"
                    "            key = \"lst\";"
                    "            width = 28;"
                    "            height = 16;"
                    "            fixed_width = true;"
                    "            fixed_height = true;"
                    "            multiple_select = false;"
                    "        }"
                    "    }"
		    ": column {"
                    ": boxed_column { label = \"Preview\";"
		    ": image { "
                    " key = \"sld\";"
                    " height = 13;"
                    " fixed_height = true;"
                    " width = 30;"
                    " fixed_width = true;"
                    " color = 0;"
                    " aspect_ratio = 1;"
                    " is_enabled = false;"
                    " is_tab_stop = false;}"
		    "}"
		    "}"
		    "}"
                    "    spacer;"
                    ;":row{"
                    "ok_cancel;"
                    ":row{"
                    ": concatenation {: text_part {key = \"var_val\";width=35;}}"
                    ":image {key=\"dclLogo\";fixed_width=true;"
		    "fixed_height=true;alignment=centered;"
                    "is_enabled=true;width=6;height=1.4;color=-15;}"
                    "}"
                    "}"
                  )
              (write-line str des)
            ); foreach
            (not (setq des (close des)))
            (> (setq dch (load_dialog dcl)) 0)
  ); and
 ); create_dcl

 (defun make_data ()
  '("3.5-FIRE-1"
    "3.5-FIRE-2"
    "3.5-Sound"
    "3.5-Wall"
    "3.5-With Veneer"
    "4-Wall"
    "5.5-FIRE-1"
    "5.5-FIRE-2"
    "5.5-Sound"
    "5.5-Wall"
    "5.5-With-Veneer"
    "6-FIRE-1"
    "6-FIRE-2"
    "6-Sound"
    "6-Wall"
    "7.5-FIRE-2"
    "7.5-Sound"
    "7.5-Wall"
    "8-inch-demising-wall"
    "CMU-8"
    "CMU-8-Furring"
    "Concrete-8"
    "CMU-12"
    "CMU-12-Furring"
    "Concrete-12"
    "Glass-Block"
    "Toilet_Ptn"
  )
 ); make_data 

 (defun init_tiles ( / populate_list init_logo_image ;| local functions |;)

  (defun populate_list ()
   (start_list "lst")
   (foreach itm lst (add_list itm))
   (end_list)
  ); populate_list

  (defun init_logo_image (/ h1 h2)
   (setq h1 (dimx_tile "dclLogo"))
   (setq h2 (dimy_tile "dclLogo"))
   (start_image "dclLogo")
   (slide_image 7 0 h1 h2 "dclLogo")
   (end_image)
  ); init_logo_image

   
  ; here start init_tiles 
  (populate_list)
  (init_logo_image) 

  (if (= shoutback 1)
   (set_tile "var_val" "Select wall style to get started..")
   (set_tile "var_val" (strcat "Hit enter to repeat < " shoutback " > "))
  )
 ); init_tiles

 ; callback
 (defun ctrl_list (value)
  (show_image "sld" (strcat "mwa-walladd(" (nth (atoi value) lst) ")"))
 ); ctrl_list 

 ; callback
 (defun ctrl_accept ()
  (setq selLst_item (get_tile "lst"))
  (done_dialog 1) 
 ); ctrl_accept

 ; here start C:WA
 (setvar "cmdecho" 0)
 (command "._undo" "_begin") 

 (if (tblsearch "layer" "A-WALL")
  (command "._layer" "_color" 50 "A-WALL" "")
  (command "._layer" "_new" "A-WALL" "_color" 50 "" "") 
 ); if

 (if (not (tblsearch "block" "MWA-AECSTYLES"))
  (progn
   (princ "Importing MWA-AECSTYLES")
   (command ".-insert" "MWA-AECSTYLES") (command)
  ); progn
 ); if

 (setq lst (make_data))

 (if (not shoutback)
  (setq shoutback 1)
 );end if 

 (if (create_dcl)
  (progn
   (setq what_next 2)

   (while (> what_next 1)
    (if (not (new_dialog "listbox" dch "" '(-1 -1))); open dialog at center
     (exit)
    )

    (init_tiles)
     
    (action_tile "lst" "(ctrl_list $value)")
    (action_tile "accept" "(ctrl_accept)")
 
    (setq what_next (start_dialog))

    (cond
     ((= what_next 0)
      ; do clean up if needed
     ); case
     ((= what_next 1)
      (setvar "cmdecho" 1)
      
      (if (eq selLst_item "")
       (command "-walladd")	
       (command "-walladd" "h" pause "st" (setq shoutback (nth selLst_item lst)))
      )
	
      (prompt "\nStart picking points to draw wall..")
      (while (/= (getvar "cmdactive") 0)
       (command pause)
      )

      (princ (strcat "\n<" shoutback "> is the current wall style"))
      (setvar "cmdecho" 1)
      (princ "\nMW Wall Done!")
     ); case
     ( t
      ; handle other codes
     ); case
    ); cond
     
   ); while  

  ); progn
 ); if


 (command "._undo" "_end")
 (setvar "cmdecho" 1)

 (princ)
); C:WA


 

 

0 Likes
Message 7 of 27

Moshe-A
Mentor
Mentor

@DC-MWA ,

 

Oh, one more thing i forgot to say: i did not test it. i do not have MWA-AECSTYLES.dwg plus the WALLADD command.

and speaking on MWA-ACESTYLES this string appears at least 5 time in code so consider using a constant variable something like this:

 

(setq AEC_LIBRARY "mwa-aecstyles") ; const

0 Likes
Message 8 of 27

DC-MWA
Collaborator
Collaborator

Moshe,

This is sweet. Changing the name of our wall styles is a big deal. So I'm going to run it up the ladder as they say and see where it goes. I will continue to play with this and get back to you.

Thanks again.

-DC

0 Likes
Message 9 of 27

Moshe-A
Mentor
Mentor

@DC-MWA ,

 

that's very easy to solve, make your data list dotted pair where the first string is your real wall style and the second goes for the the sld name:

 

(defun make_data ()
  '(("3.5 FIRE-1" 		. "3.5-FIRE-1")
    ("3.5 FIRE-2" 		. "3.5-FIRE-2")
    ("3.5 Sound" 		. "3.5-Sound")
    ("3.5 Wall" 		. "3.5-Wall")
    ("3.5 With Veneer" 		. "3.5-With Veneer")
    ("4 Wall" 			. "4-Wall")
    ("5.5 FIRE-1" 		. "5.5-FIRE-1")
    ("5.5 FIRE-2"           	. "5.5-FIRE-2")
    ("5.5 Sound"            	. "5.5-Sound")
    ("5.5 Wall"             	. "5.5-Wall")
    ("5.5 With Veneer"		. "5.5-With-Veneer")
    ("6 FIRE-1" 		. "6-FIRE-1")
    ("6 FIRE-2" 		. "6-FIRE-2")
    ("6 Sound" 			. "6-Sound")
    ("6 Wall" 			. "6-Wall")
    ("7.5 FIRE-2" 		. "7.5-FIRE-2")
    ("7.5 Sound" 		. "7.5-Sound")
    ("7.5 Wall"             	. "7.5-Wall")
    ("8 inch demising wall" 	. "8-inch-demising-wall")
    ("CMU-8" 			. "CMU-8")
    ("CMU-8 Furring" 		. "CMU-8-Furring")
    ("Concrete-8" 		. "Concrete-8")
    ("CMU-12" 			. "CMU-12")
    ("CMU-12 Furring" 		. "CMU-12-Furring")
    ("Concrete-12" 		. "Concrete-12")
    ("Glass Block" 		. "Glass-Block")
    ("Toilet_Ptn" 		. "Toilet_Ptn")
  )
 ); make_date 

attached is the fixed lisp

 

 

0 Likes
Message 10 of 27

DC-MWA
Collaborator
Collaborator

Ok, I recreated the side library file with the new names, I now get the desired views.

When I select a new wall selection I get error message...

Error: bad argument type: fixnump: "3"

 

If repeat a wall selection I get error message..

Error: bad argument type: stringp 1

after wall is inserted.

0 Likes
Message 11 of 27

Moshe-A
Mentor
Mentor

when i do that on my code there is no error at all.

 

remember that the index comes from selecting a list item is a string ("0" "1" "2" ) and you have to convert it to integer for the (nth) function.

 

moshe

 

 

 

0 Likes
Message 12 of 27

DC-MWA
Collaborator
Collaborator

I am using your code So I'm not sure what is happening....

See attached...

 

0 Likes
Message 13 of 27

Moshe-A
Mentor
Mentor
Accepted solution

@DC-MWA ,

 

see the correction/addition in red.

 

 

(if (eq selLst_item "")
 (command "-walladd")	
 (command "-walladd" "h" pause "st" (setq shoutback (car (nth (atoi selLst_item) lst))))
)

 

 

As i said i do not have WALLADD command so i can not test it. make the quick correction i'm waiting 10m to hear it is working i have to retire to bed 😀

 

 

0 Likes
Message 14 of 27

DC-MWA
Collaborator
Collaborator

I had to add   (if (= shoutback nil)(setq shoutback 1))  and remove shoutback from the variables to get shoutback to function correctly and do fast repeat.

Other than that this seems to work well

Thank you very very much. I'm goin to use what I learned here to fix my other two routines that use a lot of the same parts.

I truly appreciate your time and effort!!

 

0 Likes
Message 15 of 27

Moshe-A
Mentor
Mentor

@DC-MWA 

 

good morning  😀 glad to hear it's sorted out

 

i did not remove that code (see in red)

(= shoutback nil) is the same as (not shoutback)

 

have a nice day

moshe

 

 

(setq lst (make_data))

 (if (not shoutback)
  (setq shoutback 1)
 );end if 

 (if (create_dcl)
  (progn
   (setq what_next 2)
0 Likes
Message 16 of 27

DC-MWA
Collaborator
Collaborator

Hi Moshe,

It's working great. We did lose the preview slide when repeating wall styles. The slide stays black but the command repeats correctly.

Any ideas?

0 Likes
Message 17 of 27

Moshe-A
Mentor
Mentor

@DC-MWA ,

 

manually make sure the SLB file is ok by invoking VSLIDE command and call in each sld. the only way to update the slb file is to recreate it. 

 

moshe

  

 

 

 

 

0 Likes
Message 18 of 27

DC-MWA
Collaborator
Collaborator

Hi Moshe,

The slide lib (.slb) file has been recreated and works great. The issue is when the program "remembers" the last wall style and allows you to simply hit ok to repeat the command, there is no slide image of the wall style to be repeated.

In the original lisp I had used the following to make the preview for the repeat image:

 

(action_tile "lst"
(vl-prin1-to-string
'(progn
(setq idx (read (strcat "(" $value ")")))
(slide "sld" (strcat (nth (atoi $value) lst) ".sld"))
(setq sel1 $value)
(setq sel1temp (atoi $value))
)
)
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;remember slide
(cond ((= sel1temp 0) (slide "sld" (strcat (nth (atoi (set_tile "lst" "0")) lst) ".sld")))
((= sel1temp 1) (slide "sld" (strcat (nth (atoi (set_tile "lst" "1")) lst) ".sld")))
((= sel1temp 2) (slide "sld" (strcat (nth (atoi (set_tile "lst" "2")) lst) ".sld")))
((= sel1temp 3) (slide "sld" (strcat (nth (atoi (set_tile "lst" "3")) lst) ".sld")))
((= sel1temp 4) (slide "sld" (strcat (nth (atoi (set_tile "lst" "4")) lst) ".sld")))
((= sel1temp 5) (slide "sld" (strcat (nth (atoi (set_tile "lst" "5")) lst) ".sld")))
((= sel1temp 6) (slide "sld" (strcat (nth (atoi (set_tile "lst" "6")) lst) ".sld")))
((= sel1temp 7) (slide "sld" (strcat (nth (atoi (set_tile "lst" "7")) lst) ".sld")))
((= sel1temp 😎 (slide "sld" (strcat (nth (atoi (set_tile "lst" "8")) lst) ".sld")))
((= sel1temp 9) (slide "sld" (strcat (nth (atoi (set_tile "lst" "9")) lst) ".sld")))
((= sel1temp 10) (slide "sld" (strcat (nth (atoi (set_tile "lst" "10")) lst) ".sld")))
((= sel1temp 11) (slide "sld" (strcat (nth (atoi (set_tile "lst" "11")) lst) ".sld")))
((= sel1temp 12) (slide "sld" (strcat (nth (atoi (set_tile "lst" "12")) lst) ".sld")))
((= sel1temp 13) (slide "sld" (strcat (nth (atoi (set_tile "lst" "13")) lst) ".sld")))
((= sel1temp 14) (slide "sld" (strcat (nth (atoi (set_tile "lst" "14")) lst) ".sld")))
((= sel1temp 15) (slide "sld" (strcat (nth (atoi (set_tile "lst" "15")) lst) ".sld")))
((= sel1temp 16) (slide "sld" (strcat (nth (atoi (set_tile "lst" "16")) lst) ".sld")))
((= sel1temp 17) (slide "sld" (strcat (nth (atoi (set_tile "lst" "17")) lst) ".sld")))
((= sel1temp 18) (slide "sld" (strcat (nth (atoi (set_tile "lst" "18")) lst) ".sld")))
((= sel1temp 19) (slide "sld" (strcat (nth (atoi (set_tile "lst" "19")) lst) ".sld")))
((= sel1temp 20) (slide "sld" (strcat (nth (atoi (set_tile "lst" "20")) lst) ".sld")))
((= sel1temp 21) (slide "sld" (strcat (nth (atoi (set_tile "lst" "21")) lst) ".sld")))
((= sel1temp 22) (slide "sld" (strcat (nth (atoi (set_tile "lst" "22")) lst) ".sld")))

((= sel1temp 23) (slide "sld" (strcat (nth (atoi (set_tile "lst" "23")) lst) ".sld")))
((= sel1temp 24) (slide "sld" (strcat (nth (atoi (set_tile "lst" "24")) lst) ".sld")))
((= sel1temp 25) (slide "sld" (strcat (nth (atoi (set_tile "lst" "25")) lst) ".sld")))
((= sel1temp 26) (slide "sld" (strcat (nth (atoi (set_tile "lst" "26")) lst) ".sld")))

);end cond
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;end remember slide

 

Not sure how to approach this with new code.

0 Likes
Message 19 of 27

Moshe-A
Mentor
Mentor

if i try to understands what you are saying the issue is? when you select a list item (wall style) and click OK button?

what is 'repeat command \ repeat image'?

no slide image of wall style to be repeated?

sorry i do not understand?!

 

0 Likes
Message 20 of 27

DC-MWA
Collaborator
Collaborator

After the user selects wall and uses program, if they reyurn to the program, it remembers the last wall selection so the user doesn't have to select from the list again, they can simply hi ok and repeat the previously selected wall selection.

It also displays the wall style name at bottom of dialog with instructions to select or hit enter to repeat. See image.MWA-WALLADD dialog.JPG

0 Likes