Jump to content
Nobull84

Toggle Black and white

Recommended Posts

Nobull84

I'm looking to save some time (aren't we all). We draw in many different colors to help our, sometimes, complicated dwgs easier to work with and differentiate between things. But our end product is a black and white drawing.

 

Is there a lisp out there for toggling to white background and all black everything else? I can plot a dwg, wait for it to load, open it, review and then make changes and repeat as necessary.

 

Or, ideally, I can hit one button, review and make changes on the fly before the plotting process. Plot previews are also a bit cumbersome.

 

I hate to post this, as it is most likely out there but the search function with this forum can be a bit shaky. Any help would be appreciated.

 

 

Thanks,

-Nobull

Share this post


Link to post
Share on other sites
BlackBox

The simplest, built-in way of going about this, is to Display Plot Styles.

 

If you go into a Layout tab, open the Page Setup Manager, select your named page setup, and hit the Modify button. In the Page Setup dialog, look to the Plot Style Table pane in the upper right, and check the Display Plot Styles option.

 

This will essentially force a plot preview (for the most part) without actually hitting plot preview button, etc.. Important to note that Defpoints layer, Fields, etc. may also be displayed which could be a bit confusing to one who isn't expecting that.

 

HTH

Share this post


Link to post
Share on other sites
tzframpton

Also, if you add Lee's nifty LISP routine along with BlackBox's "Display Plot Styles" tip, it will further aid in what I call a "live plot preview": http://www.cadtutor.net/forum/showthread.php?81573-Toggle-Lineweights-when-switching-between-Model-and-Paperspace&p=554688&viewfull=1#post554688

 

Also, I change my Viewport layer to True Color 255,255,255 to "hide" the viewport border, even though it's still there. Works fantastic.

 

-Tannar

Share this post


Link to post
Share on other sites
BlackBox

You're the first person I thought of when I read this thread, Styk :thumbsup:

Share this post


Link to post
Share on other sites
tzframpton
You're the first person I thought of when I read this thread, Styk :thumbsup:
I figured as much. :)

 

*EDIT*

I need to post a Screencast with my setup in AutoCAD in the Tips and Tricks section. It's really quite nice actually.

Share this post


Link to post
Share on other sites
Nobull84

Thank you both for the great ideas.

 

Blackbox, your simple option changes in the page setup manager is basically what I'm after. It doesn't toggle in modelspace, which would be ideal, but it would suffice. However, is there an option to apply to all layouts? I have several sheets per dwgs. The current job I would like to apply this to is standing at roughly 100 sheets.

 

