Author Topic: Problem with spaces in script file  (Read 8872 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 #15 on: December 06, 2015, 01:35:35 AM »
What is the name of your drawing ?

and what are these values ?
Code - Auto/Visual Lisp: [Select]
  1. (getvar "DWGPREFIX")
  2. (getvar "DWGNAME")
  3. (getvar "CDATE")
« Last Edit: December 06, 2015, 01:39:06 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.

danglar

  • Newt
  • Posts: 161
  • Read My Li(s)(p)
Re: Problem with spaces in script file
« Reply #16 on: December 06, 2015, 01:38:56 AM »
Drawing name is a variable. Only for example it can be "pump station.dwg" but can be something else

Kerry

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


Well what is the value of the variable ...
and these
Code - Auto/Visual Lisp: [Select]
  1. (getvar "DWGPREFIX")
  2. (getvar "DWGNAME")
  3. (getvar "CDATE")

AND

if the name is a variable, what is the actual code you are trying to evaluate ;
and the value of the variables you are using.


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 #18 on: December 06, 2015, 01:56:35 AM »
Which part isn't working ??

Just a idle query ; should the variable www have ".Dwg" appended ??




« Last Edit: December 06, 2015, 02:01:17 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.

danglar

  • Newt
  • Posts: 161
  • Read My Li(s)(p)
Re: Problem with spaces in script file
« Reply #19 on: December 06, 2015, 02:44:49 AM »
Sorry for my misunderstanding, but I checked the program and my opinion is:
Two strings not working properly:
Code - Auto/Visual Lisp: [Select]
  1. (write-line  "open " www fil1)
  2.  (write-line (strcat "(vl-file-delete " (vl-string-right-trim "\"" (vl-prin1-to-string str1)) str3 ".dwg\")") fil1)
  3.  
  4.  

see attached lisp

Kerry

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

Do us both a favor ..

reduce your code to the minimum possible that can demonstrate the issue you have.
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 #21 on: December 06, 2015, 03:11:25 AM »
I'll try...

Kerry

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

Does this work for you ??

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 #23 on: December 06, 2015, 04:01:37 AM »

Going back through your code, the first thing your could do is add some error trapping.

Perhaps try something like this

Code - Auto/Visual Lisp: [Select]
  1.  
  2. (defun myDefault*error* (msg)
  3.   (while (< 0 (getvar 'cmdactive)) (command-s nil))
  4.   (setvar 'menuecho 1)
  5.   (cond ((not msg))
  6.         ((member (strcase msg t)
  7.                  '("console break" "function cancelled" "quit / exit abort")
  8.          )
  9.          (princ "\nFunction Cancelled.")
  10.         )
  11.         ((princ (strcat "\nApplication Error: " (itoa (getvar 'errno)) " :- " msg))
  12.          (vl-bt)
  13.         )
  14.   )
  15.   (setvar 'errno 0)
  16.   (princ)
  17. )
  18.  


Code - Auto/Visual Lisp: [Select]
  1.   ;;-----------
  2.   (defun *error* (msg)
  3.     (myDefault*error* msg)
  4.   )
  5.   ;;-----------
  6.  


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 #24 on: December 06, 2015, 04:09:05 AM »
Error trapping - is a good idea!
I can add it to program.
About your previous replay..
It's took for me some time but I check it according to your notes and didn't find any errors if I use certain file name and path instead variables.
It seem to me very complicated and I don't now how to find a solution

Kerry

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

I'll ask the obvious question :
Why are you using a Script file to delete the previous file ?
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 #26 on: December 06, 2015, 04:54:08 AM »

Correct me is I'm incorrect.

You have a drawing open.

You save the drawing with a different name.

You open the new drawing.

You delete the original drawing.

Alternative:


Save current
SaveAs with a different name
Delete original.

Is this correct ?
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 #27 on: December 06, 2015, 05:12:06 AM »
Obviously you are correct, but with little additions in alternative way as you call it:

I don’t need to Save current drawing, because i use this program as a part of "cleaning" process
Save As with a different name
Open the new file
Delete original.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Problem with spaces in script file
« Reply #28 on: December 06, 2015, 05:30:55 AM »
Will this work for you.
It will leave the 'Original' in th Temp folder at the moment ... it can be deleted programmatically if you want.

Code - Auto/Visual Lisp: [Select]
  1.  
  2. (defun c:doit (/ *error*)                              ; TODO add local variables
  3.   ;;-----------
  4.   (defun *error* (msg) (myDefault*error* msg))
  5.   ;;-----------
  6.   (vl-cmdf "_qsave")
  7.   (setq dwgprefix     (getvar "dwgprefix")
  8.         dwgname       (getvar "dwgname")
  9.         filename-base (vl-filename-base dwgname)
  10.         tempprefix    (getvar "tempprefix")
  11.         thedate       (rtos (getvar "CDATE") 2 0)
  12.   )
  13.   (setq OriginalFileName (strcat dwgprefix dwgname)
  14.         ArchiveFileName (strcat tempprefix dwgname)
  15.         newFileName     (strcat dwgprefix    "XREF-"
  16.                                 filename-base
  17.                                 "-TPZ-"      thedate ".Dwg" )
  18.   )
  19.   (if (findfile newFileName)
  20.     (progn
  21.       (alert (strcat newFileName " exists ... cancelling command"))
  22.       (exit)
  23.     )
  24.   )
  25.   (if (findfile ArchiveFileName)
  26.     (progn
  27.       (alert (strcat ArchiveFileName " exists ... cancelling command"))
  28.       (exit)
  29.     )
  30.   )
  31.   ;;--
  32.   (vl-cmdf "_Saveas" "2013" ArchiveFileName )
  33.   (vl-cmdf "_Saveas" "2013" newFileName )
  34.   (vl-file-delete OriginalFileName)
  35.   ;; (vl-file-delete ArchiveFileName) ;; if you really want to
  36.   (princ)
  37. )
  38.  
  39.  
  40.  
  41. (defun myDefault*error* (msg)
  42.   (while (< 0 (getvar 'cmdactive)) (command-s nil))
  43.   (setvar 'menuecho 1)
  44.   (cond ((not msg))
  45.         ((member (strcase msg t)
  46.                  '("console break" "function cancelled" "quit / exit abort")
  47.          )
  48.          (princ "\nFunction Cancelled.")
  49.         )
  50.         ((princ (strcat "\nApplication Error: " (itoa (getvar 'errno)) " :- " msg))
  51.          (vl-bt)
  52.         )
  53.   )
  54.   (setvar 'errno 0)
  55.   (princ)
  56. )
  57.  
  58.  
  59.  
  60.  

modified:kdub
« Last Edit: December 06, 2015, 05:53:19 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.

danglar

  • Newt
  • Posts: 161
  • Read My Li(s)(p)
Re: Problem with spaces in script file
« Reply #29 on: December 06, 2015, 05:34:16 AM »
looks nice , but what's about delete orriginal file and open new one?