Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to write the code of Revit development template

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

This article mainly introduces the Revit development template code how to write the relevant knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe that everyone after reading this Revit development template code how to write the article will have a harvest, let's take a look at it.

The code is as follows:

Using System

Using System.Collections.Generic

Using System.Linq

Using System.Text

Using System.Windows.Forms

Using System.IO

References to the using System.Data; system part

This paragraph is a reference so that we can write fewer lines of code.

References to the using Autodesk.Revit; Revit section

Using Autodesk.Revit.UI

Using Autodesk.Revit.UI.Selection

Using Autodesk.Revit.DB

Using Autodesk.Revit.DB.Architecture

For example: Selection se = uiDoc.Selection;// Select component

If we don't quote it, we have to write:

Autodesk.Revit.UI.Selection.Selection se = uiDoc.Selection

Whether it is troublesome or not, therefore, using reference space can give us time to scratch our feet.

/ / the long section below is the program template, which will be explained later. It would be nice for everyone to save it and use it as a template.

Namespace template

{

[Autodesk.Revit.Attributes.Transaction (Autodesk.Revit.Attributes.TransactionMode.Manual)]

[Autodesk.Revit.Attributes.Regeneration (Autodesk.Revit.Attributes.RegenerationOption.Manual)]

[Autodesk.Revit.Attributes.Journaling (Autodesk.Revit.Attributes.JournalingMode.NoCommandData)]

Public class CheckCode: IExternalCommand

{

Public Autodesk.Revit.UI.Result Execute (ExternalCommandData commandData, ref string message, Autodesk.Revit.DB.ElementSet elements)

{

/ / create an application object

Autodesk.Revit.ApplicationServices.Application app = commandData.Application.Application

/ / create a document object

Autodesk.Revit.DB.Document doc = commandData.Application.ActiveUIDocument.Document

/ / create an application object

Autodesk.Revit.UI.UIApplication uiapp = commandData.Application

/ / create a document object

Autodesk.Revit.UI.UIDocument uiDoc = uiapp.ActiveUIDocument

/ / start transaction

Transaction ts = new Transaction (doc, "standard check")

Ts.Start ()

Write code in between

Ts.Commit ()

Return Result.Succeeded

This is the end of the article on "how to write the code for Revit development templates". Thank you for reading! I believe that everyone has a certain understanding of the knowledge of "how to write the code of the Revit development template". If you want to learn more knowledge, you are welcome to follow the industry information channel.

Tags: Code template development object knowledge program content application document article part application transaction value function that is simple operation article time Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Docker MySQL Shulou Tech Info OPPO Reno