TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: KewlToyZ on June 09, 2006, 12:12:39 PM
-
I'm trying to copy an image file to a project folder automatically within an autolisp routine.
I found a few references to vl-file-copy used but it seems to return "nil" when i try the static file and folder paths.
(defun c:logocopy()
(vl-file-copy "X:\\logo.jpg" "X:\\A\\A0001\\Logos")
)
playing around with it i also tried:
(defun c:logocopy()
(setq logo2logos (getfiled "Logo File Import" "X:\\logo.jpg" "jpg" 2))
(vl-file-copy logo2logos "X:\\A\\A0001\\Logos\\" T)
)
still got nil
I'm not finding the vl-file-copy in AutoCAD help very clear on its ability to handle image files over a network.
Any direction would be appreciated, Thank you :)
-
(defun c:test()
(command "sh")
(command "copy x:\logo.jpg x:\a\0001\logos")
)
?
-
As far as I can see,
(defun c:logocopy()
(vl-file-copy "X:\\logo.jpg" "X:\\A\\A0001\\Logos")
)
should work. Are you sure that the file exists in that location and that the destination folder exists?
-
wait, try
defun c:logocopy()
(vl-file-copy "X:\\logo.jpg" "X:\\A\\A0001\\Logos\\logo.jpg")
)
-
(defun c:test()
(command "sh")
(command "copy x:\logo.jpg x:\a\0001\logos")
)
?
I was hoping for it to be this simple but it lists "copy x:\logo.jpg x:\a\0001\logos" as an unkown command
Of course adding "" to each component (command "copy" "x:\logo.jpg" "x:\a\0001\logos") brings up autocad's copy command so this isn't the right course either.
Removing the quotes all together (command copy x:\logo.jpg x:\a\0001\logos)
Returns nil again so I am back to square one lol.
-
That was my first attempt and I keep getting a nil.
Which was wy I tried the getfiled to make sure i found the file.
I'm trying to use CAD to place the logo file since the web interface seems to fail arbitrarily on folders over the network.
All have the same permissions but for some reason it misses this image file periodically.
I was hoping a simple lisp routine would help but this is proving strange as well.
-
That was my first attempt and I keep getting a nil.
Which was wy I tried the getfiled to make sure i found the file.
I'm trying to use CAD to place the logo file since the web interface seems to fail arbitrarily on folders over the network.
All have the same permissions but for some reason it misses this image file periodically.
I was hoping a simple lisp routine would help but this is proving strange as well.
I forgot the command "sh" to bring up the OS command.
My bad and thank you for the help!
-
Glad that fixed you up. I'm sure that someone who can lisp will be along in the very near future to tell you how to get vl-file-copy to work or why you shouldn't use it and what you should use instead.
-
Yes it works well alone but when I try to make the paths defined by the session it doesnt activate within another routine.
I was trying to integrate it with the drawing setup routine the guys here helped me overwhelmingly with.
I'm going to keep playing with it, but I think that the OS command seems not to recognize a variable as a path.
Or I am hust completely failing to structure it properly which is more likely.
-
Yes it works well alone but when I try to make the paths defined by the session it doesnt activate within another routine.
I was trying to integrate it with the drawing setup routine the guys here helped me overwhelmingly with.
I'm going to keep playing with it, but I think that the OS command seems not to recognize a variable as a path.
Or I am hust completely failing to structure it properly which is more likely.
It tries to pass the variable path as a command instead of a path.
(setq idx (vl-string-search "CADD" prefx))
(setq baseprefix (strcat (substr prefx 1 (+ 5 idx)) "XREF\\"))
(command "sh")
(command "copy X:\\logo.jpg" baseprefix))
--------------------------------------------------------------------------------------------
Command: Unkown command "X:\A\A9999\CADD\XREF\" Press F1 for help.
nil
Command:|
-----------------------------------------------------------------------------------
Is where I end up
-
wait, trydefun c:logocopy()
(vl-file-copy "X:\\logo.jpg" "X:\\A\\A0001\\Logos\\logo.jpg")
)
this should be working, if it isn't take a look and make sure the file isn't already there (in the target directory), if it is delete it and try again
-
What happens if
(setq idx (vl-string-search "CADD" prefx))
(setq baseprefix (strcat (substr prefx 1 (+ 5 idx)) "XREF\\"))
(setq cmdline ( "sh copy x:\\logo.jpg" baseprefix)
;my lisp is weak and lacks leverage but I believe that the above line sets cmdline to
;"sh copy x:\\logo.jpg x:\\a\\a9999\cadd\xref\
(command cmdline)
***starts looking around desperately for a lisper to step in***
woot! UCP to the rescue.
-
wait, trydefun c:logocopy()
(vl-file-copy "X:\\logo.jpg" "X:\\A\\A0001\\Logos\\logo.jpg")
)
this should be working, if it isn't take a look and make sure the file isn't already there (in the target directory), if it is delete it and try again
No the file never made it there with this, I have no idea why.
-
What happens if (setq idx (vl-string-search "CADD" prefx))
(setq baseprefix (strcat (substr prefx 1 (+ 5 idx)) "XREF\\"))
(setq cmdline ( "sh copy x:\\logo.jpg" baseprefix)
;my lisp is weak and lacks leverage but I believe that the above line sets cmdline to
;"sh copy x:\\logo.jpg x:\\a\\a9999\cadd\xref\
(command cmdline)
***starts looking around desperately for a lisper to step in***
woot! UCP to the rescue.
Nice attempt, I played with this awhile but without command SH doesnt recognize.
-
(setq idx (vl-string-search "CADD" prefx))
(setq baseprefix (strcat (substr prefx 1 (+ 5 idx)) "XREF\\"))
(command "sh")
(command "copy X:\\logo.jpg baseprefix" ))
I went back with this above.
It opens the folder with windows explorer for the baseprefix but doesn't copy the file strangely enough.
-
how would I remove the quotes from the path stored in baseprefix?
that is the reason it reads the path as a command from the shell when I run it under
(setq idx (vl-string-search "CADD" prefx))
(setq baseprefix (strcat (substr prefx 1 (+ 5 idx)) "XREF\\"))
(command "sh")
(command copy X:\\logo.jpg baseprefix ))
-
Try this.
(if (findfile "X:\\logo.jpg")
(if (findfile "X:\\A\\A0001\\Logos\\logo.jpg")
(prompt "\n File already exists, cannot copy.")
(vl-file-copy "X:\\logo.jpg" "X:\\A\\A0001\\Logos\\logo.jpg")
)
(prompt "\n Original file does not exist, cannot copy.")
)
-
how would I remove the quotes from the path stored in baseprefix?
that is the reason it reads the path as a command from the shell when I run it under
(setq idx (vl-string-search "CADD" prefx))
(setq baseprefix (strcat (substr prefx 1 (+ 5 idx)) "XREF\\"))
(command "sh")
(command copy X:\\logo.jpg baseprefix ))
You would have to string all the string together with strcat.
(command (strcat "copy x:\\logo.jpg" baseprefix))
</guess about shell command>
-
I have wrote this...
maybe could help..
(defun c:pgpbackup (/ pgpfile loginname)
(setq pgpfile (findfile "acad.pgp"))
(setq loginname (getvar "loginname"))
(if (findfile (strcat "x:/acad/pgp/" loginname ".pgp"))
(vl-file-delete (strcat "x:/acad/pgp/" loginname ".pgp"))
)
(vl-file-copy pgpfile (strcat "x:/acad/pgp/" loginname ".pgp") T)
)code]
-
Here's my little contribution.....
(defun xcopy (source dest)
(if (and (setq source (findfile source))
(vl-file-directory-p (vl-filename-directory dest))
)
(progn
(if (findfile dest)
(vl-file-delete dest)
)
(vl-file-copy source dest)
)
)
)
;;sample usage:
(xcopy "c:\\test.txt" "q:\\test.txt")
[\code]
-
I was taking some time to tell myself how much of an idiot I was.... :lol:
Forgot to include the filename with the path with vl-file-copy :|
(if (findfile "J:\\logo.jpg")
(if (findfile (strcat baseprefix"logo.jpg"))
(prompt "\n File already exists, cannot copy.")
(vl-file-copy "J:\\logo.jpg" (strcat baseprefix"logo.jpg"))
)
(prompt "\n Original file does not exist, cannot copy.")
)
Worked perfectly TWiley.
Great addition Jeff M
Nice feature there Andrea!