Author Topic: Secrets of the ShadeplotType "Legacy hidden" EXPOSED!  (Read 3506 times)

0 Members and 1 Guest are viewing this topic.

trackhack

  • Guest
Secrets of the ShadeplotType "Legacy hidden" EXPOSED!
« on: November 22, 2011, 03:36:09 AM »
Can someone give me an example of how to set a Floating Viewport to Shadeplot = "Legacy Hidden"? It would appear that (in C# ) it can only be set to:
AsDisplayed
Hidden
Rendered
RenderPreset
VisualStyle and
Wireframe

So, how about the rest of the styles:
Legacy wireframe
Legacy hidden
Conceptual
realistic
Shaded
Shaded and edges
Shades of grey
X-Ray

eg code for AutoCAD 2011

public static void ViewportCreate()
      {
      }      
      
      [CommandMethod("CreateFloatingViewport")]
      public static void CreateFloatingViewport()
      {

        // Get the current document and database, and start a transaction
       Document acDoc = AcadApp.DocumentManager.MdiActiveDocument;
       Database acCurDb = acDoc.Database;

         using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
           {
            // Open the Block table for read
            BlockTable acBlkTbl;
            acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,OpenMode.ForRead) as BlockTable;
      
            // Open the Block table record Paper space for write
            BlockTableRecord acBlkTblRec;
            acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.PaperSpace], OpenMode.ForWrite) as BlockTableRecord;
      
            // Switch to the previous Paper space layout
            AcadApp.SetSystemVariable("TILEMODE", 0);
            acDoc.Editor.SwitchToPaperSpace();

            // Create a Viewport
            Viewport acVport = new Viewport();
            acVport.SetDatabaseDefaults();
            acVport.CenterPoint = new Point3d(3.25, 3, 0);
            acVport.Width = 6;
            acVport.Height = 5;
      
            // Add the new object to the block table record and the transaction
            acBlkTblRec.AppendEntity(acVport);
            acTrans.AddNewlyCreatedDBObject(acVport, true);

                      acVport.setShadePlot(some method?)

      
            // Enable the viewport
            acVport.On = true;         
               
            // Save the new objects to the database
            acTrans.Commit();
           }
      }

Cheers
Rod

Bryco

  • Water Moccasin
  • Posts: 1883
Re: Secrets of the ShadeplotType "Legacy hidden" EXPOSED!
« Reply #1 on: November 22, 2011, 05:02:38 PM »

You may be out of luck. I presume w/ this you can set all but the legacy

Code: [Select]

         [CommandMethod("CreateFloatingViewport")]
      public static void CreateFloatingViewport()
      {

        // Get the current document and database, and start a transaction
       Document acDoc = acadApp.DocumentManager.MdiActiveDocument;
       Database db = acDoc.Database;
       Editor ed = acDoc.Editor;
         using (Transaction tr = db.TransactionManager.StartTransaction())
           {
            // Open the Block table for read
            BlockTable acBlkTbl;
            acBlkTbl = tr.GetObject(db.BlockTableId,OpenMode.ForRead) as BlockTable;
     
            // Open the Block table record Paper space for write
            BlockTableRecord acBlkTblRec;
            acBlkTblRec = tr.GetObject(acBlkTbl[BlockTableRecord.PaperSpace], OpenMode.ForWrite) as BlockTableRecord;
     
            // Switch to the previous Paper space layout
            acadApp.SetSystemVariable("TILEMODE", 0);
            acDoc.Editor.SwitchToPaperSpace();

            // Create a Viewport
            Viewport acVport = new Viewport();
            acVport.SetDatabaseDefaults();
            acVport.CenterPoint = new Point3d(3.25, 3, 0);
            acVport.Width = 6;
            acVport.Height = 5;
           
            DBVisualStyle vs=new DBVisualStyle();
            DBDictionary nod = tr.GetObject(db.NamedObjectsDictionaryId, OpenMode.ForRead) as DBDictionary;
            DBDictionary dic = tr.GetObject(nod.GetAt("ACAD_VISUALSTYLE"), OpenMode.ForRead) as DBDictionary;
            foreach (DBDictionaryEntry entry in dic)
            {
                ed.WriteMessage(Environment.NewLine + "name=" + entry.Key + " objectid=" + entry.Value.ToString());
            }

            ObjectId vsId = dic.GetAt("Linepattern");
                     
            acVport.SetShadePlot(ShadePlotType.VisualStyle, vsId);

            // Add the new object to the block table record and the transaction
            acBlkTblRec.AppendEntity(acVport);
            tr.AddNewlyCreatedDBObject(acVport, true);
            // Enable the viewport
            acVport.On = true;         
               
             PromptEntityOptions peo = new PromptEntityOptions("Select an entity:");
            peo.SetRejectMessage("Must be a vp:");
            peo.AddAllowedClass(typeof(Viewport), true);
            PromptEntityResult per = ed.GetEntity(peo);

            if (per.Status != PromptStatus.OK) return;

            Viewport vp = tr.GetObject(per.ObjectId, OpenMode.ForRead) as Viewport;
            //Util.Debug.Print(vp.VisualStyleId.ToString());
            ed.WriteMessage(Environment.NewLine + vp.ShadePlotId.ToString());
            ed.WriteMessage(Environment.NewLine + vp.ShadePlot.ToString());

            // Save the new objects to the database
            tr.Commit();
           }
      }

My print out is
Command: CREATEFLOATINGVIEWPORT
name=2dWireframe objectid=(2129252152)
name=Basic objectid=(2129252144)
name=Brighten objectid=(2129252200)
name=ColorChange objectid=(2129252232)
name=Conceptual objectid=(2129252176)
name=Dim objectid=(2129252192)
name=EdgeColorOff objectid=(2129257512)
name=Facepattern objectid=(2129252224)
name=Flat objectid=(2129252112)
name=FlatWithEdges objectid=(2129252120)
name=Gouraud objectid=(2129252128)
name=GouraudWithEdges objectid=(2129252136)
name=Hidden objectid=(2129252168)
name=JitterOff objectid=(2129257496)
name=Linepattern objectid=(2129252216)
name=OverhangOff objectid=(2129257504)
name=Realistic objectid=(2129252184)
name=Shaded objectid=(2129257616)
name=Shaded with edges objectid=(2129257608)
name=Shades of Gray objectid=(2129257584)
name=Sketchy objectid=(2129257592)
name=Thicken objectid=(2129252208)
name=Wireframe objectid=(2129252160)
name=X-Ray objectid=(2129257600)Regenerating layout.
Regenerating model.
Select an entity:
(0)
Hidden

with a null object id for the  vp I picked that had been manually configured to legacy hidden (That's the one I use as well)

Bryco

  • Water Moccasin
  • Posts: 1883
Re: Secrets of the ShadeplotType "Legacy hidden" EXPOSED!
« Reply #2 on: November 22, 2011, 08:02:10 PM »
ObjectId vsId = dic.GetAt("Hidden");
            acVport.SetShadePlot(ShadePlotType.Hidden, vsId);
appears to make legacy hidden

trackhack

  • Guest
Re: Secrets of the ShadeplotType "Legacy hidden" EXPOSED!
« Reply #3 on: November 22, 2011, 08:06:40 PM »
Thanks Bryco
I just discovered the same thing too.

Hidden = Legacy hidden.

Rod