Newby - trying to create icon menu using slides

Started by The Dark Princess, March 11, 2009, 07:07:00 PM

Previous topic - Next topic

The Dark Princess

Some quick queries.  Say i wish to have an icon menu that shows acad slides. 

I've tried to get this bit workingg but I keep getting an ADS eror nil value for SlideImage1

here's a snippet 
Now I've played with moving the dcl_form_show and restarting autocad etc and I still get the same ads error.  I've tried putting the sld in the same folder and having just the sld filename (with .sld extension) and still get the same error.
Thanks for any help you can suggest

TDP


Code (autolisp) Select
(dcl_project_load (strcat ARCTDRVESP "\\iconmenu.odcl"))
(defun c:iconmenu_OnInitialize (/)
(setq ctr 0)
(repeat 8
    (setq sld (arctgv (strcat "icon" (itoa ctr)) menulst)
              slb (substr sld 1 (vl-string-position (ascii "(") sld))
              sld (jdd-string-subst "" (list slb ")" "(") sld)
              slb (strcat ARCTDRVEPREF "Slides\\" slb ".slb")
     )
     (princ (strcat "\n" slb  "," sld))
     (cond
         ((= ctr 0)
           (dcl_SLIDEVIEW_LOAD iconmenu_SlideView1 slb sld)
         )
         ((= ctr 1)
           (dcl_SLIDEVIEW_LOAD iconmenu_SlideView2 slb sld)
         )
         ((= ctr 2)
           (dcl_SLIDEVIEW_LOAD iconmenu_SlideView3 slb sld)
         )
         ((= ctr 3)
           (dcl_SLIDEVIEW_LOAD iconmenu_SlideView4 slb sld)
         )
             ((= ctr 4)
           (dcl_SLIDEVIEW_LOAD iconmenu_SlideView5 slb sld)
         )
         ((= ctr 5)
           (dcl_SLIDEVIEW_LOAD iconmenu_SlideView6 slb sld)
         )
         ((= ctr 6)
           (dcl_SLIDEVIEW_LOAD iconmenu_SlideView7 slb sld)
         )
         ((= ctr 7)
           (dcl_SLIDEVIEW_LOAD iconmenu_SlideView8 slb sld)
         )
     )
    (setq ctr (1+ ctr))
)
)

(dcl_Form_Show iconmenu)

(defun c:SlideView1_OnClicked (/)
  (get_iconmenu_cmds  0)
)
(defun c:SlideView2_OnClicked (/)
  (get_iconmenu_cmds  1)
)
(defun c:SlideView3_OnClicked (/)
  (get_iconmenu_cmds  2)
)
(defun c:SlideView4_OnClicked (/)
  (get_iconmenu_cmds  3)
)
(defun c:SlideView5_OnClicked (/)
  (get_iconmenu_cmds  4)
)
(defun c:SlideView6_OnClicked (/)
  (get_iconmenu_cmds  5)
)
(defun c:SlideView7_OnClicked (/)
  (get_iconmenu_cmds  6)
)
(defun c:SlideView8_OnClicked (/)
  (get_iconmenu_cmds  7)
)

(defun c:SlideView1_OnDblClicked (/)
  (get_iconmenu_cmds  0) (dcl_Form_Close  iconmenu)
)
(defun c:SlideView2_OnDblClicked (/)
  (get_iconmenu_cmds  1) (dcl_Form_Close  iconmenu)
)
(defun c:SlideView3_OnDblClicked (/)
  (get_iconmenu_cmds  2) (dcl_Form_Close  iconmenu)
)
(defun c:SlideView4_OnDblClicked (/)
  (get_iconmenu_cmds  3) (dcl_Form_Close  iconmenu)
)
(defun c:SlideView5_OnDblClicked (/)
  (get_iconmenu_cmds  4) (dcl_Form_Close  iconmenu)
)
(defun c:SlideView6_OnDblClicked (/)
  (get_iconmenu_cmds  5) (dcl_Form_Close  iconmenu)
)
(defun c:SlideView7_OnDblClicked (/)
  (get_iconmenu_cmds  6) (dcl_Form_Close  iconmenu)
)
(defun c:SlideView8_OnDblClicked (/)
  (get_iconmenu_cmds  7) (dcl_Form_Close  iconmenu)
)

