ソリッド オブジェクト(Solid3d オブジェクト)は、オブジェクト全体を表します。ソリッドは、3 種類のモデリングの中で最も情報量が多く明確に定義されたモデルです。また、複雑な形状の場合も、ワイヤフレームやメッシュより作成および編集が簡単です。
直方体、球、くさびなどの基本的なソリッド形状は、Solid3d オブジェクトのメンバー メソッドとプロパティを使用して作成します。また、パスに沿ってリージョン オブジェクトを押し出したり、軸を中心にして 2D オブジェクトを回転させたりすることもできます。
メッシュと同様に、ソリッドは、隠面処理、シェーディング、レンダリングを行わなければ、ワイヤフレームとして表示されます。さらに、ソリッドを解析して物理的特性(量、慣性モーメント、重心など)を取得することができます。次の MassProperties プロパティを使用して、Solid3d オブジェクトと関連付けられた Solid3dMassProperties オブジェクトをクエリーできます。Solid3dMassProperties オブジェクトに含まれるプロパティ(MomentOfInertia、PrincipalAxes、PrincipalMoments、ProductOfInertia、RadiiOfGyration、Volume)を使用して、ソリッドを分析できます。
ソリッドの表示には、現在の表示スタイルおよび 3D モデリング関連のシステム変数が反映されます。ソリッドの表示に影響を与えるシステム変数としては、ISOLINES や FACETRES などがあります。ISOLINES は、ワイヤフレームの曲線部分を表現するために使用される面分割線の数をコントロールします。FACETRES は、シェーディングしたオブジェクトや、隠線処理したオブジェクトの滑らかさを調整します。
次の例では、くさび型ソリッドを作成します。くさびの 3 次元的な特質を表示できるように、アクティブ ビューポートのビュー方向を更新します。
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
using (Solid3d acSol3D = new Solid3d())
{
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();
}
}
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
Using acSol3D As Solid3d = New Solid3d()
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)
End Using
'' 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
Sub CreateWedge()
Dim wedgeObj As Acad3DSolid
Dim center(0 To 2) As Double
Dim length As Double
Dim width As Double
Dim height As Double
' Define the wedge
center(0) = 5#: center(1) = 5#: center(2) = 0
length = 10#: width = 15#: height = 20#
' Create the wedge in model space
Set wedgeObj = ThisDrawing.ModelSpace. _
AddWedge(center, length, width, height)
' Change the viewing direction of the viewport
Dim NewDirection(0 To 2) As Double
NewDirection(0) = -1
NewDirection(1) = -1
NewDirection(2) = 1
ThisDrawing.ActiveViewport.direction = NewDirection
ThisDrawing.ActiveViewport = ThisDrawing.ActiveViewport
ZoomAll
End Sub