Trim drawing name from string.

Discussion in 'AutoCAD' started by Casey Roberts, Oct 28, 2004.

  1. I have a string that includes the full path of a drawing, (including drawing
    name) and want to trim just the drawing name.

    For example,

    My string may be "c:\\drawingdirectory\\HOUSE.dwg"
    and I want to get the value "HOUSE"

    What's the easiest method to accomplish this?
     
    Casey Roberts, Oct 28, 2004
    #1
  2. Casey Roberts

    T.Willey Guest

    How are you getting that string? If you are getting it from the drawing you are in, then you can just do:
    (setq Dname (getvar "dwgname"))
    (setq Dname (substr Dname 1 (- (strlen Dname) 4)))

    If it is just a string that you have from nowhere, then maybe something like:
    (while (setq Temp (vl-string-search Dname "\\"))
    (setq LastSlash Temp1)
    )
    (setq Dname (substr Dname (1+ LastSlash) (- (strlen Dname) 4)))

    Hope that helps.
    Tim
     
    T.Willey, Oct 28, 2004
    #2
  3. Thanks,

    that works great.

     
    Casey Roberts, Oct 28, 2004
    #3
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.