DCL help

Discussion in 'AutoCAD' started by fletch97, Feb 22, 2005.

  1. fletch97

    fletch97 Guest

    Afternoon -

    Trying to write a dcl and lisp routine to allow for easy insertion of blocks. Having trouble trying to figure out how to write within the lisp routine to use start_list and have the box list blocks right from windows explorer?? Is that possible? Same goes for the image box......please see below, I posted both lsp and dcl files.

    test : dialog {
    label = "Door Dialog";
    : row {
    : column {
    : list_box {
    key = "style_list";
    width = 16;
    height = 8;
    allow_accept = true;
    }
    : column {
    : image {
    key = "style_image";
    height = 7;
    width = 20;
    }
    }
    }
    }
    ok_cancel_err;
    }


    (defun c:test (/ dcl_id)
    (setq DCL_ID (load_dialog "l:/tsa-custom/dcl/test.dcl"))
    (if (not (new_dialog "test" DCL_ID)) (exit))
    (start_dialog)
    (unload_dialog DCL_ID)
    (princ)
    )
     
    fletch97, Feb 22, 2005
    #1
  2. fletch97

    BillZ Guest

    Try this:
    Code:
    (defun c:test (/ dcl_id)
    (setq DCL_ID (load_dialog "test.dcl"))
    (if (not (new_dialog "test" DCL_ID)) (exit))
    (setq BlockList (vl-directory-files "C:/Program Files/AutoCAD 2005/Sample" "*.dwg" 1)
    )
    (start_list "style_list")
    (mapcar 'Add_list BlockList)
    (end_list)
    (slide_image 0 0 (dimx_tile "style_image")(dimy_tile "style_image") "slidefilename")
    (start_dialog)
    (unload_dialog DCL_ID)
    (princ)
    )
    Bill
     
    BillZ, Feb 22, 2005
    #2
  3. fletch97

    fletch97 Guest

    Bill -

    Thanks for the help however I got the following error while using your version......; error: quit / exit abort? Any ideas, the code looks good to me but I am not that good with dcl?

    Thanks again!
     
    fletch97, Feb 22, 2005
    #3
  4. fletch97

    BillZ Guest

    Yeah,
    Add the path back in the load dialog function or add the folder that holds the dialog file into the seacrch path.

    Bill
     
    BillZ, Feb 22, 2005
    #4
  5. fletch97

    fletch97 Guest

    Bill -

    Great....that worked...thanks!

    Now how do I get the drawings that are listed to display a preview image? And how do I have the user actually chose the block and insert it in? (Should I create an insert button or is there an easier way?)

    Bill, I owe you a beer for all your help, thanks man!!

    Steve
     
    fletch97, Feb 22, 2005
    #5
  6. fletch97

    BillZ Guest

    You would need a list of slides to display an image using DCL.
    Make a slide for each block in your file and list the names in your lisp.

    This would be a bare bones approach to what you are asking.

    Code:
    (defun set_list (val)
    (setq BlkNam (get_tile "style_list")
    BlkNam (nth (atoi BlkNam) BlockList)
    SldNam (nth (atoi BlkNam) SlideList)
    )
    (start_image "style_image")
    (fill_image 0 0 (dimx_tile "style_image")(dimy_tile "style_image") -15)
    (slide_image 0 0 (dimx_tile "style_image")(dimy_tile "style_image") SldNam)
    (end_image)
    )
    
    
    
    (defun c:test (/ dcl_id)
    (vl-load-com)
    (setq DCL_ID (load_dialog "l:/tsa-custom/dcl/test.dcl"))
    (if (not (new_dialog "test" DCL_ID)) (exit))
    
    (setq BlockList (vl-directory-files "C:/Program Files/AutoCAD 2005/Sample" "*.dwg" 1)
    )
    (setq SlideList (list "slide1" "slide2" "slide3" "slide4" "slide5" "slide6" "slide7") ;must be same number of slides as files.
    )
    
    (start_list "style_list")
    (mapcar 'Add_list BlockList)
    (end_list)
    
    (action_tile "style_list" "(set_list $value)")
    (action_tile "accept" "(done_dialog 1)")
    
    (setq an (start_dialog))
    (unload_dialog DCL_ID)
    
    (cond  ((= an 1)
    (vl-cmdf "insert" (strcat "C:/Program Files/AutoCAD 2005/Sample/" BlkNam)(getpoint "\nPick Point:") "" "" "")
    )
    )
    (princ)
    )
    Bill
     
    BillZ, Feb 22, 2005
    #6
  7. fletch97

    BillZ Guest

    This would be what I intended to do for the set_list function:

    Code:
    (defun set_list (val)
    (setq BlkNam (nth (atoi val) BlockList)
    SldNam (nth (atoi val) SlideList)
    )
    (start_image "style_image")
    (fill_image 0 0 (dimx_tile "style_image")(dimy_tile "style_image") -15)
    (slide_image 0 0 (dimx_tile "style_image")(dimy_tile "style_image") SldNam)
    (end_image)
    )

    Bill
     
    BillZ, Feb 22, 2005
    #7
  8. fletch97

    fletch97 Guest

    Bill -

    Last question....

    After creating the slides, where shoudl I place them to be reconized? Do I need to include a path within the lisp?
     
    fletch97, Feb 22, 2005
    #8
  9. fletch97

    BillZ Guest

    Put them in a folder and put the folder in the search path.

    Then you can make your list something like this.

    (setq SlideList (vl-directory-files "g:/autolisp/lisp slides/" "*.sld" 1))

    If the folder isn't in the search path, the path must be included in the string for slide_image.

    Bill
     
    BillZ, Feb 22, 2005
    #9
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.