Esempio n. 1
0
    private void ListDisplayRep(DisplayRepresentation dr)
    {
        Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("DisplayRep Name: " + dr.Name + "\n");
        Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("DisplayRep Work With: " + dr.WorksWith.Name + "\n");

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

        return;
    }
Esempio n. 2
0
    ////////////////////////////
    //// Display Rep
    ////
    //// list all the display reps for MassElem and MassGroup for the current display config.
    ////////////////////////////

    private void DisplayReps()
    {
        Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("\n====================================================\n");
        Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("Get All the AecDbMassElem/Massgroup Display Reps for the current display config\n");
        Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("====================================================\n");

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

        Autodesk.AutoCAD.EditorInput.Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;

        DisplaySet         ds  = new DisplaySet();
        ObjectIdCollection ids = DisplayRepresentationManager.GetActiveDisplayRepresentationSets(db);

        ed.WriteMessage("# of active display sets = " + ids.Count + "\n");

        DisplaySet acds = new DisplaySet();

        try
        {
            //  loop through the active disp sets (i.e., disp sets of active dis confid.)
            foreach (ObjectId id in ids)
            {
                acds = trans.GetObject(id, OpenMode.ForRead) as DisplaySet;
                foreach (ObjectId drid in acds.DisplayRepresentationIds)
                {
                    DisplayRepresentation dr = trans.GetObject(drid, OpenMode.ForRead) as DisplayRepresentation;
                    dr = trans.GetObject(drid, OpenMode.ForRead) as DisplayRepresentation;
                    RXClass rc = dr.WorksWith;
                    if (rc.Name == "AecDbMassElem" || rc.Name == "AecDbMassGroup")
                    {
                        if (ds.DisplayRepresentationIds.Contains(drid))
                        {
                            continue;
                        }
                        else
                        {
                            ds.DisplayRepresentationIds.Add(drid);
                            ListDisplayRep(dr);
                        }
                    }
                }
            }
            trans.Commit();
        }
        catch (System.Exception)
        {
            trans.Abort();
        }
        finally
        {
            trans.Dispose();
        }
        return;
    }
Esempio n. 3
0
    ////////////////////////////
    //// MATERIALS
    ////////////////////////////

    private void DisplayPropsMaterial()
    {
        Database           db    = Application.DocumentManager.MdiActiveDocument.Database;
        TransactionManager tm    = db.TransactionManager;
        Transaction        trans = db.TransactionManager.StartTransaction();

        try
        {
            Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("=======================================\n");
            Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("Get all the Display Properties and the Display components works with AecDbMaterialDef in ZAxis view\n");
            Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("=======================================\n");

            DisplayRepresentationManager drm = new DisplayRepresentationManager(db);
            Viewport         vport           = new Viewport();
            BlockTableRecord btr             = (BlockTableRecord)trans.GetObject(db.CurrentSpaceId, OpenMode.ForWrite, false);
            btr.AppendEntity(vport);
            trans.AddNewlyCreatedDBObject(vport, true);
            ObjectId viewportId = vport.ObjectId;

            Vector3d   viewDirection = Vector3d.ZAxis;
            ObjectId   setId         = drm.DisplayRepresentationSet(viewportId, viewDirection);
            DisplaySet ds            = trans.GetObject(setId, OpenMode.ForWrite) as DisplaySet;
            DisplayRepresentationIdCollection repIds = ds.DisplayRepresentationIds;
            DisplayRepresentation             dr     = null;
            foreach (ObjectId repId in repIds)
            {
                dr = trans.GetObject(repId, OpenMode.ForRead) as DisplayRepresentation;
                if (dr.WorksWith.Name == "AecDbMaterialDef")
                {
                    ObjectId          dpId = dr.DefaultDisplayPropertiesId;
                    DisplayProperties dp   = trans.GetObject(dpId, OpenMode.ForWrite) as DisplayProperties;
                    ListDisplayProperties(dp);
                }
            }
        }
        catch (System.Exception e)
        {
            Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage(e.Message + "\n");
            trans.Abort();
        }
        finally
        {
            trans.Dispose();
        }
        return;
    }
Esempio n. 4
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;
    }