Display Plot Styles?

Display Plot Styles?

Anonymous
Not applicable
1,342 Views
4 Replies
Message 1 of 5

Display Plot Styles?

Anonymous
Not applicable

I'm trying to develop an app that if possible will check if the "Display plot styles" is turned on in the drawing's "page setup". I've been looking through the "Developer and ObjectARX Help" for any reference to it that I could find. I'm wondering if its even possible to accomplish this using .NET ?

 

Any help would be appreciated!

0 Likes
Accepted solutions (1)
1,343 Views
4 Replies
  • .net
Replies (4)
Message 2 of 5

jabowabo
Mentor
Mentor
Accepted solution
        public static bool GetShowPlotStyles(ref bool doShowPlotStyles)
        {
            Document doc = AcadApp.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;

            bool didSuceed = false;

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                try
                {
                    // Get the Layout Manager
                    LayoutManager layoutMgr = LayoutManager.Current;
                    // get current layout
                    Layout layout = (Layout)tr.GetObject(layoutMgr.GetLayoutId(layoutMgr.CurrentLayout), OpenMode.ForRead);

                    // Get the PlotInfo from the layout
                    PlotInfo plotInfo = new PlotInfo();
                    plotInfo.Layout = layout.ObjectId;

                    // Get a copy of the PlotSettings from the layout
                    PlotSettings ps = new PlotSettings(layout.ModelType);
                    ps.CopyFrom(layout);
                    // get the setting
                    doShowPlotStyles = ps.ShowPlotStyles;
                    didSuceed = true;
                }
                catch
                {
                }

                tr.Commit();
            }// End of transaction

            return didSuceed;
        }
0 Likes
Message 3 of 5

Anonymous
Not applicable

Thank you for the quick reply! I over looked that one in the Developer Guide! Thank you!!!!

0 Likes
Message 4 of 5

rexhaujm
Explorer
Explorer

I really wish this was a user setting instead of a file/tab setting.  we have some users who like it and some who hate it.

0 Likes
Message 5 of 5

jabowabo
Mentor
Mentor

I made a LISP command to toggle it with a short command (PST). It's not quite what you want, but it's a quick way to switch back and forth.

;  Plot Style Toggle
(defun C:PST (              
          /
          acadDocument      ; Holds reference to the active AutoCAD drawing object.
          acadLayout        ; Holds reference to the active Layout object.
          acadObject        ; Holds reference to the AutoCAD object.
          showPStyles       ; Holds current status of PlotStyle display on the active Layout.
         ) ;_ End arguments & local variables.
  (cond                 ; Cond A
    ((= (getvar "TILEMODE") 1)      ; Model tab is active, abort command.
      (alert
    (strcat
      "C:PST is meant for use on a Layout tab, not on the Model tab."
      "\nPlease change to a Layout tab and try again."
    ) ;_ End strcat.
      ) ;_ End alert.
    ) ;_ End condition A1.
    (T                  ; Condition A2.
     (vl-load-com)          ; Load "vl" functions, if not already loaded.
     (setq
       acadObject     (vlax-get-acad-object)
       acadDocument   (vlax-get-property acadObject 'ActiveDocument)
       acadLayout     (vlax-get-property acadDocument 'ActiveLayout)
       showPStyles (vlax-get-property acadLayout 'ShowPlotStyles)
     ) ;_ End setq.
     (if (= showPStyles :vlax-true)
       (progn
     (vlax-put-property acadLayout 'ShowPlotStyles :vlax-false)
     (prompt "\nThe display of plot styles has been turned off. ")
       ) ;_ End progn.
       (progn
     (vlax-put-property acadLayout 'ShowPlotStyles :vlax-true)
     (prompt "\nThe display of plot styles has been turned on. ")
       ) ;_ End progn.
     ) ;_ End if.
     (vlax-release-object acadLayout)
     (vlax-release-object acadDocument)
     (vlax-release-object acadObject)
     (command "_.REGENALL")     ; Regenerate the screen graphics.
    ) ;_ End condition A2.
  ) ;_ End cond A.
  (prin1)
) ;_ End C:PST.

  

0 Likes