创建实体填充区域
 
 

You can create triangular and quadrilateral areas filled with a color. When creating filled areas, set the FILLMODE system variable to off to improve performance and back on once the fills have been created.

用户可以创建用某种颜色填充的三角形和四边形的区域。要更快地得到结果,请在关闭 FILLMODE 系统变量时创建这些区域,然后再打开 FILLMODE 以填充完成的区域。

When you create a quadrilateral solid-filled area, the sequence of the third and fourth points determines its shape. Compare the following illustrations:

创建四边形实体填充区域时,第三点和第四点的次序将决定其形状。请比较下面的图解:

The first two points define one edge of the polygon. The third point is defined diagonally opposite from the second. If the fourth point is set equal to the third point, then a filled triangle is created.

前两点定义了多边形的一条边。第三点定义在第二点的对角处。如果第四点设置为等于第三点,则会创建一个填充三角形。

For more information about filling solids, see “Create Solid-Filled Areas” in the AutoCAD User's Guide.

更多关于直译实体的信息,请参见AutoCAD 用户手册中的“创建实体填充区域”部分。

创建一个实体填充对象

The following example creates a quadrilateral solid (bow-tie) in Model space using the coordinates (0, 0, 0), (5, 0, 0), (5, 8, 0), and (0, 8, 0). It also creates a quadrilateral solid in a rectangular shape using the coordinates (10, 0, 0), (15, 0, 0), (10, 8, 0), and (15, 8, 0).

下面示例使用坐标 (0,0,0)、(5,0,0)、(5,8,0) 和 (0,8,0) 在模型空间中创建四边形实体(蝴蝶结)。它也使用坐标(10, 0, 0), (15, 0, 0), (10, 8, 0)和 (15, 8, 0)创建一个矩形形状的四边形实体。

VB.NET

Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Geometry
 
<CommandMethod("Add2DSolid")> _
Public Sub Add2DSolid()
  '' 获得当前文档和数据库   Get the current document and database
  Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
  Dim acCurDb As Database = acDoc.Database
 
  ''启动一个事务   Start a transaction
  Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
 
      '' 以只读方式打开块表   Open the Block table for read
      Dim acBlkTbl As BlockTable
      acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead)
 
      '' 以写方式打开模型空间块表记录   Open the Block table record Model space for write
      Dim acBlkTblRec As BlockTableRecord
      acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), _
                                      OpenMode.ForWrite)
 
      '' Create a quadrilateral (bow-tie) solid in Model space
      Dim ac2DSolidBow As Solid = New Solid(New Point3d(0, 0, 0), _
                                            New Point3d(5, 0, 0), _
                                            New Point3d(5, 8, 0), _
                                            New Point3d(0, 8, 0))
 
      ac2DSolidBow.SetDatabaseDefaults()
 
      '' 添加新对象到块表记录和事务中   Add the new object to the block table record and the transaction
      acBlkTblRec.AppendEntity(ac2DSolidBow)
      acTrans.AddNewlyCreatedDBObject(ac2DSolidBow, True)
 
      '' Create a quadrilateral (square) solid in Model space
      Dim ac2DSolidSqr As Solid = New Solid(New Point3d(10, 0, 0), _
                                            New Point3d(15, 0, 0), _
                                            New Point3d(10, 8, 0), _
                                            New Point3d(15, 8, 0))
 
      ac2DSolidSqr.SetDatabaseDefaults()
 
      '' 添加新对象到块表记录和事务中   Add the new object to the block table record and the transaction
      acBlkTblRec.AppendEntity(ac2DSolidSqr)
      acTrans.AddNewlyCreatedDBObject(ac2DSolidSqr, True)
 
      '' 保存新对象到数据库中   Save the new object to the database
      acTrans.Commit()
  End Using
End Sub

C#

using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
 
[CommandMethod("Add2DSolid")]
public static void Add2DSolid()
{
  // 获得当前文档和数据库   Get the current document and database
  Document acDoc = Application.DocumentManager.MdiActiveDocument;
  Database acCurDb = acDoc.Database;
 
  // 启动一个事务  Start a transaction
  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 Model space for write
      BlockTableRecord acBlkTblRec;
      acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],
                                      OpenMode.ForWrite) as BlockTableRecord;
 
      // Create a quadrilateral (bow-tie) solid in Model space
      Solid ac2DSolidBow = new Solid(new Point3d(0, 0, 0),
                                     new Point3d(5, 0, 0),
                                     new Point3d(5, 8, 0),
                                     new Point3d(0, 8, 0));
 
      ac2DSolidBow.SetDatabaseDefaults();
 
      // 添加新对象到块表记录和事务中   Add the new object to the block table record and the transaction
      acBlkTblRec.AppendEntity(ac2DSolidBow);
      acTrans.AddNewlyCreatedDBObject(ac2DSolidBow, true);
 
      // Create a quadrilateral (square) solid in Model space
      Solid ac2DSolidSqr = new Solid(new Point3d(10, 0, 0),
                                     new Point3d(15, 0, 0),
                                     new Point3d(10, 8, 0),
                                     new Point3d(15, 8, 0));
 
      ac2DSolidSqr.SetDatabaseDefaults();
 
      // 添加新对象到块表记录和事务中   Add the new object to the block table record and the transaction
      acBlkTblRec.AppendEntity(ac2DSolidSqr);
      acTrans.AddNewlyCreatedDBObject(ac2DSolidSqr, true);
 
      // 保存新对象到数据库中   Save the new object to the database
      acTrans.Commit();
  }
}
VBA/ActiveX 代码参考