Esempio n. 1
0
    //  added. list all the disp set registered.
    private void ListDisplaySets()
    {
        Autodesk.AutoCAD.EditorInput.Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
        ed.WriteMessage("===================================\n");
        ed.WriteMessage("  Currently Registerd Display Set  \n");
        ed.WriteMessage("===================================\n");

        Database    db    = Application.DocumentManager.MdiActiveDocument.Database;
        Transaction trans = db.TransactionManager.StartTransaction();

        // get the dictionary.
        DictionaryDisplaySet dictDispSet = new DictionaryDisplaySet(db, false);

        ed.WriteMessage("Current # of display set = " + dictDispSet.Records.Count.ToString() + "\n");

        try
        {
            // loop throught it and print out the name.
            foreach (ObjectId id in dictDispSet.Records)
            {
                DisplaySet dispSet = trans.GetObject(id, OpenMode.ForRead) as DisplaySet;
                ListDisplaySet(dispSet);
            }
        }
        catch (System.Exception)
        { trans.Abort(); }
        finally
        { trans.Dispose(); }
    }
Esempio n. 2
0
    //  create a display config with a little more information filled.
    private DisplayConfiguration CreateDisplayConfig()
    {
        Database    db    = Application.DocumentManager.MdiActiveDocument.Database;
        Transaction trans = db.TransactionManager.StartTransaction();

        DisplayRepresentationManager drm      = new DisplayRepresentationManager(db);
        ObjectId             currentDisConfId = drm.DisplayConfigurationIdForCurrentViewport;
        DisplayConfiguration currentDisConf   = trans.GetObject(currentDisConfId, OpenMode.ForRead) as DisplayConfiguration;

        DisplayConfiguration dc = new DisplayConfiguration();

        try
        {
            DisplaySet ds = new DisplaySet();
            ds.SetToStandard(db);
            ds.SubSetDatabaseDefaults(db);

            //  top
            dc.ViewDependentCombinations.Add(new ViewDependentCombination(new Vector3d(0, 0, 1), DictionaryDisplaySet.GetStandardPlanId(db)));
            //  for bottom. No DictionaryDisplaySet.GetStandardXxxId for Plan Diagnostic, so get it from the name.
            ObjectId id = DictionaryDisplaySet.GetStandardSet("Plan Diagnostic", db);
            if (id != ObjectId.Null)
            {
                dc.ViewDependentCombinations.Add(new ViewDependentCombination(new Vector3d(0, 0, -1), id));
            }
            else  // if not found, let's use Reflected.
            {
                dc.ViewDependentCombinations.Add(new ViewDependentCombination(new Vector3d(0, 0, -1), DictionaryDisplaySet.GetStandardReflectedId(db)));  //buttom
            }
            dc.ViewDependentCombinations.Add(new ViewDependentCombination(new Vector3d(-1, 0, 0), DictionaryDisplaySet.GetStandardSectionElevId(db))); // left
            dc.ViewDependentCombinations.Add(new ViewDependentCombination(new Vector3d(1, 0, 0), DictionaryDisplaySet.GetStandardSectionElevId(db)));  // right
            dc.ViewDependentCombinations.Add(new ViewDependentCombination(new Vector3d(0, -1, 0), DictionaryDisplaySet.GetStandardSectionElevId(db))); //  front
            dc.ViewDependentCombinations.Add(new ViewDependentCombination(new Vector3d(0, 1, 0), DictionaryDisplaySet.GetStandardSectionElevId(db)));  // back

            //  try adding DefaultViewDependentViewSet here.
            dc.DefaultViewDependentViewSet = DictionaryDisplaySet.GetStandardModelId(db);

            DictionaryDisplayConfiguration dictDisplayConfigs = new DictionaryDisplayConfiguration(db);
            string newName = GetNewName();
            dictDisplayConfigs.AddNewRecord(newName, dc);
            trans.AddNewlyCreatedDBObject(dc, true);
            trans.Commit();
        }
        catch (System.Exception)
        {
            trans.Abort();
        }
        finally
        {
            trans.Dispose();
        }
        return(dc);
    }
