Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How does Revit create and switch tags

Shulou Source: shulou.com Published: 2022-05-31 14:22:46 11月14日 Update

This article mainly explains "how to create and switch tags in Revit". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how to create and switch tags in Revit.

At the beginning, let's start with a question. There are usually a lot of marks on a beam when marking construction drawings, so we will switch marks by switching the form of marks (as shown in the following figure), so how is this realized in the code?

First take a look at API, which are the parameters we need to create a NewTag:

First parameter: we use the doc.ActiveView current active view

Second parameter: find our beam

Third parameter: whether to add arrowheads or not

The fourth parameter: there are three forms: category tag, multi-category tag and material. Let's choose the first category tag.

Fifth parameter: horizontal direction or vertical direction.

Sixth parameter: coordinates

FilteredElementCollector fil = new FilteredElementCollector (doc, uiDoc.ActiveView.Id)

Fil.OfCategory (BuiltInCategory.OST_StructuralFraming); / / Beam

Foreach (Element el in fil)

{

IndependentTag tagg = doc.Create.NewTag (doc.ActiveView, el, true, TagMode.TM_ADDBY_CATEGORY, TagOrientation.Vertical, new XYZ); / / Mark each quart beam

}

The effect achieved is:

The system is only created according to the default last choice and cannot implement a tag, so what should I do next?

There is only one sentence to use here: tagg.ChangeTypeId (id)

All integrated with the above code:

FilteredElementCollector fil = new FilteredElementCollector (doc, uiDoc.ActiveView.Id)

Fil.OfCategory (BuiltInCategory.OST_StructuralFraming); / / Beam

FilteredElementCollector filtered = new FilteredElementCollector (doc); / / callout

Filtered.OfClass (typeof (FamilySymbol)) .OfCategory (BuiltInCategory.OST_StructuralFramingTags)

ElementId id = null

Foreach (FamilySymbol tag in filtered)

{

If (tag.Name = "Beam centralized Dimensions")

{

Id = tag.Id

}

}

Foreach (Element el in fil)

{

IndependentTag tagg = doc.Create.NewTag (doc.ActiveView, el, true, TagMode.TM_ADDBY_CATEGORY, TagOrientation.Vertical, new XYZ); / / Mark each quart beam

Tagg.ChangeTypeId (id)

IndependentTag tag = doc.Create.NewTag (doc.ActiveView, el, true, TagMode.TM_ADDBY_CATEGORY, TagOrientation.Vertical, new XYZ (0,0,0))

}

Effect:

Thank you for your reading, the above is the content of "how to create and switch tags for Revit". After the study of this article, I believe you have a deeper understanding of how to create and switch tags for Revit, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Tag parameter switch category learning code content effect direction problem next one sentence three forms above coordinates that is beginning form train of thought. Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Huawei Docker Shulou Technology Shulou Information