(defun c:iconmenu_OnClose (UpperLeftX UpperLeftY /)
   (dcl_Form_Close iconmenu)
)


I would prefer to write part of this as:

Code (autolisp) Select
(setq ctr 0)
(repeat 8
    (setq sld (arctgv (strcat "icon" (itoa ctr)) menulst)
              slb (substr sld 1 (vl-string-position (ascii "(") sld))
              sld (jdd-string-subst "" (list slb ")" "(") sld)
              slb (strcat ARCTDRVEPREF "Slides\\" slb ".slb")
     )
    (dcl_SLIDEVIEW_LOAD (read (strcat "iconmenu_SlideView" (itoa (setq ctr (1+ ctr))))) slb sld)
)


can this be done?

owenwengerd

There is no "SlideImage1" in the code that you posted. If you meant "iconmenu_SlideView1" is NIL, then double check the control name to make sure you have it right (double-click on the slideview control in Studio, select the Load method, then click the "copy-to-clipboard" button to get it straight from the source). In addition, ake sure you're loading the correct .odcl file.

Add an (eval) around your (read) and your proposed code should work fine. You can also specify the control handle via three strings (see http://www.opendcl.com/HelpFiles/index.php?lang=ENU&page=Reference/DataType/Control.htm). If you use strings, then only the last string changes. Same effect, perhaps slightly simpler than what you have now.
Owen Wengerd (Outside The Box) / ManuSoft

BazzaCAD

#2
Here is a snippet I use to populate a bunch of DwgPreview controls with the 3 string approach.
Just change the (dcl_DwgPreview_LoadDwg) function to (dcl_SLIDEVIEW_LOAD)
It's much easier the (eval) (read) approach.

Code (autolisp) Select

(setq CtrlCnt 1)
(repeat 16
  (dcl_DwgPreview_LoadDwg "BX" "frmBlkLibMain" (strcat "DwgPreview" (itoa CtrlCnt)) "PathTOFile")
  (setq CtrlCnt (1+ CtrlCnt))
);_ while


Just an FYI, you can use the DwgPreview control instead of the SlideView if you wish.
IMO, it's much easier to deal with because you don't have to manage a bunch of intermediate slide files.
For example, if some of your blocks or DWG's change, you have to recreate your slides again. Also, when creating the slides, the aspect ratio of Acad's edit window effects the slides. So they'll appear to be zoomed differently.
On the other hand, if you use the DwgPreview, all you have to do is change your DWG file & OpenDCL will display the thumbnail preview image for it.

That's just my 2 cents, if you're converting some old DCL code & have all your slides already made & none of them are going to change, then yes the SlideView probably is the way to go.


a.k.a.
Barry Ralphs
barryDOTralphsATgmailDOTcom

The Dark Princess

#3
Thanks for the suggestions.  I had the darned thing working and then played with some of the settinggs of the slide tiles. I'm using 5.22 and am wondering if I should go back to 4.

The current odcl and lsip crashes acad 2009 and acad 2008 without a pause.  It freezes acad 2004 and shows the 10 slides on the 2nd row and only the last two on the top.  I have a feeling that my odcl is futzed.

I have 3,000 slid files and am not really interested in pushing all that into another format if it can be avoided.

The total code is pasted below, the snippets are first.  The 20 slides are arranged in order in the project dcl and I have played with thing adjusting the use bottom/use left from right numbers and can't get it to not crash acad.

TDP

Code (autolisp) Select

(defun resize_reposition_slides (/  wi  hi bd x1 y1 wp hp j ctr)
    (setq wp (dcl_Control_Getwidth iconmenu)
              bd 2
              wi (fix (/ (- wp (* (1+ ICONCOLS) bd)) ICONCOLS))
              hi (fix (* wi 0.75))
              hp (+  20 (*  (1+ ICONCOLS)  bd) (* ICONROWS hi))
              x1 0
              y1 0
              j 0
              ctr 0
     )
    (dcl_Control_SetHeight  iconmenu (fix hp))
      (repeat 1
          (setq x1 bd
                   y1 (+ bd (* j (+ bd hi)))
         )
          (repeat ICONCOLS
              (setq ctrl (eval (read (strcat "SlideView" (itoa ctr)))))
              (dcl_Control_SetUseRightFromRight  ctrl 2);  i've turned this on and off to no avail
              (dcl_Control_SetUseBottomFromBottom ctrl 0)  i've turned this on and off to no avail
              (dcl_Control_SetLeft ctrl (fix x1))
              (dcl_Control_SetTop ctrl (fix y1))
              (dcl_Control_SetWidth  ctrl (fix wi))
              (dcl_Control_SetHeight ctrl (fix hi))
             ; (dcl_Control_SetPos ctrl (fix x1) (fix y1) (fix wi) (fix hi))

             (setq x1 (+ x1 bd wi)
                       ctr (1+ ctr)
              )
           )
          (setq j (1+ j))
     )
)

(progn

(defun get_iconmenu_cmds ( n /)
  (setq cmds (arctgv (strcat "cicon" (itoa (+ n (* ICONROWS ICONCOLS pageno)))) menulst))
)
(setdetailvars ARCTANNOVAR)
(setq iconmenuname "SYMBOLS-AIA")
  (setq pageno 0
            iconno nil
    )
  (if (= (type iconmenuname) 'LIST)
      (setq mode1 (reducepathtoname (cadr iconmenuname))
               iconmenuname (car iconmenuname)
      );   this means that the icon is preselected beforehand
     (if (setq temp (cdf_list (arctgv iconmenuname DSAISOFTMENUPICK)))
         (setq pageno (atoi (car temp))
                  iconno (cadr temp)
                  mode1 ""
         )
       (setq mode1 nil)
    )
  )
  (if (setq ret (arctgv iconmenuname DSAISOFTMENU))
      (progn
          (setq ret (cdf_list (list ret "|"))
                lbl (strcat "DSAISoft   " (substr (car ret) 2 (- (strlen (car ret)) 2)))
                menulst nil
                ctr 0
                numpages (/ (float (length (cdr ret))) (* ICONROWS ICONCOLS))
                numpages (if (/= (fix numpages) numpages)(1+ (fix numpages)) (fix numpages))
          )
          (foreach x (cdr ret)
             (setq str1 (strcat "icon" (itoa ctr))
                   ctr (1+ ctr)
             )
             (if (wcmatch (strcase x) "*BLANK*")
                 (setq menulst (cons (cons str1 "[BLANK]") menulst))
                 (progn
                     (setq y (substr x 2)
                              y (cond
                                   ((vl-string-position (ascii ",") y)
                                     (strcat (substr y 1 (vl-string-position (ascii ",") y)) ")")
                                    )
                                   (T
                                      (strcat (substr y 1 (vl-string-position (ascii "]") y)) ")")
                                   )
                                )
                          menulst (cons (cons str1 y) menulst)
                          y (cond
                                ((and (setq x1 (vl-string-search "(setq ARCTBLKINFO \"" x))
                                         (vl-string-position (ascii "\"") x)
                                         (setq x1 (substr x (+ (vl-string-position (ascii "\"") x) 2)))
                                         (vl-string-position (ascii "\"") x1)
                                         (setq x1 (substr x1 1 (vl-string-position (ascii "\"") x1)))
                                         (setq x1 (nth 3 (cdf_list x1)))
                                  )
                                  x1
                                )
                                ((vl-string-position (ascii ",") x)
                                    (setq y (substr x (+ (vl-string-position (ascii ",") x) 2)))
                                    (substr y 1 (vl-string-position (ascii ")") y))
                                )
                                (T
                                  ""
                                )
                           )   
                          menulst (cons (cons (strcat "n" str1) y) menulst)
                          y (substr x (+ (vl-string-position (ascii "]") x) 2))
                          menulst (cons (cons (strcat "c" str1) y) menulst)
                  )
                  (if (and (zeros mode1)(not iconno))
                       (if (wcmatch (strcase y) (strcase (strcat "*" mode1 "*")))
                           (setq iconno str1)
                        )
                   )
             ); progn
     )
          )
        );   progn
        (progn
           (princ (strcat "\nMenu Name " iconmenuname " not Found!"))
           (exit)
        )
      )
(defun get_slide_lib ( i /)
    (substr  (arctgv (strcat "icon" (itoa i)) menulst) 1 (vl-string-position (ascii "(") (arctgv (strcat "icon" (itoa i)) menulst)))
)
(defun get_slide ( i /)
        (jdd-string-subst "" (list (get_slide_lib i) ")" "(") (arctgv (strcat "icon" (itoa i)) menulst))
)
(defun resize_reposition_slides (/ ); wi  hi bd x1 y1 wp hp j ctr)
    (setq wp (dcl_Control_Getwidth iconmenu)
              bd 2
              wi (fix (/ (- wp (* (1+ ICONCOLS) bd)) ICONCOLS))
              hi (fix (* wi 0.75))
              hp (+  20 (*  (1+ ICONCOLS)  bd) (* ICONROWS hi))
              x1 0
              y1 0
              j 0
              ctr 0
     )
    (dcl_Control_SetHeight  iconmenu (fix hp))
      (repeat 1
          (setq x1 bd
                   y1 (+ bd (* j (+ bd hi)))
         )
          (repeat ICONCOLS
              (setq ctrl (eval (read (strcat "SlideView" (itoa ctr)))))
              (dcl_Control_SetUseRightFromRight  ctrl 2)
              (dcl_Control_SetUseBottomFromBottom ctrl 0)
              (dcl_Control_SetLeft ctrl (fix x1))
              (dcl_Control_SetTop ctrl (fix y1))
              (dcl_Control_SetWidth  ctrl (fix wi))
              (dcl_Control_SetHeight ctrl (fix hi))
             ; (dcl_Control_SetPos ctrl (fix x1) (fix y1) (fix wi) (fix hi))

             (setq x1 (+ x1 bd wi)
                       ctr (1+ ctr)
              )
           )
          (setq j (1+ j))
     )
)
(dcl_project_load (strcat ARCTDRVESP "\\iconmenu.odcl"))

(defun c:iconmenu_OnInitialize (/ sld slb ctr)
(resize_reposition_slides)
(setq ctr 0)
(repeat (* 2 ICONCOLS)
    (setq sld (get_slide ctr)
              slb (strcat ARCTDRVEPREF "Slides\\" (get_slide_lib ctr) ".slb")
     )
    (if (and (zeros sld) (zeros slb))
         (dcl_slideview_load (eval (read (strcat "SlideView" (itoa ctr)))) slb sld)
    )
   ;(eval (read (strcat "(defun c:SlideView" (itoa ctr)"_OnRightClick (/)(princ "  (itoa ctr) "))")))
   (setq ctr (1+ ctr))
)

)
;(setq ctr 0);
;(repeat 20
;(eval (read (strcat "(defun c:SlideView" (itoa ctr)"_OnRightClick (/)(princ "  (itoa ctr) "))")))
;   (setq ctr (1+ ctr))
;)
(defun c:SlideView0_OnDblClicked (/)
  (get_iconmenu_cmds  0) (dcl_Form_Close  iconmenu)
)
(defun c:SlideView1_OnDblClicked (/)
  (get_iconmenu_cmds  1) (dcl_Form_Close  iconmenu)
)
(defun c:SlideView2_OnDblClicked (/)
  (get_iconmenu_cmds  2) (dcl_Form_Close  iconmenu)
)
(defun c:SlideView3_OnDblClicked (/)
  (get_iconmenu_cmds  3) (dcl_Form_Close  iconmenu)
)
(defun c:SlideView4_OnDblClicked (/)
  (get_iconmenu_cmds  4) (dcl_Form_Close  iconmenu)
)
(defun c:SlideView5_OnDblClicked (/)
  (get_iconmenu_cmds  5) (dcl_Form_Close  iconmenu)
)
(defun c:SlideView6_OnDblClicked (/)
  (get_iconmenu_cmds  6) (dcl_Form_Close  iconmenu)
)
(defun c:SlideView7_OnDblClicked (/)
  (get_iconmenu_cmds  7) (dcl_Form_Close  iconmenu)
)
(defun c:SlideView8_OnDblClicked (/)
  (get_iconmenu_cmds  8) (dcl_Form_Close  iconmenu)
)
(defun c:SlideView9_OnDblClicked (/)
  (get_iconmenu_cmds  9) (dcl_Form_Close  iconmenu)
)

(defun c:SlideView0_OnClicked (/)
  (get_iconmenu_cmds  0)
)
(defun c:SlideView1_OnClicked (/)
  (get_iconmenu_cmds  1)
)
(defun c:SlideView2_OnClicked (/)
  (get_iconmenu_cmds  2)
)
(defun c:SlideView3_OnClicked (/)
  (get_iconmenu_cmds  3)
)
(defun c:SlideView4_OnClicked (/)
  (get_iconmenu_cmds  4)
)
(defun c:SlideView5_OnClicked (/)
  (get_iconmenu_cmds  5)
)
(defun c:SlideView6_OnClicked (/)
  (get_iconmenu_cmds  6)
)
(defun c:SlideView7_OnClicked (/)
  (get_iconmenu_cmds  7)
)
(defun c:SlideView8_OnClicked (/)
  (get_iconmenu_cmds  8)
)
(defun c:SlideView9_OnClicked (/)
  (get_iconmenu_cmds  9)
)
(defun c:iconmenu_OnClose (UpperLeftX UpperLeftY /)
   (dcl_Form_Close iconmenu)
)


(defun c:SlideView0_OnRightClick (/)
  (dcl_MessageBox "To Do: code must be added to event handler\r\nc:SlideView9_OnRightClick" "To do")
)
(defun c:SlideView1_OnRightClick (/)
  (dcl_MessageBox "To Do: code must be added to event handler\r\nc:SlideView9_OnRightClick" "To do")
)
(defun c:SlideView2_OnRightClick (/)
  (dcl_MessageBox "To Do: code must be added to event handler\r\nc:SlideView9_OnRightClick" "To do")
)
(defun c:SlideView3_OnRightClick (/)
  (dcl_MessageBox "To Do: code must be added to event handler\r\nc:SlideView9_OnRightClick" "To do")
)
(defun c:SlideView4_OnRightClick (/)
  (dcl_MessageBox "To Do: code must be added to event handler\r\nc:SlideView9_OnRightClick" "To do")
)
(defun c:SlideView5_OnRightClick (/)
  (dcl_MessageBox "To Do: code must be added to event handler\r\nc:SlideView9_OnRightClick" "To do")
)
(defun c:SlideView6_OnRightClick (/)
  (dcl_MessageBox "To Do: code must be added to event handler\r\nc:SlideView9_OnRightClick" "To do")
)
(defun c:SlideView7_OnRightClick (/)
  (dcl_MessageBox "To Do: code must be added to event handler\r\nc:SlideView9_OnRightClick" "To do")
)
(defun c:SlideView8_OnRightClick (/)
  (dcl_MessageBox "To Do: code must be added to event handler\r\nc:SlideView9_OnRightClick" "To do")
)
(defun c:SlideView9_OnRightClick (/)
  (dcl_MessageBox "To Do: code must be added to event handler\r\nc:SlideView9_OnRightClick" "To do")
)

(defun c:SlideView10_OnRightClick (/)
  (dcl_MessageBox "To Do: code must be added to event handler\r\nc:SlideView9_OnRightClick" "To do")
)
(defun c:SlideView11_OnRightClick (/)
  (dcl_MessageBox "To Do: code must be added to event handler\r\nc:SlideView9_OnRightClick" "To do")
)
(defun c:SlideView12_OnRightClick (/)
  (dcl_MessageBox "To Do: code must be added to event handler\r\nc:SlideView9_OnRightClick" "To do")
)
(defun c:SlideView13_OnRightClick (/)
  (dcl_MessageBox "To Do: code must be added to event handler\r\nc:SlideView9_OnRightClick" "To do")
)
(defun c:SlideView14_OnRightClick (/)
  (dcl_MessageBox "To Do: code must be added to event handler\r\nc:SlideView9_OnRightClick" "To do")
)
(defun c:SlideView15_OnRightClick (/)
  (dcl_MessageBox "To Do: code must be added to event handler\r\nc:SlideView9_OnRightClick" "To do")
)
(defun c:SlideView16_OnRightClick (/)
  (dcl_MessageBox "To Do: code must be added to event handler\r\nc:SlideView9_OnRightClick" "To do")
)
(defun c:SlideView17_OnRightClick (/)
  (dcl_MessageBox "To Do: code must be added to event handler\r\nc:SlideView9_OnRightClick" "To do")
)
(defun c:SlideView18_OnRightClick (/)
  (dcl_MessageBox "To Do: code must be added to event handler\r\nc:SlideView9_OnRightClick" "To do")
)
(defun c:SlideView19_OnRightClick (/)
  (dcl_MessageBox "To Do: code must be added to event handler\r\nc:SlideView9_OnRightClick" "To do")
)
(dcl_Form_Show iconmenu)
)


I modified your post by placing the CODE tags around your code, to remove the random happy faces. - BazzaCAD, Barry

owenwengerd

Can you email a zip with all the files I need to reproduce the crash? I'd like to get it fixed before we officially release OpenDCL 5.
mailto:owenw@manusoft.com
Owen Wengerd (Outside The Box) / ManuSoft

BazzaCAD

Wow looks like some cool code. I'd love to see you ODCL project file too.
Are you converting an old ObjectDCL file, or starting from scratch?
a.k.a.
Barry Ralphs
barryDOTralphsATgmailDOTcom

The Dark Princess

Hey, thanks for the quick replies. I'm at hoe today and have things to attend to so i won't be doing much coding.  When adesk introduced the cui I realised that I would have more sissues with our huge block library so i decided to write my own version of the slide menu system in lisp and dcl.  this way I wouldn;t have to rewrite the huge .mnu file with 2900+ blocks.  I ended up with basically what I wanted - a 4 row x 10 slide system with paging (infinite loop paging) a back button etc and all the functionality. I aded the ability to change the number of rows, columns and image size on the fly by simply rewriting the dcl code.  Now in an attempt to learn odcl I'm trying to reproduce this dialog in odcl. So much of the code is dealing with parsing the instructions within my version of the .mnu file.  I also have a dcl which allows me to add blocks, move them around, batch generate slides and update any of the slide menus.

Pretty fun project and it all works flawlessly.  I'd like to have the resizing thing in a more classic way.

owenwengerd

I took a look at the files you emailed, but the lisp appears to be corrupted. I tried to clean it up, and finally got it loading without error, but it still crashes as soon as I run it. Can you have another look and see if you can send it again?
Owen Wengerd (Outside The Box) / ManuSoft

The Dark Princess

Owen,


I need to rework it and get all the library funcs and variables set for you.  Would you email the stuff to my home address?

jamieduncan@velcom.ca

Thanks

TDP

owenwengerd

I scrapped the code and just loaded each slide into a slideview manually. Sure enough, one of them caused AutoCAD to crash. I found and fixed a buffer overrun bug that was triggered by that slide, now they all display without any errors. Hopefully that was the only bug.
Owen Wengerd (Outside The Box) / ManuSoft

The Dark Princess

owen

that's great.  I suppose I have to wait for that bug to be fixed?


Jamie

owenwengerd

Yes, but not long. I'll upload RC3 later today.
Owen Wengerd (Outside The Box) / ManuSoft

The Dark Princess

Thnx Owen

I have a couple of much lkarger slides - do you want to test the buffer overrun with them?

TDP

owenwengerd

The buffer overrun I found is fixed, but of course there could be more bugs elsewhere in the code. Please test your slides on RC4 and let me know if you encounter any problems. If you do, I'll have a look.
Owen Wengerd (Outside The Box) / ManuSoft

The Dark Princess