tzframpton, Lee's coding is almost sure to do something great as I've become a fan. (He's helped me tremendously in the past). At times though, I am weary of adding things to current lsp files as I make my modifications to my employer's programs. I have added a handful of lisps and made some decent changes to the CUI but when it comes to altering files, I become uneasy. My employer has altered CAD significantly to suit our business.

I would call myself being a novice at best. I have made modifications in the past that I have not been able to return to default settings (which required help from others *embarrassing*) so please bear with my hesitation. What exactly does the program from Lee do and what am I playing with in the acaddoc.lsp file? In other words, how could I mess something up?

 

I also read on that thread's comments from Blackbox, regarding other user's viewing my drawings. If I read it correctly, there is a potential for differences in how they are viewed upon opening. I do not like rocking boats here at my office. (At least I'm not experienced enough to do so yet). I try to limit my customizing to only affect me and my work while sharing with other's, giving them the option to use. If it could potentially create more buttons for my checkers and supervisors to hit, I would probably not even attempt the install.

 

Thank you both for your time and dealing with my reluctance,

-Nobull

Share this post


Link to post
Share on other sites
BlackBox

You're welcome; we're happy to help.

 

If you do enable Display Plot Styles, then from Layout tab, you can use MSPACE Command (presuming a locked Viewport), and modify entities in Model Space through Layout using this view, which is why Defpoints, etc. can play a factor as they're shown, but not necessarily plottable per-se.

 

Please note that the change I note above to named page setup is applied to any layout which references said named page setup. Also be mindful that named page setups are saved within the drawing, and not to an external, central location, which means that only those drawings which you've updated to 'Display Plot Styles' will appear this way, and any with the same named page setup (unmodified) will not appear this way.

 

This is one of those very settings that may, or may not be well received for all users, especially if being done outside of one's CAD Standard(s).

 

I've always found it best to implement 'toggle' functionality, and where possible an automatic restoration for Save, Close, etc.

 

HTH

Share this post


Link to post
Share on other sites
alanjt

That's pretty damn slick, even though that white screen just molested my eyeballs. Is the reasoning for the viewport being 255,255,255 just so it doesn't display in the fake preview, or is there something else?

Share this post


Link to post
Share on other sites
tzframpton
That's pretty damn slick, even though that white screen just molested my eyeballs.
Lol, good to see you still around with the witty comments. :)

 

The white screen does throw people off. Revit was white-only for a long time, until too many people complained and they added white or black. 95% of people still use white, and for good reason. Once you get used to it, it makes total sense to keep it white. Revit's intuitive "live plot preview" in their Views and Sheets is what started it all. "Once you go white, everything's alright".

 

Is the reasoning for the viewport being 255,255,255 just so it doesn't display in the fake preview, or is there something else?
That's exactly right. With Display Plot Styles enabled it's the only way to "hide" the Viewport border without freezing the layer. This way the Viewport edge can still be selected and manipulated without the hassle of on/off or freeze/unfreeze layers. This method works on any user's setup actually - not just the one I demonstrated.

Share this post


Link to post
Share on other sites
Nobull84

 

We finally got our internet service here at work to let me look at your video and I can see what you do. Lineweights are not really anything we use (I wish we did) so I can see now that Lee's awesome lisp won't aid much in what I'm after. Would it be too cumbersome for someone to write a lisp for toggling the "display plot stlyes" and to toggle the screen between black and white?

 

My drawings do look somewhat similar to yours, in that they can get a little busy. I've found a toggle lisp for the B&W screen before but it doesn't help as much without the plot style function. Man I wish I knew how to write this stuff! You guys are definitely at a higher tier than I! Henceforth the "Full Member" titles as opposed to the "Luminous Being" and "Forum Deity" titles.

 

Thanks again for the "luminous" replies :)

-Nobull

Share this post


Link to post
Share on other sites
Nobull84

I have found the two lisps I'm after but with a couple hiccups:

1. When toggling the plot styles, I have to change sheets to get the effects to take place. Any ideas on how to make the changes more immediate?

2. Can these two things: the plot stye and the background color, be changed at the same time with the same command?

3. Can these options be used in a "toggle" fashion? Whereas the same button changes the options back and forth.

 

;;Lisp created by ASMI,3-13-08;;
;;found on Cadtutor.net;;
(defun c:bw()
(vl-load-com)
  (vlax-for l
     (vla-get-Layouts
        (vla-get-ActiveDocument
(vlax-get-acad-object)))
   (vla-put-ShowPlotStyles l :vlax-true)
   ); end vlax-for
 (princ)
 ); end of c:bw
(defun c:cl()
(vl-load-com)
  (vlax-for l
     (vla-get-Layouts
        (vla-get-ActiveDocument
(vlax-get-acad-object)))
   (vla-put-ShowPlotStyles l :vlax-false)
   ); end vlax-for
 (princ)
 ); end of c:cl

