当前位置: 首页>>代码示例>>C#>>正文


C# Space.SetDatabaseDefaults方法代码示例

本文整理汇总了C#中Space.SetDatabaseDefaults方法的典型用法代码示例。如果您正苦于以下问题:C# Space.SetDatabaseDefaults方法的具体用法?C# Space.SetDatabaseDefaults怎么用?C# Space.SetDatabaseDefaults使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Space的用法示例。


在下文中一共展示了Space.SetDatabaseDefaults方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Create

        public static DBObject Create(this Grevit.Types.Room r, Transaction tr)
        {
            DictionarySpaceStyle ss = new DictionarySpaceStyle(Command.Database);



            try
            {
                BlockTable bt = (BlockTable)tr.GetObject(Command.Database.BlockTableId, OpenMode.ForRead);
                BlockTableRecord ms = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);

                Polyline acPoly = new Polyline();
                acPoly.SetDatabaseDefaults();

                int i = 0;
                foreach (Grevit.Types.Point p in r.points)
                {
                    acPoly.AddVertexAt(i, new Point2d(p.x, p.y), 0, 0, 0);
                    i++;
                }
                acPoly.Closed = true;
                ms.AppendEntity(acPoly);
                tr.AddNewlyCreatedDBObject(acPoly, true);


                Autodesk.Aec.Geometry.Profile myProfile = Autodesk.Aec.Geometry.Profile.CreateFromEntity(acPoly, Command.Editor.CurrentUserCoordinateSystem);

                Space space;


                bool newEnt = false;

                if (Command.existing_objects.ContainsKey(r.GID))
                {
                    space = (Space)tr.GetObject(Command.existing_objects[r.GID], OpenMode.ForWrite);
                }
                else
                {
                    newEnt = true;
                    space = new Space();
                    space.SetDatabaseDefaults(Command.Database);
                    space.SetToStandard(Command.Database);
                }

                space.Associative = r.associative;
                space.Name = r.name;

                space.GeometryType = SpaceGeometryType.TwoD;
                space.Location = new Point3d(0, 0, 0);
                space.SetBaseProfile(myProfile, Matrix3d.Identity);

                LayerTable lt = (LayerTable)tr.GetObject(Command.Database.LayerTableId, OpenMode.ForRead);
                if (r.TypeOrLayer != "") { if (lt.Has(r.TypeOrLayer)) space.LayerId = lt[r.TypeOrLayer]; }
                if (ss.Has(r.FamilyOrStyle, tr)) space.StyleId = ss.GetAt(r.FamilyOrStyle);

                if (newEnt)
                {
                    ms.AppendEntity(space);
                    tr.AddNewlyCreatedDBObject(space, true);
                    ms.Dispose();
                }
                return space;

            }

            catch (Autodesk.AutoCAD.Runtime.Exception e)
            {
            }

            return null;
        }
开发者ID:samuto,项目名称:Grevit,代码行数:71,代码来源:CreateExtension.cs

示例2: Create

        public static void Create(Grevit.Types.Room r)
        {
            Database db = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database;
            Transaction tr = db.TransactionManager.StartTransaction();
            Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
            DictionarySpaceStyle ss = new DictionarySpaceStyle(db);

            try
            {
                BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
                BlockTableRecord ms = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);

                Polyline acPoly = new Polyline();
                acPoly.SetDatabaseDefaults();

                int i = 0;
                foreach (Grevit.Types.Point p in r.points)
                {
                    acPoly.AddVertexAt(i, new Point2d(p.x, p.y), 0, 0, 0);
                    i++;
                }
                acPoly.Closed = true;
                ms.AppendEntity(acPoly);
                tr.AddNewlyCreatedDBObject(acPoly, true);

                Autodesk.Aec.Geometry.Profile myProfile = Autodesk.Aec.Geometry.Profile.CreateFromEntity(acPoly, ed.CurrentUserCoordinateSystem);

                Space space;

                bool newEnt = false;

                if (Command.existing_objects.ContainsKey(r.GID))
                {
                    space = (Space)tr.GetObject(Command.existing_objects[r.GID], OpenMode.ForWrite);
                }
                else
                {
                    newEnt = true;
                    space = new Space();
                    space.SetDatabaseDefaults(db);
                    space.SetToStandard(db);
                }

                space.Associative = r.associative;
                space.Name = r.name;

                space.GeometryType = SpaceGeometryType.TwoD;
                space.Location = new Point3d(0, 0, 0);
                space.SetBaseProfile(myProfile, Matrix3d.Identity);

                LayerTable lt = (LayerTable)tr.GetObject(db.LayerTableId, OpenMode.ForRead);
                if (r.TypeOrLayer != "") { if (lt.Has(r.TypeOrLayer)) space.LayerId = lt[r.TypeOrLayer]; }
                if (ss.Has(r.FamilyOrStyle, tr)) space.StyleId = ss.GetAt(r.FamilyOrStyle);

                if (newEnt)
                {
                    ms.AppendEntity(space);
                    tr.AddNewlyCreatedDBObject(space, true);
                }
                AddXData(r, space);
                writeProperties(space, r.parameters, tr);
                storeID(r, space.Id);
                tr.Commit();
            }

            catch (Autodesk.AutoCAD.Runtime.Exception e)
            {
                ed.WriteMessage(e.Message);
                tr.Abort();
            }

            finally
            {
                tr.Dispose();
            }
        }
开发者ID:bbrangeo,项目名称:Grevit,代码行数:76,代码来源:CreateExtension.cs


注:本文中的Space.SetDatabaseDefaults方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。