See the top rated post in this thread. Click here

Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Lisp to "Display plot styles" on open

  1. #1
    Member
    Join Date
    2006-07
    Posts
    2
    Login to Give a bone
    0

    Default Lisp to "Display plot styles" on open

    Hi all! I'm hoping someone might be able to help me with a Lisp routine. I would like to have a Lisp that could change all layouts to "Display plot styles" on open. I have a couple Lisps already that get me pretty close but I was hoping that someone would be able to combine the two somehow.

    I'm running Civil3D 2011 on Win7-64


    I found this Lisp somewhere on this forum. I think originally it unchecked the "display plot styles" but I changed it to do the opposite. I turned it into a button, but its a manual button press and it only works on the current tab.

    Code:
    (defun pstyleDOshow (/ doc layoutobj)
      (setq	doc	  (vla-get-activedocument
    		    (vlax-get-acad-object)
    		  )
    	layoutobj (vla-get-activelayout doc)
      )
      (vla-put-showplotstyles layoutobj :vlax-true)
      (vla-regen doc acAllViewports)
      (mapcar 'vlax-release-object (list layoutobj doc))
      (princ)
    )

    Then I have this Lisp to lock all viewports in an drawing automatically after opening a drawing. I just add this to my startup suite and it works great!

    Code:
    ;;;VPLOCK.lsp locks all viewports automatically when opening a drawing
    ;;;no idea who wrote it
    
    (defun vplock (yesno / ss lock x obj)
      (vl-load-com)
      (if (setq ss (ssget "X" '((0 . "VIEWPORT")(-4 . "/=")(69 . 1))))
        (progn
          (if (= "y" yesno) (setq lock :vlax-true)(setq lock :vlax-false))
          (setq x 0)
          (while (< x (sslength ss))
         (setq obj (vlax-ename->vla-object (ssname ss x)))
         (vla-put-displaylocked obj lock)
         (setq x (1+ x))
         )
          )
        )
      (princ)
      )
    (vplock "y")
    So I don't know if a combination of these two would work, but I thought I'd include both just in case it helps. Ultimately what I need is a way to change all viewports in a drawing to "display plot styles" every time I open a drawing. Is this possible? I've been trying to figure this out on my own for a while but I'm not that great at programing so I haven't been able to make it work correctly. I would really appreciate any help on this. Thanks!
    Last edited by rkmcswain; 2011-04-26 at 04:21 PM. Reason: added CODE tags

  2. #2
    100 Club
    Join Date
    2000-11
    Location
    Ontario, Canada
    Posts
    116
    Login to Give a bone
    2

    Default Re: Lisp to "Display plot styles" on open

    Try adding this to your startup suite:

    Code:
    (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-true))
        ); vlax-for
      (vla-regen doc acAllViewports)
      (mapcar 'vlax-release-object (list layouts doc))
      (princ)
      ); defun
    (showpstyle)

  3. #3
    Member
    Join Date
    2006-07
    Posts
    2
    Login to Give a bone
    0

    Default Re: Lisp to "Display plot styles" on open

    Thanks gharvey for the quick reply! That worked perfectly! You're awesome!

  4. #4
    100 Club
    Join Date
    2000-11
    Location
    Ontario, Canada
    Posts
    116
    Login to Give a bone
    0

    Default Re: Lisp to "Display plot styles" on open

    Glad I could help

  5. #5
    Member
    Join Date
    2008-07
    Posts
    6
    Login to Give a bone
    0

    Default Re: Lisp to "Display plot styles" on open

    Hi, GHarvey. Is there any way to write this so it will effect all paper space layouts and exclude the model layout. When I run it it changes all of my colors that are set to black/white (Pen 7) to white in model space.... My hope is to see model space in color, but paper space as a plot preview... (In Black) Thanks in advance!

  6. #6
    Member
    Join Date
    2008-07
    Posts
    6
    Login to Give a bone
    0

    Default Re: Lisp to "Display plot styles" on open

    ---------------------------

  7. #7
    100 Club
    Join Date
    2000-11
    Location
    Ontario, Canada
    Posts
    116
    Login to Give a bone
    0

    Default Re: Lisp to "Display plot styles" on open

    Try the following revision...

    Code:
    (defun showpstyle ( / DOC LAYOUTS)
      (setq doc (vla-get-activedocument (vlax-get-acad-object))
            layouts (vla-get-layouts doc)
            ); setq
      (vlax-for n layouts
        (if (/= "Model" (vla-get-name n))
          (vl-catch-all-apply 'vla-put-showplotstyles (list n :vlax-true))
          ); if
        ); vlax-for
      (vla-regen doc acAllViewports)
      (mapcar 'vlax-release-object (list layouts doc))
      (princ)
      ); defun
    (showpstyle)

  8. #8
    Programming Moderator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,454
    Login to Give a bone
    0

    Default Re: Lisp to "Display plot styles" on open

    Couple of things....

    Unless I am overlooking something (which is entirely possible), there's no need to call vl-Catch-All-Apply when setting an Object's Property (in this case a Boolean), given that you've hard-coded an allowable value (in this case :vlax-True).

    I would, however, recommend that one do so (that is, to use vl-Catch-All-Apply) if passing a parameter to the Object's Property as a value; just not needed here IMO.

    Also, one need not release internal Object's; only external/interface Objects.

    Code:
    (defun c:ShowPlotStyles ( / acDoc)
      (vlax-for oLayout
                (vla-get-layouts
                  (setq acDoc
                         (vla-get-activedocument (vlax-get-acad-object))
                  )
                )
        (if (/= "Model" (vla-get-name oLayout))
          (vla-put-showplotstyles oLayout :vlax-true)
        )
      )
      (vla-regen acDoc acAllViewports)
      (princ)
    )
    Separately, this could easily be expanded to incorporate a bit-coded setting, either drawing data (via XRecord?), or registry data to allow one to programmatically toggle the ShowPlotStyles Property value at drawing open, and/or while in session if desired

    Psuedo system variable:
    Code:
    0 = All Layouts do not display plot styles
    1 = All Layouts display plot styles, except for Model
    2 = All Layouts display plot styles, including Model
    Last edited by RenderMan; 2013-02-15 at 07:21 PM.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3620, Core i7-7700K 4.2GHz, 64GB RAM, Samsung 970 Pro M.2, 8GB NVIDIA Quadro P4000

  9. #9
    Member
    Join Date
    2008-07
    Posts
    6
    Login to Give a bone
    0

    Default Re: Lisp to "Display plot styles" on open

    Thank You!! GHarvey & RenderMan

  10. #10
    Woo! Hoo! my 1st post
    Join Date
    2016-02
    Posts
    1
    Login to Give a bone
    0

    Default Re: Lisp to "Display plot styles" on open

    Quote Originally Posted by GHarvey View Post
    Try adding this to your startup suite:

    Code:
    (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-true))
        ); vlax-for
      (vla-regen doc acAllViewports)
      (mapcar 'vlax-release-object (list layouts doc))
      (princ)
      ); defun
    (showpstyle)
    this lisp does not response when i load. can anyone help me

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 8
    Last Post: 2012-08-18, 01:31 AM
  2. Plot Styles Change "Normal" globaly in layer dialog
    By IanR in forum VBA/COM Interop
    Replies: 14
    Last Post: 2012-01-11, 02:18 AM
  3. Replies: 5
    Last Post: 2009-04-17, 10:10 AM
  4. "SketchUp" like display styles
    By IanR in forum Revit Architecture - Wish List
    Replies: 0
    Last Post: 2008-07-04, 11:38 AM
  5. Replies: 8
    Last Post: 2007-04-04, 12:39 PM

Posting Permissions

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