Jump to content

Recommended Posts

Posted (edited)

hi all, see third comment

Edited by shakey230
Posted

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 :cry:

 

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" ))

Posted

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.

Posted

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.

Posted

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"  "" ""  "")

Posted

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

Posted

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)
)

  • Like 1
Posted

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.

Posted

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)))

Posted

mircea cant thank you enough. you have been a great help thank you.:D

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...