;;Lisp found on JTB World;;
;;; BackgroundChanger.LSP ver 1.0
;;; Lets you change the background in a simple way
;;; Works for both model space and paper space but could simply be customized for your need
;;;
;;; By Jimmy Bergmark
;;; Copyright (C) 1997-2004 JTB World, All Rights Reserved
;;; Website: [url="http://www.jtbworld.com"]www.jtbworld.com[/url]
;;; E-mail: [email="info@jtbworld.com"]info@jtbworld.com[/email]
;;; 2003-07-01 - First release
;;; Tested on AutoCAD 2002, 2004, 2005
; Set the background in model and paper space to grey
(defun c:BGGrey ()
 (vl-load-com)
 (setq disp (vla-get-display (vla-get-preferences (vlax-get-acad-object))))
 (setq drafting (vla-get-drafting (vla-get-preferences (vlax-get-acad-object))))
 (vla-put-GraphicsWinModelBackgrndColor disp 5987163)
 (vla-put-GraphicsWinLayoutBackgrndColor disp 5987163)
 (vla-put-LayoutCrosshairColor disp 16777215)
 (vla-put-ModelCrosshairColor disp 16777215)
 (vla-put-AutoTrackingVecColor disp 16777215)
 (vla-put-AutoSnapMarkerColor drafting 2)
 (princ)
)
; Set the background in model and paper space to white
(defun c:BGWhite ()
 (vl-load-com)
 (setq disp (vla-get-display (vla-get-preferences (vlax-get-acad-object))))
 (setq drafting (vla-get-drafting (vla-get-preferences (vlax-get-acad-object))))
 (vla-put-GraphicsWinModelBackgrndColor disp 16777215)
 (vla-put-GraphicsWinLayoutBackgrndColor disp 16777215)
 (vla-put-LayoutCrosshairColor disp 0)
 (vla-put-ModelCrosshairColor disp 0)
 (vla-put-AutoTrackingVecColor disp 0)
 (vla-put-AutoSnapMarkerColor drafting 6)
 (princ)
)
; Set the background in model and paper space to black
(defun c:BGB ()
 (vl-load-com)
 (setq disp (vla-get-display (vla-get-preferences (vlax-get-acad-object))))
 (setq drafting (vla-get-drafting (vla-get-preferences (vlax-get-acad-object))))
 (vla-put-GraphicsWinModelBackgrndColor disp 0)
 (vla-put-GraphicsWinLayoutBackgrndColor disp 0)
 (vla-put-LayoutCrosshairColor disp 16777215)
 (vla-put-ModelCrosshairColor disp 16777215)
 (vla-put-AutoTrackingVecColor disp 16777215)
 (vla-put-AutoSnapMarkerColor drafting 2)
 (princ)
)
; Background toggle between black and white
(defun c:bgt ()
 (vl-load-com)
 (setq disp (vla-get-display (vla-get-preferences (vlax-get-acad-object))))
 (setq drafting (vla-get-drafting (vla-get-preferences (vlax-get-acad-object))))
 (if (= (vlax-variant-value
   (vlax-variant-change-type
     (vla-get-graphicswinmodelbackgrndcolor disp)
     vlax-vblong
   )
 )
 0
     )
   (c:bgwhite)
   (c:bgblack)
 )
 (princ)
)
(princ)

 

Thank you again,

-Nobull

Share this post


Link to post
Share on other sites
BlackBox

Would it be too cumbersome for someone to write a lisp for toggling the "display plot stlyes" and to toggle the screen between black and white?

 

Quickly written... Just be sure to mind the same items I addressed in the other thread about persistent (document saved) settings....

 

(vl-load-com)

