filtering variable text

Discussion in 'AutoCAD' started by mnash, Jan 11, 2005.

  1. mnash

    mnash Guest

    In one drawing a certain variable is so many characters long say 7, and in another drawing the same type of variable is 9 characters long. How do I make the variable in both cases to get from 1234567 to 123 in the first drawing and 12345 in the second drawing. Eseentially the last four characters in the variable are useless for me. The variable I'm referring to is the filename and I want to get rid of the ".dwg" at the end.
    thanks
     
    mnash, Jan 11, 2005
    #1
  2. (vl-filename-base "abc.dwg")
    "abc"

    (vl-filename-base "abc.dwaasdasdg")
    "abc"

    --
    Autodesk Discussion Group Facilitator



    another drawing the same type of variable is 9 characters long. How do I
    make the variable in both cases to get from 1234567 to 123 in the first
    drawing and 12345 in the second drawing. Eseentially the last four
    characters in the variable are useless for me. The variable I'm referring
    to is the filename and I want to get rid of the ".dwg" at the end.
     
    Jason Piercey, Jan 11, 2005
    #2
  3. Or,

    (setq howlong (strlen (getvar "dwgname")))
    (setq dwgnameonly (substr (getvar "dwgname") 1 (- howlong 4)))

    "dwgnameonly" will be what you're looking for. The same approach will give
    you back any text string with four characters removed from the end, in case
    you need such a thing for anything other than the drawing name (which is the
    only situation Jason's will work in).
     
    Kent Cooper, AIA, Jan 11, 2005
    #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.