See the top rated post in this thread. Click here

Results 1 to 6 of 6

Thread: Lisp to delete named page setups not working...

  1. #1
    I could stop if I wanted to jpcadconsulting347236's Avatar
    Join Date
    2011-09
    Posts
    267
    Login to Give a bone
    0

    Default Lisp to delete named page setups not working...

    Hiy aagain gang.

    here's another routine that is baffeling me.

    It's supposed to delete a bunch of named page setups (based on wildcards), and then add back certain page setups based on the vale of INSUNITS.

    When it gets to the part that is supposed to delete them (in red below) it fails with:

    "error: no function definition: VLAX-GET-ACAD-OBJECT"

    Code:
    ;;; DELETES ALL STANDARD NAMED PAGE SETUPS AN IMPORTS BASED ON INSUNITS ;;;
    
    ;;;This section collects page setup names ;;;
    (vl-load-com)
    (defun DeleteOldPageSetup ( Name / Cfgs)
    (setq Cfgs
     (vla-get-plotconfigurations
     (vla-get-activedocument
     (vlax-get-acad-object))))
    (cond
     ((vl-string-search "*" Name)
      (vlax-for x Cfgs
       (if (wcmatch (vla-get-name x) Name)
        (vla-delete x)
     )))
     (T
      (vl-catch-all-apply
        '(lambda () (vla-delete (vla-item Cfgs Name)))
     ))
    )
    (princ)
    )
    ;;; This section deletes the page setups - add names as needed ;;;
    (DeleteOldPageSetup "*_COLOR*")
    (DeleteOldPageSetup "*_PAPER*")
    (DeleteOldPageSetup "*_PDF*")
    (DeleteOldPageSetup "*_Metric*")
    
    
    ;;; IMPORTS NAMED PAGE SETUPS
    
    
    (cond ((= (getvar "INSUNITS") 1) (command "._-PSETUPIN" "Z:/ACA 2019/Drawings/MVVA Pagesetups.dwg" "*"))
          ((= (getvar "INSUNITS") 2) (command "._-PSETUPIN" "Z:/ACA 2019/Drawings/MVVA Pagesetups.dwg" "*"))
          ((= (getvar "INSUNITS") 4) (command "._-PSETUPIN" "Z:/ACA 2019/Drawings/MVVA Metric Pagesetups.dwg" "*"))
          ((= (getvar "INSUNITS") 5) (command "._-PSETUPIN" "Z:/ACA 2019/Drawings/MVVA Metric Pagesetups.dwg" "*"))
          ((= (getvar "INSUNITS") 6) (command "._-PSETUPIN" "Z:/ACA 2019/Drawings/MVVA Metric Pagesetups.dwg" "*"))
    )

    Thanks as always for any guidance.

    -JP
    James Pertusi

    CAD Applications Consultant
    1 (646) 773 4834
    www.jpcadconsulting.com

  2. #2
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL
    Posts
    3,094
    Login to Give a bone
    0

    Default Re: Lisp to delete named page setups not working...

    I use your DelPageSetup by Jason Piercey on a regular basis (Thanks), but have only used it with a wildcard at the end as in
    Code:
    (DelPageSetup "11×17*")
    not at the beginning. How many different prefixes do you have for "_COLOR*"? You must use a lot more Page Setups than me.
    Tom Beauford P.S.M. - Civil 2019 on Windows 10 Enterprise
    Design Analysis - Leon County Public Works/Engineering Wrap [CODE] tags around selected text
    2280 Miccosukee Rd. Tallahassee, FL 32308-5310
    Ph# (850)606-1516 Home Page

  3. #3
    I could stop if I wanted to jpcadconsulting347236's Avatar
    Join Date
    2011-09
    Posts
    267
    Login to Give a bone
    0

    Default Re: Lisp to delete named page setups not working...

    We have a lot. Trying to remedy that.

    I tried with no * at the beginning. No dice. Same error.

    Thanks!
    James Pertusi

    CAD Applications Consultant
    1 (646) 773 4834
    www.jpcadconsulting.com

  4. #4
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    5,514
    Login to Give a bone
    0

    Default Re: Lisp to delete named page setups not working...

    It should have been loaded by vl-load-com. I would try restarting AutoCAD and testing again.
    C:> ED WORKING....

  5. #5
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL
    Posts
    3,094
    Login to Give a bone
    0

    Default Re: Lisp to delete named page setups not working...

    Not sure if it helps as it looks the same to me, but this has always worked great:
    Code:
    ; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/purge-all-page-setup-names/m-p/830018#M55676
    (defun DelPageSetup ( Name / Cfgs) ; by Jason Piercey - Autodesk Discussion Forum Moderator
      (setq Cfgs
    	(vla-get-plotconfigurations
    	  (vla-get-activedocument
    		(vlax-get-acad-object)
    	  )
    	)
      )
    
      (cond
    	((vl-string-search "*" Name)
    	  (vlax-for x Cfgs
    		(if (wcmatch (vla-get-name x) Name)
    		  (vla-delete x)
    		)
    	  )
    	)
    
    	(T
    	  (vl-catch-all-apply
    		'(lambda () (vla-delete (vla-item Cfgs Name)))
    	  )
    	)
      )
      (princ)
    )
    
    ;; (DelPageSetup "*") to run or
    ;; (or DelPageSetup (load "DelPageSetup.lsp"))(DelPageSetup "*") to load if needed then run
    To import an 11×17 layout deleting any existing Page Setups beginning with "11×17" and importing Page Setups "11×17" & "11×17 PDF" I use the macro:
    Code:
    ^C^C^P(DelPageSetup "11×17*")(Steal (strcat (vl-filename-directory (getenv "QnewTemplate")) (chr 92) "AutoCAD Template" (chr 92) "Templates.dwt") (list (list "Page Setups" (list "11×17" "11×17 PDF"))))(Steal (strcat (vl-filename-directory (getenv "QnewTemplate")) (chr 92) "AutoCAD Template" (chr 92) "Templates.dwt") (list (list "Layouts" (list "11×17")))) .regen
    I lean heavily on Lee Mac's code and others. While I've written a bit myself I don't feel the need to rewrite code others have already shared online.
    Tom Beauford P.S.M. - Civil 2019 on Windows 10 Enterprise
    Design Analysis - Leon County Public Works/Engineering Wrap [CODE] tags around selected text
    2280 Miccosukee Rd. Tallahassee, FL 32308-5310
    Ph# (850)606-1516 Home Page

  6. #6
    I could stop if I wanted to jpcadconsulting347236's Avatar
    Join Date
    2011-09
    Posts
    267
    Login to Give a bone
    1

    Default Re: Lisp to delete named page setups not working...

    Thanks all, I'm now using DelPageSetup by Jason Piercey and it's working like a charm.
    Last edited by jpcadconsulting347236; 2019-05-22 at 08:19 PM.
    James Pertusi

    CAD Applications Consultant
    1 (646) 773 4834
    www.jpcadconsulting.com

Similar Threads

  1. 2016: Page Setup Manager/Page Setups not importing
    By tbevis730888 in forum AutoCAD General
    Replies: 2
    Last Post: 2016-07-02, 03:49 PM
  2. Delete and Delete All Page Setups
    By IanR in forum AutoCAD Wish List
    Replies: 2
    Last Post: 2015-12-17, 06:38 AM
  3. Replies: 2
    Last Post: 2006-08-11, 12:35 PM
  4. Page setups not working for other users
    By IanR in forum AutoCAD Plotting
    Replies: 2
    Last Post: 2006-04-01, 08:58 AM
  5. Importing a layout also imports the named page setups
    By jpaulsen in forum AutoCAD Wish List
    Replies: 1
    Last Post: 2005-02-17, 04:29 AM

Posting Permissions

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