+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12
  1. #1
    Full Member
    Using
    AutoCAD 2012
    Join Date
    Mar 2012
    Posts
    25

    Default hi all. please dont laugh - lisp

    Registered forum members do not see this ad.

    hi all, see third comment
    Last edited by shakey230; 4th Jul 2012 at 05:29 am.

  2. #2
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    3,004

    Default

    Until someone will take a look to your code, please edit the post and add code tags. Thank you.
    Regards,
    Mircea

    AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3

  3. #3
    Full Member
    Using
    AutoCAD 2012
    Join Date
    Mar 2012
    Posts
    25

    Default

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

  4. #4
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    3,004

    Default

    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.
    Regards,
    Mircea

    AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3

  5. #5
    Full Member
    Using
    AutoCAD 2012
    Join Date
    Mar 2012
    Posts
    25

    Default

    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.

  6. #6
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    3,004

    Default

    Please pay attention that here you are self referencing the current drawing (excerpt from your code).
    Code:
    (setq drawingnew1 (strcat (getvar "dwgprefix") (vl-filename-base (getvar "DWGNAME")))) 
    (command "-xref"  "A"  drawingNew1 "0,0,0"  "" ""  "")
    Regards,
    Mircea

    AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3

  7. #7
    Full Member
    Using
    AutoCAD 2012
    Join Date
    Mar 2012
    Posts
    25

    Default

    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

  8. #8
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    3,004

    Default

    Please check this modified code:
    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)
    )
    Regards,
    Mircea

    AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3

  9. #9
    Full Member
    Using
    AutoCAD 2012
    Join Date
    Mar 2012
    Posts
    25

    Default

    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.

  10. #10
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    3,004

    Default

    Registered forum members do not see this ad.

    Just change this part:
    Code:
     (vl-mkdir (setq pathNew (strcat (getvar "DWGPREFIX") "arch\\")))
     (setq drawingNew1 (strcat pathNew
                               (vl-filename-base Name)
                               "-XREF"
                               (vl-filename-extension Name)))
    Regards,
    Mircea

    AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3

Similar Threads

  1. Replies: 7
    Last Post: 1st May 2011, 07:46 pm
  2. You Guys Are Gonna Laugh!
    By Guitarzan-54 in forum AutoCAD Drawing Management & Output
    Replies: 4
    Last Post: 5th Dec 2005, 08:14 pm
  3. LISP, DONT REDEFINE BLOCK
    By J-LYLE in forum AutoLISP, Visual LISP & DCL
    Replies: 6
    Last Post: 5th Apr 2005, 08:02 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts