splitpath

Discussion in 'AutoCAD' started by Marcel Janmaat, Oct 1, 2004.

  1. Does anyone know of the existance of a command to split the path of a
    path+filename.

    I have for example;

    "H:\\HE\\0000\\0001\\VO\\BK\\0001_VO-BK-002.dwg"

    And want;

    "H:\\HE\\0000\\0001\\VO\\BK\\"

    and

    "0001_VO-BK-002.dwg"

    ofcourse strlen varies!

    MJ
     
    Marcel Janmaat, Oct 1, 2004
    #1
  2. Marcel Janmaat

    dblaha Guest

    To get just the path:
    (GETVAR "DWGPREFIX")

    To get just the filename:
    (GETVAR "DWGNAME")



    Dave
     
    dblaha, Oct 1, 2004
    #2
  3. That I know.

    But i'ts not what i mean. I obtained the path a different way.

    I explicitly need to split the path in the textstring.

    M
     
    Marcel Janmaat, Oct 1, 2004
    #3
  4. Marcel Janmaat

    Dale Fugier Guest

    Dale Fugier, Oct 1, 2004
    #4
  5. Marcel Janmaat

    dblaha Guest

    Oh. Well in that case, do a VL-STRING-SEARCH for the \\ until you can't find any more and then grab the rest of the string from that point with a SUBSTR.


    Dave
     
    dblaha, Oct 1, 2004
    #5
  6. I knew there was something like this. Just wasn't looking at the right
    place.
    Thanx!
     
    Marcel Janmaat, Oct 1, 2004
    #6
  7. Marcel Janmaat

    dblaha Guest

    Like this:

    (defun path-split (path)
    (setq temp_path path
    final_pos 1
    )
    (while (setq pos (vl-string-search "\\" temp_path))
    (setq temp_path (substr temp_path (+ pos 2)))
    (setq final_pos (+ final_pos (+ pos 1)))
    )
    (setq the_name (substr path final_pos))
    (setq the_path (substr path 1 (- (strlen path)(strlen the_name))))
    )



    Dave
     
    dblaha, Oct 1, 2004
    #7
  8. Marcel Janmaat

    Jim Claypool Guest

    (defun splitpath (filespec)
    (setq
    filepath (strcat (vl-filename-directory filespec) "\\")
    filename (strcat (vl-filename-base filespec) (vl-filename-extension
    filespec))
    )
    (princ (strcat "\nFile Path = " filepath "\nFilename = " filename))
    (princ)
    )
     
    Jim Claypool, Oct 1, 2004
    #8
  9. Marcel Janmaat

    hendie Guest

    why not use the built in function FNSPLITL ~ (fnsplitl (getvar "dwgname")) ~ why make things complicated ?




    www.resourcecad.com
     
    hendie, Oct 4, 2004
    #9
  10. I agree!
    This one is just as usefull, only doesn't split the drivemapping.
    Dos_splitpath does.
     
    Marcel Janmaat, Oct 11, 2004
    #10
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.
Similar Threads
There are no similar threads yet.
Loading...