Populate listbox with drawing names

Discussion in 'AutoCAD' started by Matt W, Oct 15, 2004.

  1. Matt W

    Matt W Guest

    How can I populate a listbox (in a DCL dialog box) with the drawing names
    from a directory?
    I'm assuming this will involve VLISP which I know little-to-nothing about.

    Thanks in advance!
     
    Matt W, Oct 15, 2004
    #1
  2. Matt W

    Rudy Tovar Guest

    I'm just curious as to what you know... assuming that you'll be developing
    this utility or don't know assuming that someone can do it for you.

    This is not an attack against you, but it would help to know how much more
    you know...

    There are several things to consider...

    1. What's it for...?
    2. What you have started...?

    (start_list "list1" 3)
    (mapcar 'add_list <listing>)
    (end_list)

    The 3 in the 'start_list' represents the action that will be performed every
    time the list is populated, 'clear', 'append', 'reconstruct', etc.

    There is a (vl-directory-files [directory pattern directories]) function
    that will return the files by following the example out-lined.
    (vl-directory-files "c:/acadwin" "acad*.exe")("ACAD.EXE" "ACADAPP.EXE"
    "ACADL.EXE" "ACADPS.EXE")(vl-directory-files "e:/acadwin" nil -1)("." ".."
    "SUPPORT" "SAMPLE" "ADS" "FONTS" "IGESFONT" "SOURCE"
    "ASE")(vl-directory-files "E:/acad13c4" nil -1)("." ".." "WIN" "COM"
    "DOS")Just remember that you'll still need to select the directory...

    Some have used an example as such...

    (setq di (getfiled "\nEnter" "Select Project Directory" "" 1))

    (if di
    (progn
    (setq cn (strlen di)
    cn (- cn 24)
    di (substr di 1 cn)
    )

    In this case DI contains the directory name.
     
    Rudy Tovar, Oct 15, 2004
    #2
  3. Matt W

    T.Willey Guest

    First select a directory. I got this routine from Tony T. here.
    (defun DIRECTORY-DIA ( / sh folder parentfolder folderobject result)
    ;By Tony Tanzillo
    ;Modified by Tim Willey
    (vl-load-com)
    (setq sh
    (vla-getInterfaceObject
    (vlax-get-acad-object)
    "Shell.Application"
    )
    )

    (setq folder
    (vlax-invoke-method
    sh
    'BrowseForFolder
    0
    ""
    0
    )
    )
    (vlax-release-object sh)

    (if folder
    (progn
    (setq parentfolder
    (vlax-get-property folder 'ParentFolder)
    )
    (setq FolderObject
    (vlax-invoke-method
    ParentFolder
    'ParseName
    (vlax-get-property Folder 'Self)
    )
    )
    (setq result
    (vlax-get-property FolderObject 'Path)
    )
    (mapcar 'vlax-release-object
    (list folder parentfolder folderobject)
    )
    (setq result (strcat result "\\"))
    )
    )
    )

    Then you can grab all the dwg files from there to a list with:
    (setq dlist (vl-directory-files (directory-dia) "*.dwg"))
    Then you just add it to you dialog list box:
    (start_list "tx2" 3); clear the list, where tx2 is the key of your list box
    (mapcar 'add_list dlist)
    (end_list)

    Hope this helps.
    Tim
     
    T.Willey, Oct 15, 2004
    #3
  4. Matt W

    Matt W Guest

    I know how to fill a listbox with a predefined list
    I.E.
    (setq BlockList (list "2-Way Control Valve" "Anchor" "Ball Valve"
    "Companion Flange" "RiseDrop" "Bow Tie Valve"))
    (start_list "lstValves")
    (mapcar 'add_list BlockList)

    What I *don't* know is how to grab a directory and fill a listbox with that
    directory's files.
    It looks like (vl-directory-files... will do the trick (figured it would
    take some VLISP to accomplish).

    Thanks!

    --
    I support two teams: the Red Sox and whoever beats the Yankees.


    | I'm just curious as to what you know... assuming that you'll be developing
    | this utility or don't know assuming that someone can do it for you.
    |
    | This is not an attack against you, but it would help to know how much more
    | you know...
    |
    | There are several things to consider...
    |
    | 1. What's it for...?
    | 2. What you have started...?
    |
    | (start_list "list1" 3)
    | (mapcar 'add_list <listing>)
    | (end_list)
    |
    | The 3 in the 'start_list' represents the action that will be performed
    every
    | time the list is populated, 'clear', 'append', 'reconstruct', etc.
    |
    | There is a (vl-directory-files [directory pattern directories]) function
    | that will return the files by following the example out-lined.
    | (vl-directory-files "c:/acadwin" "acad*.exe")("ACAD.EXE" "ACADAPP.EXE"
    | "ACADL.EXE" "ACADPS.EXE")(vl-directory-files "e:/acadwin" nil -1)("." ".."
    | "SUPPORT" "SAMPLE" "ADS" "FONTS" "IGESFONT" "SOURCE"
    | "ASE")(vl-directory-files "E:/acad13c4" nil -1)("." ".." "WIN" "COM"
    | "DOS")Just remember that you'll still need to select the directory...
    |
    | Some have used an example as such...
    |
    | (setq di (getfiled "\nEnter" "Select Project Directory" "" 1))
    |
    | (if di
    | (progn
    | (setq cn (strlen di)
    | cn (- cn 24)
    | di (substr di 1 cn)
    | )
    |
    | In this case DI contains the directory name.
    | --
    | MASi
    | Copyright 2004 by Cadentity
    | www.Cadentity.com
    |
    |
    |
    | | > How can I populate a listbox (in a DCL dialog box) with the drawing
    names
    | > from a directory?
    | > I'm assuming this will involve VLISP which I know little-to-nothing
    about.
    | >
    | > Thanks in advance!
    | >
    | > --
    | > I support two teams: the Red Sox and whoever beats the Yankees.
    | >
    | >
    | >
    |
    |
     
    Matt W, Oct 15, 2004
    #4
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.