タグは、図面要素を識別するための注釈です。この API は、IndependentTag と RoomTag クラスを公開して、Revit アプリケーションで使用されるほとんどのタグを網羅しています。RoomTag の詳細は、「部屋」(「Revit Architecture」セクション)を参照してください。
表 37: タグ名とカテゴリ
タグ名 |
BuiltInCategory |
キーノート タグ |
OST_KeynoteTags |
梁システム タグ |
OST_BeamSystemTags |
電子回路タグ |
OST_ElectricalCircuitTags |
スパン方向タグ |
OST_SpanDirectionSymbol |
パス配筋スパン タグ |
OST_PathReinSpanSymbol |
鉄筋システム スパン タグ |
OST_IOSRebarSystemSpanSymbolCtrl |
ファミリ ライブラリにある各カテゴリには既に定義済みのタグが付いています。一部のタグは、既定の Revit アプリケーションで自動的にロードされ、その他のタグは手動でロードされます。IndependentTag オブジェクトは、[カテゴリ別]オプションを使用して作成されている場合は、ホスト要素に基づいて異なるカテゴリを返します。たとえば、Wall および Floor の IndependentTag は、それぞれ OST_WallTags と OST_FloorTags です。
タグが[マルチカテゴリ]や[マテリアル]スタイルを使用して作成された場合は、カテゴリ はそれぞれ OST_MultiCategoryTags と OST_MaterialTags になります。
コード領域 16-5: IndependentTag を作成 |
private IndependentTag CreateIndependentTag(Autodesk.Revit.DB.Document document, Wall wall) { // make sure active view is not a 3D view Autodesk.Revit.DB.View view = document.ActiveView; // define tag mode and tag orientation for new tag TagMode tagMode = TagMode.TM_ADDBY_CATEGORY; TagOrientation tagorn = TagOrientation.Horizontal; // Add the tag to the middle of the wall LocationCurve wallLoc = wall.Location as LocationCurve; XYZ wallStart = wallLoc.Curve.GetEndPoint(0); XYZ wallEnd = wallLoc.Curve.GetEndPoint(1); XYZ wallMid = wallLoc.Curve.Evaluate(0.5, true); IndependentTag newTag = document.Create.NewTag(view, wall, true, tagMode, tagorn, wallMid); if (null == newTag) { throw new Exception("Create IndependentTag Failed."); } // newTag.TagText is read-only, so we change the Type Mark type parameter to // set the tag text. The label parameter for the tag family determines // what type parameter is used for the tag text. WallType type = wall.WallType; Parameter foundParameter = type.LookupParameter("Type Mark"); bool result = foundParameter.Set("Hello"); // set leader mode free // otherwise leader end point move with elbow point newTag.LeaderEndCondition = LeaderEndCondition.Free; XYZ elbowPnt = wallMid + new XYZ(5.0, 5.0, 0.0); newTag.LeaderElbow = elbowPnt; XYZ headerPnt = wallMid + new XYZ(10.0, 10.0, 0.0); newTag.TagHeadPosition = headerPnt; return newTag; } |
図 74: サンプル コードを使用した IndependentTag の作成