Help! Help!!!

Discussion in 'AutoCAD' started by LLily, Feb 23, 2005.

  1. LLily

    LLily Guest

    Hello everybody,

    I am a pretty new for AutoCAD. My leader gave me a task to find out all drawing files stored in a win2000 folder. I should get all drawings' filename and their path, and any attached tiffs and path.

    What kind of environment should I set up on my PC? How can I get start it?

    Your any help will be great appreciated.

    Thanks in advance!
     
    LLily, Feb 23, 2005
    #1
  2. LLily

    Norman Yuan Guest

    Find dwg file? The easiest way would be to fire up Windows Explorer and go
    that folder. You probably meant how to do this programmatically with VBSA
    code. Check out Dir() in VB/VBA. No special "environment" is required. Start
    AutoCAD, enter "VBAIDE" in command line. Then use Object Brower/VBA Help to
    learn more about Dir() and other related topic. Following is copied directly
    from Acad VBA Help:

    Dim MyFile, MyPath, MyName
    ' Returns "WIN.INI" (on Microsoft Windows) if it exists.
    MyFile = Dir("C:\WINDOWS\WIN.INI")

    ' Returns filename with specified extension. If more than one *.ini
    ' file exists, the first file found is returned.
    MyFile = Dir("C:\WINDOWS\*.INI")

    ' Call Dir again without arguments to return the next *.INI file in the
    ' same directory.
    MyFile = Dir

    ' Return first *.TXT file with a set hidden attribute.
    MyFile = Dir("*.TXT", vbHidden)

    ' Display the names in C:\ that represent directories.
    MyPath = "c:\" ' Set the path.
    MyName = Dir(MyPath, vbDirectory) ' Retrieve the first entry.
    Do While MyName <> "" ' Start the loop.
    ' Ignore the current directory and the encompassing directory.
    If MyName <> "." And MyName <> ".." Then
    ' Use bitwise comparison to make sure MyName is a directory.
    If (GetAttr(MyPath & MyName) And vbDirectory) = vbDirectory Then
    Debug.Print MyName ' Display entry only if it
    End If ' it represents a directory.
    End If
    MyName = Dir ' Get next entry.
    Loop
    drawing files stored in a win2000 folder. I should get all drawings'
    filename and their path, and any attached tiffs and path.
     
    Norman Yuan, Feb 23, 2005
    #2
  3. LLily

    Oberer Guest

    you could do it via vba, or an old dos method.

    if you need to process one dir (and it's sub dirs) you could always: (long dos approach)
    dir *.dwg /s >YOURTEXTFILENAME.TXT
    This gets all dwg's in this dir & sub dirs and puts it into a text file. you'd then have to open the text file in excel and sort it.

    You could do a search in windows and take screen shots of the results.

    finally you could use a little vba

    this code is close to what you're after as well

    Code:
    Sub FIX_ALIGNMENT_FILES()
    
    Dim MyPath As String
    Dim MyName As String
    
    Dim NEW_Dir As String
    
    NEW_Dir = "ST-JASMINE DR"
    ' Display the names in C:\ that represent directories.
    
    MyPath = "\\Nt2\engineering\LD Projects\Windbrooke\align\" & NEW_Dir & "\"   ' Set the path.
    MyName = Dir(MyPath, vbDirectory)    ' Retrieve the first entry.
    Do While MyName <> ""    ' Start the loop.
    ' Ignore the current directory and the encompassing directory.
    If MyName <> "." And MyName <> ".." Then
    ' Use bitwise comparison to make sure MyName is a directory.
    Debug.Print MyName
    If (GetAttr(MyPath & MyName) And vbDirectory) <> vbDirectory Then
    Debug.Print MyPath & MyName & MyPath & NEW_Dir & Right(MyName, 4)
    'FileCopy MyPath & MyName, MyPath & NEW_Dir & Right(MyName, 4)
    Debug.Print "CREATED: " & MyPath & NEW_Dir & Right(MyName, 4)
    'If Dir(MyPath & "TEST" & Right(MyName, 4), vbNormal) > 0 Then
    ' Kill MyPath & MyName
    Debug.Print "DELETED: " & MyPath & MyName
    'End If
    Debug.Print MyName    ' Display entry only if it
    
    End If    ' it represents a directory.
    End If
    MyName = Dir    ' Get next entry.
    Loop
    
    End Sub
    
     
    Oberer, Feb 23, 2005
    #3
  4. LLily

    LLily Guest

    Thanks all for your help. In my case, some AutoCAD files were linked to tiff files using function within AutoCAD application. One drawing is actually made up of 2 linked files-"filename.dwg" and a "somename.tiff". Also, some files may be tiff only. Is there a way to find out which of the .dwg files have a link to a tiff file, then list the .dwg and .tiff filename and their path?

    Thanks,
     
    LLily, Feb 24, 2005
    #4
  5. LLily

    Norman Yuan Guest

    Browsing a folder, with your eye or with code, you can only know what type
    of files are in or how many files are in, but you cannot tell if a file
    (*.tiff, or other image files) is linked in a *dwg file. You need actually
    open the *.dwg file in AutoCAD to examine it, with your eyes, or with code.
    If you have lot of file in particular folder (may be also include all
    subfolders) and you want to know how many dwg files and how many *.tiff (or
    other image) files, and which *.tiff file is buried in which *.dwg file, I'd
    imagine you could write a VBA program, which navigate through a given folder
    (including all subfolders, if necessary) to get lists of all *.dwg files and
    *.tiff file (this could be done just a few second with thousands of file in
    a folder); and then the VBA program will have to open each *.dwg file to
    examine whether there is a *.tiff buried in it or not, if yes, what the file
    name is. It process could take some time, depending how big the file is and
    how fast the computer is.

    Coding such a VBA program isn't a difficult thing. Besides the sample code
    for loop through a folder in my previous reply, you only need to add some
    code the open/close dwg file in AutoCAD, and search the drawing for
    AcadRasterImage object. Once found, its ImageFile property tells you what
    the *.tiff file name is.

    tiff files using function within AutoCAD application. One drawing is
    actually made up of 2 linked files-"filename.dwg" and a "somename.tiff".
    Also, some files may be tiff only. Is there a way to find out which of the
    ..dwg files have a link to a tiff file, then list the .dwg and .tiff filename
    and their path?
     
    Norman Yuan, Feb 24, 2005
    #5
  6. Hi,

    It is quite likely that an attached Tiff file actually has the file name
    (and path) stored as text in the drawing file.

    You may be able to use a Windows search for file "*.dwg" containing the text
    ".TIF". After finding those files you could create more sophisticated code
    to get the full file name, or as a minimum know which files to open.

    --


    Laurie Comerford
    CADApps
    www.cadapps.com.au


    tiff files using function within AutoCAD application. One drawing is
    actually made up of 2 linked files-"filename.dwg" and a "somename.tiff".
    Also, some files may be tiff only. Is there a way to find out which of the
    ..dwg files have a link to a tiff file, then list the .dwg and .tiff filename
    and their path?
     
    Laurie Comerford, Feb 24, 2005
    #6
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.