remove blanks

Discussion in 'AutoCAD' started by john m, Jun 17, 2004.

  1. john m

    john m Guest

    Hello,

    I'm sure someone must have a little routine for removing blanks from the
    drawing name.

    I have some software that uses the drawing name in a DOS Batch file

    Which chokes if there is blanks

    Its been a while since i did any lisping

    here is my attempt

    (defun dn ()
    (setq dn (getvar "dwgname") dnl (strlen dn) x dnl )
    (while (> 0 x)

    (if (= (substr dn x) " ")
    (progn
    (setq a (substr dn 1 (- x 1)))
    (setq b (substr dn (+1 x) (strlen dnl)))
    (setq dn (strcat a "_" b))
    )
    )
    (setq x (- x 1))
    )
    (princ dn)
    )

    any suggestions appreciated. obviously the above doesnt work

    thanks in advance

    jm
     
    john m, Jun 17, 2004
    #1
  2. Tony Tanzillo, Jun 17, 2004
    #2
  3. john m

    ECCAD Guest

    I suggest you get a utility to 'rename' the .dwg's.
    Check out: www.renamewiz.com
    I use it and it's great.

    Bob
     
    ECCAD, Jun 17, 2004
    #3
  4. john m

    bob.at Guest

    John

    try this one. I didnt test it but i hope its not to fare away.
    Another posipility is not to remove the blanks but to enclose the whole dwgname with parantheses. This works normally in DOS batches.

    bob.at

    (defun rem_blank ( / dn x dnl dn_new)
    (setq dn (getvar "dwgname") dnl (strlen dn) x 0)
    (setq dn_new nil)
    (while (< x dnl)
    (if (= (substr dn x 1) " ")
    (setq dn_new (strcat dn_new "_"))
    (setq dn_new (strcat dn_new (substr dn x 1)))
    )
    (setq x (1+ x))
    )
    dn_new
    )
     
    bob.at, Jun 17, 2004
    #4
  5. john m

    ECCAD Guest

    Pardon me for asking, but what's the point - trying to use Lisp to 'modify' the drawing name ? You cannot use the resultant as a 'new' drawing name - to open ? Therefore, the only thing it would be useful for is to open the drawing, make up a 'new' name, and follow up with a saveas ?
    Unless I am missing something..

    Bob
     
    ECCAD, Jun 17, 2004
    #5
  6. john m

    andywatson Guest

    Command: (setq no_spaces "take these spaces away")
    "take these spaces away"

    Command: (while (vl-string-search " " no_spaces) (setq no_spaces
    (vl-string-subst "_" " " no_spaces)))
    "take_these_spaces_away"
     
    andywatson, Jun 17, 2004
    #6
  7. john m

    john m Guest

    that is awesome
    thanks everyone
    bob the batch program copies plot files to a particular plot cue and needs
    to either rename the plot files or put quotes, etc
    all good suggestions i should have thought of

    been a long time since i did much with bat files either

    thanks again
     
    john m, Jun 17, 2004
    #7
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.