Esempio n. 3
0
    ////////////////////////////
    //// Display Props
    //// list all the disp reps for the door for the current view port
    ////////////////////////////

    private void DisplayProps()
    {
        Database             db    = Application.DocumentManager.MdiActiveDocument.Database;
        TransactionManager   tm    = db.TransactionManager;
        Transaction          trans = db.TransactionManager.StartTransaction();
        BlockTable           bt    = (BlockTable)tm.GetObject(db.BlockTableId, OpenMode.ForRead, false);
        BlockTableRecord     btr   = (BlockTableRecord)tm.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite, false);
        DictionaryDisplaySet dds   = new DictionaryDisplaySet(db, false);

        try
        {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            PromptEntityOptions optEnt = new PromptEntityOptions("Select an AEC door entity");
            optEnt.SetRejectMessage("Selected entity is NOT an AEC door entity, try again...");
            optEnt.AddAllowedClass(typeof(Autodesk.Aec.Arch.DatabaseServices.Door), false);  // Geo is the base class of AEC entities.

            PromptEntityResult resEnt = ed.GetEntity(optEnt);
            if (resEnt.Status != PromptStatus.OK)
            {
                ed.WriteMessage("Selection error - aborting" + "\n");
                return;
            }

            Autodesk.Aec.Arch.DatabaseServices.Door door = trans.GetObject(resEnt.ObjectId, OpenMode.ForRead) as Door;
            ed.WriteMessage("You have selected an " + door.GetRXClass().Name + "\n");

            //  get its style
            Autodesk.Aec.Arch.DatabaseServices.DoorStyle doorstyle = trans.GetObject(door.StyleId, OpenMode.ForRead) as DoorStyle;

            ObjectId doorId = door.ObjectId;
            DisplayRepresentationManager drm = new DisplayRepresentationManager(db);

            ObjectIdCollection    ids = drm.GetDisplayRepresentationIdsFromCurrentViewport(door.GetRXClass());
            DisplayRepresentation dr  = null;
            Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("=======================================\n");
            Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("Get all the Display Representations work with the door for current view port\n");
            Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("=======================================\n");
            Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("door disp rep count = " + ids.Count + "\n");

            foreach (ObjectId id in ids)
            {
                dr = trans.GetObject(id, OpenMode.ForRead) as DisplayRepresentation;

                Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("Display Representation Name: " + dr.Name + " Display Name: " + dr.DisplayName + "\n");

                Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("Display Representation Name: " + dr.Name + "Display Name" + dr.DisplayName + "\n");
                DisplayProperties dps     = null;
                RXClass           rcProps = dr.DisplayPropertiesClass;
                Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("Display Props Class: " + rcProps.Name + "\n");

                //  find override at instance level.
                ObjectId overId = dr.FindDisplayPropertiesOverride(door);
                if (overId != ObjectId.Null)
                {
                    dps = trans.GetObject(overId, OpenMode.ForRead) as DisplayProperties;
                    Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("Element override Display Props Name: " + dps.Name + "Display Name" + dps.DisplayName + "\n");
                    continue;
                }
                ObjectId overstyleId = dr.FindDisplayPropertiesOverride(doorstyle);
                if (overstyleId != ObjectId.Null)
                {
                    dps = trans.GetObject(overstyleId, OpenMode.ForRead) as DisplayProperties;
                    Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("Style override Style Display Props Name: " + dps.Name + "Display Name" + dps.DisplayName + "\n");
                    continue;
                }
                ObjectId defaultDpsId = dr.DefaultDisplayPropertiesId;
                if (!defaultDpsId.IsNull)
                {
                    dps = trans.GetObject(defaultDpsId, OpenMode.ForRead) as DisplayProperties;
                    Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("Default Display Props Name: " + dps.Name + "Display Name" + dps.DisplayName + "\n");
                }
            }
            trans.Commit();
        }
        catch (System.Exception)
        {
            trans.Abort();
        }
        finally
        {
            trans.Dispose();
        }
        return;
    }