(defun c:DisplayPlotStyles (/ *error* acDoc show)

 (defun *error* (msg)
   (setq *ShowPlotStyles*
   (if (= :vlax-true show)
     :vlax-true
     :vlax-false
   )
   )
   (if	acDoc
     (progn
(vla-regen acDoc acallviewports)
(vla-endundomark acDoc)
)
   )
   (cond ((not msg))							; Normal exit
  ((member msg '("Function cancelled" "quit / exit abort")))	; <esc> or (quit)
  ((princ (strcat "\n** Error: " msg " ** ")))			; Fatal error, display it
   )
   (princ)
 )

 (setq	show (if (= :vlax-true *ShowPlotStyles*)
       :vlax-false
       :vlax-true
     )
 )
 (vla-startundomark
   (setq acDoc (vla-get-activedocument (vlax-get-acad-object)))
 )
 (vlax-for x (vla-get-layouts acDoc)
   (vla-put-showplotstyles x show)
 )
 (*error* nil)
)

Share this post


Link to post
Share on other sites
Nobull84

I've been messing with it for a while but I guess my understanding of lisp is still to rudimentary. Is it possible to have the background toggle colors at the same time as your command is entered? If I have to stick with two separate lisps, then no big deal. But that would be the icing on the lisp cake.

 

Tanks,

-Nobull

Share this post


Link to post
Share on other sites
alanjt
Lol, good to see you still around with the witty comments. :)

 

lol. You'll never be completely rid of me. I just need a break from time-to-time.

Share this post


Link to post
Share on other sites
alanjt
I've been messing with it for a while but I guess my understanding of lisp is still to rudimentary. Is it possible to have the background toggle colors at the same time as your command is entered? If I have to stick with two separate lisps, then no big deal. But that would be the icing on the lisp cake.

 

Tanks,

-Nobull

 

Actually, what would be pretty slick, would be to create a reactor that would change all settings based on when the viewport is/not activated.

Activated: plot styles off, black background, lineweights off, etc.

Deactivate: plot styles on, white background, lineweights on.

 

Wouldn't be that hard to do, and most of the coding has already been done. Might have to do this for myself. I suddenly like this idea.

Share this post


Link to post
Share on other sites
Nobull84
Actually, what would be pretty slick, would be to create a reactor that would change all settings based on when the viewport is/not activated.

Activated: plot styles off, black background, lineweights off, etc.

Deactivate: plot styles on, white background, lineweights on.

 

Wouldn't be that hard to do, and most of the coding has already been done. Might have to do this for myself. I suddenly like this idea.

 

I like that idea as well. Hopefully, we can come up with both here maybe? The entire idea behind all this is that we are going paperless, more sooner than later. We have now two 19" monitors and one 42" monitor to replace paper sheets. I am one of the two testers for this and we are moving forward with this. I do notice though that some mistakes are more easily caught after being plotted on paper. I am trying to simulate this print without having to actually plot to the PDF program. That transfer from CAD to the PDF viewer sometimes just takes too long.

 

Any help appreciated as always,

-Nobull

Share this post


Link to post
Share on other sites
tzframpton
Wouldn't be that hard to do, and most of the coding has already been done. Might have to do this for myself. I suddenly like this idea.
I would be highly interested in this as well. My tutorial works good for "me" but not in a collaborative environment with other drafters. If you do develop something I would most certainly be a beneficiary to this customization, as would lots of people I think.

Share this post


Link to post
Share on other sites
alanjt
I would be highly interested in this as well. My tutorial works good for "me" but not in a collaborative environment with other drafters. If you do develop something I would most certainly be a beneficiary to this customization, as would lots of people I think.

The more I think about it, the more I like the idea. I'll work on something in a bit.

Share this post


Link to post
Share on other sites
BlackBox
I would be highly interested in this as well. My tutorial works good for "me" but not in a collaborative environment with other drafters. If you do develop something I would most certainly be a beneficiary to this customization, as would lots of people I think.

 

The more I think about it, the more I like the idea. I'll work on something in a bit.

 

Implementing the code logic, such that the event handler hooks any save to the database, or destruction of the document (where changes are saved), in order to first restore 'correct' settings is the easy part, and can be done with Visual LISP without issue.

 

So too, is it easy to implement a means by which a user can specify persistent settings which predetermine the user's default settings for each-and-every-single setting change, and to also store the 'restored' values prior to save/close if one wants to always have specific setting values when opening a given drawing.

 

It is a great deal harder to account for other code that may or may not change a setting, or LayerTableRecord while this app is enabled, especially for users that aren't yet proficient enough to code this app themselves... But still possible.

 

Some may not appreciate my having done so (and that's perfectly fine), but that's why I went to the extent I did in the other thread... To try and make this app something that many users, and employers could actually use for their daily work, in the real world, on real projects... Both internally, and when sharing drawings externally.

 

 

 

FWIW - I've already coded most of this app in .NET API (each window zoomed out to 26% for clarity):

 

ct_live.plot.preview.jpg

 

Code snippet from my .NET plug-in:

 

// (C) Copyright 2013 by BlackBoxCAD.com
//
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Internal;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.Windows.Data;

using acApp = Autodesk.AutoCAD.ApplicationServices.Application;

using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Reflection;

[assembly: ExtensionApplication(typeof(BlackBox.AutoCAD.LivePlotPreview.Monitor))]

namespace BlackBox.AutoCAD.LivePlotPreview
{
   class Monitor : IExtensionApplication
   {
       //private bool layerTableIsWatched;
       //private bool layerTableHasChanged;
       //private bool reconcileNeeded;
       private bool layerCommandIsActive;
       private bool layersChanged;
       private bool layoutSwitching;
       private DataItemCollection layers;
       private DocumentCollection acDocs;
       private int fieldDisplay;
       private int layLockFadeCtl;
       private int lwDisplay;
       private int pdmode;
       private int xDwgFadeCtl;
       private ObjectIdCollection layerIdsNotPlottable;
       private ObjectIdCollection layerIdsPlottable;
       private string newLayout;


       void IExtensionApplication.Initialize()
       {
           acApp.SystemVariableChanged += onSystemVariableChanged;
           acApp.DocumentManager.DocumentCreated += onDocumentCreated;
           acApp.DocumentManager.DocumentToBeDestroyed += onDocumentToBeDestroyed;

           acDocs = acApp.DocumentManager;

           //Setup(acApp.DocumentManager.MdiActiveDocument);
           WatchLayers();
       }
       void IExtensionApplication.Terminate()
       {
       }
       [CommandMethod("FOO")]
       void FOO()
       {
           Document doc = Application.DocumentManager.MdiActiveDocument;
           Editor ed = doc.Editor;
           PromptSelectionResult psr = ed.GetSelection();

           if (psr.Status == PromptStatus.OK)
           {
               List<string> layers = new List<string>();
               ObjectId[] ids = psr.Value.GetObjectIds();

               using (Transaction tr =
                   doc.Database.TransactionManager.StartOpenCloseTransaction())
               {
                   foreach (ObjectId id in ids)
                   {
                       Entity ent = (Entity)tr.GetObject(id, OpenMode.ForRead);
                       string layerName = ent.Layer;

                       if (!layers.Contains(layerName))
                       {
                           layers.Add(layerName);
                       }
                   }

                   int i = layers.Count;

                   ed.WriteMessage(
                       "\nYou selected {0}:", i, i == 1 ? "this layer" : "these layers");

                   layers.Sort();

                   foreach (string layerName in layers)
                   {
                       ed.WriteMessage("\n{0}", layerName);
                   }

                   ed.WriteMessage("\n");

                   tr.Commit();
               }
           }
       }
       int GetVar(string var)
       {
           return Convert.ToInt32(acApp.GetSystemVariable(var));
       }
       void onCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
       {
           if (SwitchingToLayout() &&
               e.Action == NotifyCollectionChangedAction.Add &&
               e.NewStartingIndex == -1)
           {
               if (layersChanged)
               {
                   //UpdateLayers();
                   UpdateViewports();
               }
               else
               {
                   layersChanged = true;
               }
           }
       }
       void onCollectionItemsChanged(object sender, NotifyCollectionItemsChangedEventArgs e)
       {
           if (layersChanged)
           {
               //UpdateLayers();
               UpdateViewports();
           }
           else
           {
               layersChanged = true;

               if (!layerCommandIsActive)
               {
                   //UpdateLayers();
                   UpdateViewports();
               }
           }
       }
       void onCommandEnded(object sender, CommandEventArgs e)
       {
           Document doc = acDocs.MdiActiveDocument;
           doc.CommandCancelled -= onCommandEnded;
           doc.CommandEnded -= onCommandEnded;
           doc.CommandFailed -= onCommandEnded;

           layers.CollectionChanged += onCollectionChanged;
           layers.ItemsChanged += onCollectionItemsChanged;

           doc.Editor.WriteMessage(
                   "\n[LivePlotPreview] : onCommandEnded({0}) \n",
                   e.GlobalCommandName.ToUpper());

           if (layersChanged)
           {
               //UpdateLayers();
               UpdateViewports();
           }
           else
           {
               layersChanged = true;
           }
           
           layerCommandIsActive = false;
       }

       // ...

   }
}

 

... As of 2013-11-09, I'm at a stopping point with certain API features not yet being exposed to even .NET API according to my friends at ADN that review, and have published my Exchange Apps.

 

Specifically, the ability to properly handle any *Layer* change(s) from both Command calls, Layer Manager, and other code (such as Scripts, Macros, LISP, etc.) made while this app is enabled, and subsequently correctly account for which VPLayers are VPFrozen, VPThawed, etc. within each-and-every-single PViewport, on each-and-every-single Layout.

 

Even if only accounting for a single Layout, and it's subsequent multiple PViewports, it is quite the challenge given the API feature relegation, and I've tried monitoring Application Events, Collection Events, Command Events, Document Events, Layout Events, Point Filter Events, System Variable Events, and even the UIBinding.Collection only to reach 'close' to what I was after.

 

[Edit] - ... And ADN staff informing me that this isn't yet possible, and they're paid to tell me the truth (thank you ADN membership).

 

... This really is a great idea, and I'm very anxious myself to contribute to it's successful release, if you couldn't tell by the +/-550 lines of C# pictured above.

 

 

 

Unfortunately, it appears that this app shall fail to properly account for all potentialities until Autodesk exposed the complete roster of API features specifically, and implicitly required (and those are just the one's I've identified to-date; there may be others I am currently unaware of).

Share this post


Link to post
Share on other sites

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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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