A solid object (Solid3d object) represents the entire volume of an object. Solids are the most informationally complete and least ambiguous of the 3D modeling types. Complex solid shapes are also easier to construct and edit than wireframes and meshes.
实体对象(3DSolid 对象)代表对象的整个体积。实体是信息最完整和最确切的三维建模类型。复杂实体形也比线框和网格更容易构造和编辑。
You create basic solid shapes, such as a box, sphere, and wedge among others with the member mthods and properties of the Solid3d object. You can also extrude region objects along a path or revolving a 2D object about an axis.
用 Solid3d 对象的成员方法或属性可以创建基本实体形,像长方体、球体和楔体其中的一个。也可以通过沿路径拉伸二维对象或者绕轴旋转二维对象来创建实体。
Like meshes, solids are displayed as wireframes until you hide, shade, or render them. Additionally, you can analyze solids for their mass properties (volume, moments of inertia, center of gravity, and so forth). Use the following MassProperties property you can query the Solid3dMassProperties object associated with the Solid3d object. The Solid3dMassProperties object contains the following properties in which allow you to to analyze the solid: MomentOfInertia, PrincipalAxess, PrincipalMoments, ProductOfInertia, RadiiOfGyration, and Volume.
与网格类似,在进行消隐、着色或渲染之前,实体显示为线框。此外,用户还可以分析实体的质量属性(体积、惯性矩、重心等等)。以下特性可用于分析实体:MomentOfInertia、PrincipalDirections、PrincipalMoments、ProductOfInertia、RadiiOfGyration 和 Volume。
The display of a solid is affected by the current visual style and 3D modeling related system variables. Some of the system variables that affect the display of a solid are ISOLINES and FACETRES. ISOLINES controls the number of tessellation lines used to visualize curved portions of the wireframe, while FACETRES adjusts the smoothness of shaded and hidden-line objects.
实体的显示受当前可视化样式和与三维模型相关的系统变量的影响。影响实体显示的一些系统变量有 ISOLINES 和 FACETRES。ISOLINES 控制轮廓素线的数量,它用于显示框架线的曲线的一部分。而 FACETRES 调整着色和隐藏线的对象的平滑度。
For more information on creating solids, see “Create 3D Objects” in the AutoCAD User's Guide.
有关创建实体的详细信息,请参见《AutoCAD 用户手册》中的“创建三维对象”。
The following example creates a wedge-shaped solid. The viewing direction of the active viewport is updated to display the three-dimensional nature of the wedge.
本样例在模型空间中创建一个楔形实体。然后更新活动视口的观察方向,以便于查看楔体的三维情况。
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Geometry
<CommandMethod("CreateWedge")> _
Public Sub CreateWedge()
''获得当前文档和数据库,并启动一个事务 Get the current document and database, and start a transaction
Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim acCurDb As Database = acDoc.Database
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 3D solid wedge
Dim acSol3D As Solid3d = New Solid3d()
acSol3D.SetDatabaseDefaults()
acSol3D.CreateWedge(10, 15, 20)
'' 定位三维实体的中心在(5,5,0) Position the center of the 3D solid at (5,5,0)
acSol3D.TransformBy(Matrix3d.Displacement(New Point3d(5, 5, 0) - _
Point3d.Origin))
'' 添加新对象到块表记录和事务中 Add the new object to the block table record and the transaction
acBlkTblRec.AppendEntity(acSol3D)
acTrans.AddNewlyCreatedDBObject(acSol3D, True)
'' 打开活动视口 Open the active viewport
Dim acVportTblRec As ViewportTableRecord
acVportTblRec = acTrans.GetObject(acDoc.Editor.ActiveViewportId, _
OpenMode.ForWrite)
''旋转当前视口的查看方向 Rotate the view direction of the current viewport
acVportTblRec.ViewDirection = New Vector3d(-1, -1, 1)
acDoc.Editor.UpdateTiledViewportsFromDatabase()
'' 保存新对象到数据库中 Save the new objects to the database
acTrans.Commit()
End Using
End Sub
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
[CommandMethod("CreateWedge")]
public static void CreateWedge()
{
// Get the current document and database, and start a transaction
Document acDoc = Application.DocumentManager.MdiActiveDocument;
Database acCurDb = acDoc.Database;
using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
{
// 以只读方式打开块表记录 Open the Block table record 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 3D solid wedge
Solid3d acSol3D = new Solid3d();
acSol3D.SetDatabaseDefaults();
acSol3D.CreateWedge(10, 15, 20);
// Position the center of the 3D solid at (5,5,0)
acSol3D.TransformBy(Matrix3d.Displacement(new Point3d(5, 5, 0) -
Point3d.Origin));
// 添加新对象到块表记录和事务中 Add the new object to the block table record and the transaction
acBlkTblRec.AppendEntity(acSol3D);
acTrans.AddNewlyCreatedDBObject(acSol3D, true);
// 打开活动视口 Open the active viewport
ViewportTableRecord acVportTblRec;
acVportTblRec = acTrans.GetObject(acDoc.Editor.ActiveViewportId,
OpenMode.ForWrite) as ViewportTableRecord;
// Rotate the view direction of the current viewport
acVportTblRec.ViewDirection = new Vector3d(-1, -1, 1);
acDoc.Editor.UpdateTiledViewportsFromDatabase();
// 保存新对象到数据库中 Save the new objects to the database
acTrans.Commit();
}
}