ViewSection クラスを使用して、断面図ビュー、詳細ビュー、吹き出しビュー、参照吹き出しと参照断面を作成できます。これは立面図ビューも表します。
断面図ビューはモデルを切断して内部構造を表示します。ViewSection.CreateSection()メソッドは、断面図ビューを作成します。
|
コード領域: ViewSection.CreateSection() |
public ViewSection ViewSection.CreateSection(Document document, ElementId viewFamilyTypeId, BoundingBoxXYZ sectionBox); |
viewFamilyTypeId パラメータは、新しい ViewSection によって使用される ViewFamilyType の ID です。このタイプは、断面 ViewFamily である必要があります。sectionBox パラメータは、断面図ビューのトリミング ボックスです。断面図ビューで必要な方向と範囲が表示されます。通常、他のビューのトリミング ボックスがパラメータとして使用されます。また、方向と範囲を示すためにカスタム BoundingBoxXYZ インスタンスを構築することもできます。
次のコードでは、断面図ビューを作成する方法を示しています。断面図ビューの境界ボックスは、壁の中心に作成されます。結果として得られた断面図ビューは、プロジェクト ブラウザの断面図(建築断面)ノードに配置されます。
|
コード領域: 断面図ビューを作成 |
// Find a section view type
IEnumerable<ViewFamilyType> viewFamilyTypes = from elem in new FilteredElementCollector(document).OfClass(typeof(ViewFamilyType))
let type = elem as ViewFamilyType
where type.ViewFamily == ViewFamily.Section
select type;
// Create a BoundingBoxXYZ instance centered on wall
LocationCurve lc = wall.Location as LocationCurve;
Transform curveTransform = lc.Curve.ComputeDerivatives(0.5, true);
// using 0.5 and "true" (to specify that the parameter is normalized)
// places the transform's origin at the center of the location curve)
XYZ origin = curveTransform.Origin; // mid-point of location curve
XYZ viewDirection = curveTransform.BasisX.Normalize(); // tangent vector along the location curve
XYZ normal = viewDirection.CrossProduct(XYZ.BasisZ).Normalize(); // location curve normal @ mid-point
Transform transform = Transform.Identity;
transform.Origin = origin;
transform.BasisX = normal;
transform.BasisY = XYZ.BasisZ;
// can use this simplification because wall's "up" is vertical.
// For a non-vertical situation (such as section through a sloped floor the surface normal would be needed)
transform.BasisZ = normal.CrossProduct(XYZ.BasisZ);
BoundingBoxXYZ sectionBox = new BoundingBoxXYZ();
sectionBox.Transform = transform;
sectionBox.Min = new XYZ(-10,0,0);
sectionBox.Max = new XYZ(10,12,5);
// Min & Max X values (-10 & 10) define the section line length on each side of the wall
// Max Y (12) is the height of the section box// Max Z (5) is the far clip offset
// Create a new view section.
ViewSection viewSection = ViewSection.CreateSection(document, viewFamilyTypes.First().Id, sectionBox);
|
参照断面とは、既存のビューを参照する断面のことです。新しい参照断面を作成する場合、Revit は新しいビューを追加しません。
|
コード領域: ViewSection.CreateReferenceSection() |
public ViewSection ViewSection.CreateReferenceSection(Document document,
ElementId parentViewId,
ElementId viewIdToReference,
XYZ headPoint,
XYZ tailPoint);
|
詳細ビューは、その他のビューで吹き出しまたは断面図として表示されるモデルのビューです。このビューのタイプは、通常は親ビューよりも詳細な尺度でモデルを表示します。これは、モデルの特定の部分に情報を追加するために使用されます。静的 ViewSection.CreateDetail()メソッドを使用して、新しい詳細 ViewSection を作成します。
|
コード領域: ViewSection.CreateDetail() |
public ViewSection ViewSection.CreateDetail(Document document, ElementId viewFamilyTypeId, BoundingBoxXYZ sectionBox); |
viewFamilyTypeId パラメータは、新しい ViewSection によって使用される ViewFamilyType の ID です。このタイプは、詳細 ViewFamily である必要があります。標準の断面図ビューのように、sectionBox パラメータは、断面図ビューのトリミング ボックスです。断面図ビューで必要な方向と範囲が表示されます。
新しい詳細 ViewSection が追加されると、プロジェクト ブラウザの詳細ビュー(詳細)ノードで表示されます。
立面図ビューは、レベル ラインが表示されるモデルの断面です。立面図ビューは ViewSection クラスによって表されます。他のタイプの断面図ビューとは異なり、ViewSection クラスの静的メソッドを使用して立面図ビューを作成できません。立面図ビューを作成するには、まず立面図マーカーを作成し、そのマーカーを使用して立面図ビューを作成します。新しく作成された立面図ビューは、プロジェクト ブラウザの断面図(建物の立面図)ノードに表示されます。これには一意の名前が割り当てられます。
次の例では、梁の位置に基づいて立面図ビューを作成しています。
|
コード領域: 立面図ビューを作成 |
ViewSection CreateElevationView(Document document, FamilyInstance beam)
{
// Find an elevation view type
IEnumerable<ViewFamilyType> viewFamilyTypes = from elem in new FilteredElementCollector(document).OfClass(typeof(ViewFamilyType))
let type = elem as ViewFamilyType
where type.ViewFamily == ViewFamily.Elevation
select type;
LocationCurve lc = beam.Location as LocationCurve;
XYZ xyz = lc.Curve.GetEndPoint(0);
ElevationMarker marker = ElevationMarker.CreateElevationMarker(document, viewFamilyTypes.First().Id, xyz, 1);
ViewSection elevationView = marker.CreateElevation(document, document.ActiveView.Id, 1);
return elevationView;
}
|
ElevationMarker.CreateElevation()メソッドは、パラメータとして ViewPlan の ID を取得します。これは ElevationMarker が表示されている ViewPlan です。新しい立面図 ViewSection は、範囲を作成し、ViewPlan から設定を継承します。最後のパラメータは、新しい立面図ビューが配置される ElevationMarker のインデックスです。ElevationMarker のインデックスは有効で未使用である必要があります。ビューの方向はインデックスによって決定されます。
吹き出しには、別のビューの一部が拡大されて表示されます。吹き出しビューは、静的メソッド ViewSection.CreateCallout()を使用して作成できます。吹き出しは、平面図ビュー、天井伏図ビュー、構造伏図ビュー、断面図ビュー、立面図ビュー、製図ビュー、詳細ビューで作成できます。結果として得られるビューは、使用された ViewFamilyType に応じて ViewSection、ViewPlan、ViewDetail のいずれかになり、プロジェクト ブラウザの対応するノードに表示されます。
|
コード領域: ViewSection.CreateCallout() |
public ViewSection ViewSection.CreateCallout(Document document,
ElementId parentViewId,
ElementId viewFamilyTypeId,
XYZ point1,
XYZ point2);
|
参照吹き出しは、既存のビューを参照する吹き出しです。参照吹き出しを追加すると、Revit はプロジェクトにビューを作成しません。その代わりに、指定した既存のビューへのポインタが作成されます。複数の参照吹き出しが同じビューを示すことができます。
|
コード領域: ViewSection.CreateReferenceCallout() |
public ViewSection ViewSection.CreateReferenceCallout(Document document,
ElementId parentViewId,
ElementId viewIdToReference,
XYZ point1,
XYZ point2);
|
参照吹き出しの作成は、吹き出しの作成に似ています。ただし、吹き出しの ViewFamilyType の ID をパラメータとして持つのではなく、CreateReferenceCallout()メソッドは参照するビューの ID を取得します。参照されるビューの ViewFamilyType は、新しい参照吹き出しによって使用されます。
参照されたビューが製図ビューでない限り、トリミングされたビューのみを参照できます。製図ビューは、親ビューのタイプに関係なく、常に参照することができます。立面図ビューは、親の立面図ビューおよび製図ビューから参照することができます。断面図ビューは、親の断面図ビューおよび製図ビューから参照することができます。詳細ビューは、水平方向の詳細ビューしか参照できない平面図ビュー、天井伏図ビュー、構造伏図ビューの親ビュー以外のすべての親ビューから参照できます。平面図ビュー、天井伏図ビュー、構造伏図ビューは、平面図ビュー、天井伏図ビュー、構造伏図ビューの親ビューから参照できます。
次の例では、詳細 ViewFamilyType を使用して新しい吹き出しを作成し、新しい吹き出しビューを使用して参照吹き出しを作成します。
|
コード領域: 吹き出しと参照用吹き出しを作成 |
public void CreateCalloutView(Document document, View parentView)
{
// Find a detail view type
IEnumerable<ViewFamilyType> viewFamilyTypes = from elem in new FilteredElementCollector(document).OfClass(typeof(ViewFamilyType))
let type = elem as ViewFamilyType
where type.ViewFamily == ViewFamily.Detail
select type;
ElementId viewFamilyTypeId = viewFamilyTypes.First().Id;
XYZ point1 = new XYZ(2, 2, 2);
XYZ point2 = new XYZ(30, 30, 30);
ElementId parentViewId = parentView.Id; // a ViewPlan
View view = ViewSection.CreateCallout(document, parentViewId, viewFamilyTypeId, point1, point2);
ViewSection.CreateReferenceCallout(document, parentViewId, view.Id, point1, point2);
}
|