shakey230 Posted July 4, 2012 Posted July 4, 2012 (edited) hi all, see third comment Edited July 4, 2012 by shakey230 Quote
MSasu Posted July 4, 2012 Posted July 4, 2012 Until someone will take a look to your code, please edit the post and add code tags. Thank you. Quote
shakey230 Posted July 4, 2012 Author Posted July 4, 2012 hi all, trying to peice a lisp together here it could prob be done more efficently but as long as i get it to work i am happy. basicaly i open a file and run the lisp. first - its saves 2 files - filename-pl & filename-XREF then with another comand it loads in the file (filename-xref) as an xref now the problem i am having is i want to rename the xref name to ARCH via the rename command but it keeps kicking out the current file name and if it would be possable to save the file called (filename-XREF) in the same directry but in another folder cald ARCH that would be great.. Code: (defun c:sa ( / Name ) (setq Name (strcat (getvar "dwgprefix") (vl-filename-base (getvar "DWGNAME" )) ) ) (vl-load-com) (setq Name1 (strcat (getvar "dwgprefix") (vl-filename-base (getvar "DWGNAME" )) ) ) (setq drawingOld1 (getvar "DWGNAME") drawingNew1 (strcat (getvar "DWGPREFIX") (vl-filename-base drawingOld1 ) "-XREF" (vl-filename-extension drawingOld1))) (command "_SAVEAS" "" drawingNew1) (setq drawingOld (getvar "DWGNAME") drawingNew (strcat (getvar "DWGPREFIX") (vl-filename-base Name1) "-pl" (vl-filename-extension drawingOld) ) ) (command "_SAVEAS" "" drawingNew) ) (defun C:AS () (setq drawingnew1 (strcat (getvar "dwgprefix") (vl-filename-base (getvar "DWGNAME")) ) ) (command "-xref" "A" drawingNew1 "0,0,0" "" "" "") (command "-Rename" "B" (vl-filename-base (getvar "DWGNAME")) "ARCH" )) Quote
MSasu Posted July 4, 2012 Posted July 4, 2012 What are you trying to achieve in fact? You open a drawing (i.e. Test.dwg) and save it twice under Test-XREF.dwg and Test-pl.dwg names. This part is working well. On the second part you try to insert as external reference the current drawing and then rename it. The current drawing – last save - will be Test-pl.dwg, and you try to insert Test-pl.dwg in it. This isn’t allowed by AutoCAD (circular reference). By reading again your previous thread seems that you are trying to xref the *-pl drawing, so have to presume that the current drawing should be *.XREF one. Although I’m not sure what will achieve by this – you will have the same content twice; one in drawing and once as external reference. Quote
shakey230 Posted July 4, 2012 Author Posted July 4, 2012 basically i open drawing TEST.dwg run the lisp it saves the test-xref file and saves test-pl this brings me in the test-pl file, (and leaves the orgional test.dwg) then it xrefs test-xref.dwg in - to this point it works ok what i want to do (on the last line on the lisp) is change the refferance name of test-xref.dwg to ARCH. and if possable send the test-xref.dwg to a folder with in that directory aclled arch (e.g. current C:\Users\david\Desktop\test script insert -to - C:\Users\david\Desktop\test script\arch) but i want to do this without naming the directory as it will change with jobs so it will be the current directory with a folder called arch. Quote
MSasu Posted July 4, 2012 Posted July 4, 2012 Please pay attention that here you are self referencing the current drawing (excerpt from your code). (setq drawingnew1 (strcat (getvar "dwgprefix") (vl-filename-base (getvar "DWGNAME")))) (command "-xref" "A" drawingNew1 "0,0,0" "" "" "") Quote
shakey230 Posted July 4, 2012 Author Posted July 4, 2012 thanks marcea. it changed the names ok, but on the xref file it called it test-xref3.dwg and it didnt x ref the test-xref.dwg file in to the current test-pl.dwg Quote
MSasu Posted July 4, 2012 Posted July 4, 2012 Please check this modified code: (defun c:sa( / Name drawingNew1 drawingNew2 ) (vl-load-com) (setq Name (getvar "DWGNAME")) (setq drawingNew1 (strcat (getvar "DWGPREFIX") (vl-filename-base Name) "-XREF" (vl-filename-extension Name))) (setq drawingNew2 (strcat (getvar "DWGPREFIX") (vl-filename-base Name) "-pl" (vl-filename-extension Name))) ;test if target drawing already exists (if (not (findfile drawingNew1)) (command "_SAVEAS" "" drawingNew1) (command "_SAVEAS" "" drawingNew1 "_Y") ) (if (not (findfile drawingNew2)) (command "_SAVEAS" "" drawingNew2) (command "_SAVEAS" "" drawingNew2 "_Y") ) (command "_XREF" "_A" drawingNew1 '(0.0 0.0 0.0) 1.0 1.0 0.0) (command "_RENAME" "_B" (vl-filename-base drawingNew1) "ARCH") (princ) ) 1 Quote
shakey230 Posted July 4, 2012 Author Posted July 4, 2012 yes mircea its a great job. prob pushing my luck a bit but is it possable to * send the test-xref.dwg to a folder with in that directory aclled arch (e.g. current C:\Users\david\Desktop\test script insert -to - C:\Users\david\Desktop\test script\arch) but i want to do this without naming the directory as it will change with jobs so it will be the current directory with a folder called arch* if not dont worry about it if not more than happy with what i have got. Quote
MSasu Posted July 4, 2012 Posted July 4, 2012 Just change this part: [color=red](vl-mkdir (setq pathNew (strcat (getvar "DWGPREFIX") "arch\\"))) [/color] (setq drawingNew1 (strcat [color=red]pathNew [/color] (vl-filename-base Name) "-XREF" (vl-filename-extension Name))) Quote
shakey230 Posted July 4, 2012 Author Posted July 4, 2012 mircea cant thank you enough. you have been a great help thank you. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.