Author Topic: Problem with spaces in script file  (Read 9041 times)

0 Members and 1 Guest are viewing this topic.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Problem with spaces in script file
« Reply #30 on: December 06, 2015, 05:37:25 AM »
The new one is already open because of the saveas.

Delete the original the same way you did previously if you really want to.

eg
(vl-file-delete ArchiveFileName)

Personally I'd leave it in the Temp folder for a while :)


ahhh I see what you mean ... just a sec
« Last Edit: December 06, 2015, 05:41:15 AM by Kerry »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Problem with spaces in script file
« Reply #31 on: December 06, 2015, 05:53:46 AM »
Have a play now
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

danglar

  • Newt
  • Posts: 161
  • Read My Li(s)(p)
Re: Problem with spaces in script file
« Reply #32 on: December 06, 2015, 05:55:46 AM »
now it's works more efficient, but in some cases i need to reduce "wight" of cleaned file and I prefere to do it via "wblock" command. In your program I have a little problem with it because in wblock case i have an existing file and I need to overwrite it

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Problem with spaces in script file
« Reply #33 on: December 06, 2015, 06:01:56 AM »

Sounds like a Personal Problem.
I'm sure you can resolve it.

I don't see a problem.

kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

danglar

  • Newt
  • Posts: 161
  • Read My Li(s)(p)
Re: Problem with spaces in script file
« Reply #34 on: December 06, 2015, 06:04:18 AM »
thank you I'll try to find a solution

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Problem with spaces in script file
« Reply #35 on: December 06, 2015, 06:08:32 AM »
When are you wblocking ?
How are you wblocking ?
Which drawing are you wblocking ?
What is the name of the new drawing ?

I shouldn't need to ask these questions ... they should be part of your question.

.


kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

danglar

  • Newt
  • Posts: 161
  • Read My Li(s)(p)
Re: Problem with spaces in script file
« Reply #36 on: December 06, 2015, 06:37:58 AM »
you are right about the questions and time to ask it..
I need:
1. wblock from current file with new name, like you did it
2. open new file (created by wblock command)
3. close previous file
4. delete previous file

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Problem with spaces in script file
« Reply #37 on: December 06, 2015, 06:45:31 AM »

Do you want to do this ALL the time or only sometimes  ?

That is : will you need 2 functions or one ?

kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Problem with spaces in script file
« Reply #38 on: December 06, 2015, 07:01:03 AM »
I have an old memory of there being problems wblocking and re-opening a drawing .... not sure about it

Personally I'd
set layer 0
Zoom Extents
Purge 3 times
Audit with repair.
Save.

Do the above in one function.

Then run the renamer we've been playing with.

I'm off to bed.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

danglar

  • Newt
  • Posts: 161
  • Read My Li(s)(p)
Re: Problem with spaces in script file
« Reply #39 on: December 06, 2015, 07:09:44 AM »
I need to do wblocking All the times.. in my old program i did it without any problem except for spaces between words in path and name of file

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Problem with spaces in script file
« Reply #40 on: December 06, 2015, 06:51:46 PM »

This seems to work OK for me.
Please Test thoroughly.

Code - Auto/Visual Lisp: [Select]
  1. (defun c:doit (/ *error*)                              ; TODO add local variables
  2.   ;;-----------
  3.   (defun *error* (msg) (myDefault*error* msg))
  4.   ;;-----------
  5.   (vl-cmdf "_qsave")
  6.   (setq dwgprefix     (getvar "dwgprefix")
  7.         dwgname       (getvar "dwgname")
  8.         filename-base (vl-filename-base dwgname)
  9.         tempprefix    (getvar "tempprefix")
  10.         thedate       (rtos (getvar "CDATE") 2 0)
  11.   )
  12.   (setq OriginalFileName (strcat dwgprefix dwgname)
  13.         ArchiveFileName  (strcat tempprefix
  14.                                  dwgname
  15.                                  "-"
  16.                                  (rtos (* (getvar "cdate") 1000000) 2 0)
  17.                          )
  18.         newFileName      (strcat dwgprefix    "XREF-"
  19.                                  filename-base
  20.                                  "-TPZ-"      thedate
  21.                                  ".Dwg"
  22.                                 )
  23.   )
  24.   ;;--
  25.   (setq expert (getvar "expert"))
  26.   (setvar "expert" 5)
  27.   ;;---------- wblock  
  28.   (vl-cmdf "-layer" "set" "0" "")
  29.   (vl-cmdf ".ucs" "W")
  30.   (vl-cmdf "Zoom" "E")
  31.   (vl-cmdf "_Saveas" "2013" ArchiveFileName)
  32.   (setq ss (ssget "X"))
  33.   (vl-cmdf ".wblock" newFileName "" (getvar "insbase") ss "")
  34.   (setvar "expert" expert)
  35.   ;;---------- write script
  36.   (setq fn (open (strcat tempprefix "sclean.scr") "w"))
  37.   (write-line "close n" fn)
  38.     (strcat "open "
  39.             (strcat (vl-string-right-trim
  40.                       "\""
  41.                       (vl-prin1-to-string
  42.                         (vl-string-translate "\\" "/" newFileName)
  43.                       )
  44.                     )
  45.                     "\""
  46.             )
  47.     )
  48.     fn
  49.   )
  50.     (strcat
  51.       "(vl-file-delete "
  52.         "\""
  53.         (vl-prin1-to-string (vl-string-translate "\\" "/" dwgprefix))
  54.       )
  55.       filename-base
  56.       ".dwg\")"
  57.     )
  58.     fn
  59.   )
  60.   (close fn)
  61.   ;;----------
  62.   (vl-cmdf "script" (strcat tempprefix "sclean.scr"))
  63.   (princ)
  64. )
  65.  
  66.  
  67.  
  68.  
  69.  
  70. (defun myDefault*error* (msg)
  71.   (while (< 0 (getvar 'cmdactive)) (command-s nil))
  72.   (setvar 'menuecho 1)
  73.   (cond ((not msg))
  74.         ((member
  75.            (strcase msg t)
  76.            '("console break" "function cancelled" "quit / exit abort")
  77.          )
  78.          (princ "\nFunction Cancelled.")
  79.         )
  80.         ((princ (strcat "\nApplication Error: "
  81.                         (itoa (getvar 'errno))
  82.                         " :- "
  83.                         msg
  84.                 )
  85.          )
  86.          (vl-bt)
  87.         )
  88.   )
  89.   (setvar 'errno 0)
  90.   (princ)
  91. )
  92.  
  93.   (princ)
  94.  
  95.  
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

danglar

  • Newt
  • Posts: 161
  • Read My Li(s)(p)
Re: Problem with spaces in script file
« Reply #41 on: December 07, 2015, 02:04:51 AM »
As requested, i did a Test of your program thoroughly and find it's working properly!
In a same time I made the necessary changes for me.
For example I set the date in a convenient for the Europeans form and canceled backups because I have
automatical backup on my comp.
Now, I think, we have a final solution of the issue (see attached lisp)
Thank you very much for Great Help!

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Problem with spaces in script file
« Reply #42 on: December 07, 2015, 02:46:10 AM »

Good to hear.

Personally I would keep the archive copy ... unless you have a backup immediately before you wblock it and erase the original.

If something weird happens with the wblock you will need to rely on your last backup, which may not be current.

kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.