Results 1 to 2 of 2

Thread: Lisp for hiding plot styles across multiple drawings

  1. #1
    Woo! Hoo! my 1st post
    Join Date
    2013-11
    Posts
    1
    Login to Give a bone
    0

    Default Lisp for hiding plot styles across multiple drawings

    Hello,

    I want to be able to hide plot styles on all documents in a directory.

    I have lisp code that can hide plot styles on the current drawing:

    Code:
    (vl-load-com)
    
    (defun showpstyle ( / DOC LAYOUTS)
      (setq doc (vla-get-activedocument (vlax-get-acad-object))
            layouts (vla-get-layouts doc)
            ); setq
      (vlax-for n layouts
        (vl-catch-all-apply 'vla-put-showplotstyles (list n :vlax-false))
        ); vlax-for
      (vla-regen doc acAllViewports)
      (mapcar 'vlax-release-object (list layouts doc))
      (princ)
      ); defun
    (showpstyle)

    And I have code that can loop through a directory and change things on multiple drawings:

    Code:
    ;; Copies plot configurations from the current drawing;; to all drawings within a selected folder.
    (defun c:copyplotconfigs (/ _getfolder _getplotconfigs adoc dir doc file l n odbx plt v)
      (vl-load-com)
      (defun _getfolder (message / sh folder result)
        (setq sh (vla-getinterfaceobject (vlax-get-acad-object) "Shell.Application"))
        (setq folder (vlax-invoke-method sh 'browseforfolder 0 message 0))
        (vlax-release-object sh)
        (if	folder
          (progn (setq result (vlax-get-property (vlax-get-property folder 'self) 'path))
    	     (if (wcmatch result "*\\")
    	       result
    	       (strcat result "\\")
    	     )
          )
        )
      )
    
    
     
      (defun _getplotconfigs (doc / out)
        (vlax-for x	(vla-get-plotconfigurations doc)
          (setq out (cons (cons (strcase (vla-get-name x)) x) out))
        )
      )
      (setq adoc (vla-get-activedocument (setq doc (vlax-get-acad-object))))
      (cond
        ((not (setq l (_getplotconfigs adoc)))
         (princ "\nNo plot configurations in current drawing!")
        )
        ((not (setq	odbx (if (< (setq v (substr (getvar 'acadver) 1 2)) "16")
    		       (vla-getinterfaceobject doc "ObjectDBX.AxDbDocument")
    		       (vla-getinterfaceobject doc (strcat "ObjectDBX.AxDbDocument." v))
    		     )
    	  )
         )
         (princ "\nObject DBX interface not created!")
        )
        ((if
           (setq dir (_getfolder "Select directory to apply current drawing pagesetups to: "))
    	(foreach f (vl-directory-files dir "*.dwg" 0)
    	  (setq file (strcat dir f))
    	  (if (vl-catch-all-error-p (vl-catch-all-apply 'vla-open (list odbx file)))
    	    (princ (strcase (strcat "\nError opening: " file)))
    	    (progn (princ (strcat "\nOpening: " file))
    		   (setq plt (vla-get-plotconfigurations odbx))
    		   (if (not (zerop (setq n (vla-get-count plt))))
    		     (progn (princ (strcat "\n\t" (itoa n) " - plot configurations removed"))
    			    (vlax-map-collection plt 'vla-delete)
    		     )
    		   )
    		   (and	(vlax-invoke adoc 'copyobjects (mapcar 'cdr l) plt nil)
    			(princ (strcat "\n\t"
    				       (itoa (length l))
    				       " - plot configurations copied from current drawing"
    			       )
    			)
    		   )		   		   
    		   (vla-saveas odbx (vla-get-name odbx))
    	    )
    	  )	
    	)
    	(princ "\nBuh bye...")
         )
        )
      )
      (princ)
    )
    (copyplotconfigs)
    I cant figure out how to combine these do hide plot styles on all drawings? Can anyone help me combine these, I dont understand lisp that well especially the vla functions.

  2. #2
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Lisp for hiding plot styles across multiple drawings

    Well, even if you can modify each Layout's ShowPlotStyles Property via ObjectDBX (DBX)... I don't recall doing so personally... DBX does not support the Regen() Method AFAIK.

    Quote Originally Posted by matthew.turinski436979 View Post
    I dont understand lisp that well especially the vla functions.
    Did you write all of that code yourself, or did you cull it from the interwebs?

    Cheers
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

Similar Threads

  1. Import Styles and Settings to Multiple Drawings
    By Wish List System in forum Civil 3D Wish List
    Replies: 1
    Last Post: 2015-04-28, 12:39 AM
  2. Drag and Drop Styles to Multiple Drawings
    By civil3d.wishlist1941 in forum Civil 3D Wish List
    Replies: 4
    Last Post: 2015-03-13, 02:39 PM
  3. Use Multiple Plot Styles per Plot
    By autocad.wishlist1734 in forum AutoCAD Wish List
    Replies: 1
    Last Post: 2012-07-20, 12:08 PM
  4. Replies: 0
    Last Post: 2009-08-20, 08:08 PM
  5. Drawings Stuck in STB plot styles
    By m.cullen in forum AutoCAD General
    Replies: 3
    Last Post: 2005-04-07, 01:05 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
  •