banner



how to create a tag in revit

Places a tag on an element or subelement.

Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 18.0.0.0 (18.0.0.420)
Since: 2018

Syntax

C#
                                                              public                                static                                IndependentTag                                Create( 	Document                                document, 	ElementId                                ownerDBViewId, 	Reference                                referenceToTag, 	bool                                addLeader, 	TagMode                                tagMode, 	TagOrientation                                tagOrientation, 	XYZ                                pnt                                )                            
Visual Basic
                                                              Public                                Shared                                Function                                Create                                ( _                                document                                As                                Document, _                                ownerDBViewId                                As                                ElementId, _                                referenceToTag                                As                                Reference, _                                addLeader                                As                                Boolean, _                                tagMode                                As                                TagMode, _                                tagOrientation                                As                                TagOrientation, _                                pnt                                As                                XYZ _ )                                As                                IndependentTag                            
Visual C++
                                                              public:                                static                                IndependentTag^                                Create( 	Document^                                document,  	ElementId^                                ownerDBViewId,  	Reference^                                referenceToTag,  	bool                                addLeader,  	TagMode                                tagMode,  	TagOrientation                                tagOrientation,  	XYZ^                                pnt                                )                            

Parameters

document
Type: Autodesk.Revit.DB Document
The document to which the tag will be added.
ownerDBViewId
Type: Autodesk.Revit.DB ElementId
The view in which the tag will be visible.
referenceToTag
Type: Autodesk.Revit.DB Reference
The host reference of the tag. The reference can be to an element or subelement in a local or linked document.
addLeader
Type: System Boolean
When true, the tag will be created with a straight leader with an attached end.
tagMode
Type: Autodesk.Revit.DB TagMode
This argument determines the type of tag that will be created. Tag by category, multi-category tag, and material tag are allowed.
tagOrientation
Type: Autodesk.Revit.DB TagOrientation
The orientation of the tag's head.
pnt
Type: Autodesk.Revit.DB XYZ
For tags without leaders, this point is the position of the tag head. For tags with leaders, this point is the end point of the leader, and a leader of default length will be created from this point to the tag head.

Return Value

If successful the new tag is returned.

Remarks

Examples

Copy C#

                                          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);     Reference wallRef =                      new                      Reference(wall);      IndependentTag newTag = IndependentTag.Create(document, view.Id,  wallRef,                      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; }                  

Copy VB.NET

                                          Private                      Function                      CreateIndependentTag(document                      As                      Autodesk.Revit.DB.Document, wall                      As                      Wall)                      As                      IndependentTag                      ' make sure active view is not a 3D view                      Dim                      view                      As                      Autodesk.Revit.DB.View = document.ActiveView                      ' define tag mode and tag orientation for new tag                      Dim                      tagMode__1                      As                      TagMode = TagMode.TM_ADDBY_CATEGORY                      Dim                      tagorn                      As                      TagOrientation = TagOrientation.Horizontal                      ' Add the tag to the middle of the wall                      Dim                      wallLoc                      As                      LocationCurve =                      TryCast(wall.Location, LocationCurve)                      Dim                      wallStart                      As                      XYZ = wallLoc.Curve.GetEndPoint(0)                      Dim                      wallEnd                      As                      XYZ = wallLoc.Curve.GetEndPoint(1)                      Dim                      wallMid                      As                      XYZ = wallLoc.Curve.Evaluate(0.5,                      True)                      Dim                      WallRef                      As                      Reference =                      New                      Reference(wall)                      Dim                      newTag                      As                      IndependentTag = IndependentTag.Create(document, view.Id, wallRef,                      True, tagMode__1, tagorn, wallMid)                      If                      newTag                      Is                      Nothing                      Then                      Throw                      New                      Exception("Create IndependentTag Failed.")                      End                      If                      ' 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.                      Dim                      type                      As                      WallType = wall.WallType                      Dim                      foundParameter                      As                      Parameter = type.LookupParameter("Type Mark")                      Dim                      result                      As                      Boolean                      = foundParameter.[Set]("Hello")                      ' set leader mode free                      ' otherwise leader end point move with elbow point                      newTag.LeaderEndCondition = LeaderEndCondition.Free                      Dim                      elbowPnt                      As                      XYZ = wallMid +                      New                      XYZ(5.0,                      5.0,                      0.0)       newTag.LeaderElbow = elbowPnt                      Dim                      headerPnt                      As                      XYZ = wallMid +                      New                      XYZ(10.0,                      10.0,                      0.0)       newTag.TagHeadPosition = headerPnt                      Return                      newTag                      End                      Function                                      

Exceptions

See Also

how to create a tag in revit

Source: https://www.revitapidocs.com/2018.1/1f622654-786a-b8fd-1f81-278698bacd5b.htm

Posted by: gibsonthistalre98.blogspot.com

0 Response to "how to create a tag in revit"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel