本文整理汇总了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;
}
示例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();
}
}