"Findfile" from AcadX.com

Discussion in 'AutoCAD' started by Jeff Mishler, Dec 19, 2003.

  1. Jeff Mishler

    Jeff Mishler Guest

    I have used this in a routine that lists xrefs and the "found at" path,
    similar to the Xref manager in Acad. The problem I've come up against is
    that if the search path is too long, it errors out. I know for a fact
    that the variables get set properly and that the drawing does exist in
    the paths provided, yet findfile doesn't find it, while it does find 2
    other xrefs in different paths. Is there a max length that SearchPathA
    in kernel32.dll can handle?

    Any help or ideas on this would be greatly appreciated.

    Jeff
     
    Jeff Mishler, Dec 19, 2003
    #1
  2. 256 characters.

    --
    There are 10 kinds of people. Those who understand binary and those who
    don't.

    http://code.acadx.com
    (Pull the pin to reply)
     
    Frank Oquendo, Dec 19, 2003
    #2
  3. Jeff Mishler

    Jeff Mishler Guest

    Hmm, now I'm scrathing my head a little more. In the following cut/paste
    from the immediate window, findfile finds the file in the first 2
    instances and fails on the third.
    ? len(spath)
    337
    ? len(spath)
    339
    ? len(spath)
    359

    I am setting the values for each path based on 1., the saved xref path,
    2., the drawing path, 3., the ACAD support path. Here is the portion of
    code to get the paths to search in and the xref drawing name:

    supPath = ThisDrawing.Application.Path
    supPath = supPath & ";" &
    ThisDrawing.Application.Preferences.Files.SupportPath
    supPath = ThisDrawing.Path & ";" & supPath
    strName = objXref.Path
    strPath = strName
    varPath = Split(strPath, "\")
    strName = varPath(UBound(varPath)) 'Last element of Split
    strPath = Left(strPath, Len(strPath) - Len(strName)) 'Remove dwg
    name
    strPaths(intCnt, 0) = objXref.name 'Name in drawing
    strPaths(intCnt, 2) = FindFile(strName, strPath & ";" & supPath)
    'Found at path

    The strPath for the 3 xrefs (first 2 work, the last doesn't) are:
    "L:\2003\23107 Meadow Park IP\dwg\meadowlark3\"
    "\Land Projects 3\2003\23107 Meadow Park IP\dwg\"
    "\Land Projects 3\2003\23107 Meadow Park IP\dwg\Applewood\apple\dwg\"

    FWIW, the strPaths(X, 1) element gets set later and only contains text
    as to whether the xref is loaded or unloaded.

    Any ideas on how I can get this to continue properly?

    Thanks,
    Jeff
     
    Jeff Mishler, Dec 19, 2003
    #3
  4. Jeff Mishler

    Jeff Mishler Guest

    OK, now I've figured it out......I think.
    Using (findfile "blah") at the command line doesn't find it either. So
    my guess is that ACAD adds the drive to search, if it doesn't exist, to
    the xref's stored path.
    After adding the following lines it now works....

    If InStr(1, strPath, ":") = 0 Then
    strPath = Left(ThisDrawing.Path, 2) & strPath
    End If

    Thanks for looking at it.

    Jeff
     
    Jeff Mishler, Dec 19, 2003
    #4
  5. What you found is that the technique that you
    were led to believe is a functional counterpart
    to AutoLISP's (findfile) function, is not.

    If you read the description for (findfile), you'll
    see that it involves more than just searching the
    static paths listed in the ACAD enviornment variable.

    What you need to be careful with is the active
    document in an MDI scenario. Because (Findfile)
    is document dependent, the active document's
    path is included in the search, so that means
    the result can vary depending on which of several
    open documents are active.
     
    Tony Tanzillo, Dec 20, 2003
    #5
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.