建筑外围尺寸标注
This commit is contained in:
12
TestTools/Class1.cs
Normal file
12
TestTools/Class1.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TestTools
|
||||
{
|
||||
public class Class1
|
||||
{
|
||||
}
|
||||
}
|
||||
36
TestTools/Properties/AssemblyInfo.cs
Normal file
36
TestTools/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 有关程序集的一般信息由以下
|
||||
// 控制。更改这些特性值可修改
|
||||
// 与程序集关联的信息。
|
||||
[assembly: AssemblyTitle("TestTools")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("TestTools")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2021")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// 将 ComVisible 设置为 false 会使此程序集中的类型
|
||||
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
|
||||
//请将此类型的 ComVisible 特性设置为 true。
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
|
||||
[assembly: Guid("1cceeb54-fd53-4812-8c2d-3489e7883f86")]
|
||||
|
||||
// 程序集的版本信息由下列四个值组成:
|
||||
//
|
||||
// 主版本
|
||||
// 次版本
|
||||
// 生成号
|
||||
// 修订号
|
||||
//
|
||||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
|
||||
//通过使用 "*",如下所示:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
119
TestTools/TestCmd.cs
Normal file
119
TestTools/TestCmd.cs
Normal file
@@ -0,0 +1,119 @@
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
using Autodesk.Revit.UI.Selection;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TestTools
|
||||
{
|
||||
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
|
||||
[Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
|
||||
public class TestCmd : Autodesk.Revit.UI.IExternalCommand
|
||||
{
|
||||
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
|
||||
{
|
||||
UIApplication uiapp = commandData.Application;
|
||||
UIDocument uidoc = uiapp.ActiveUIDocument;
|
||||
Autodesk.Revit.ApplicationServices.Application app = uiapp.Application;
|
||||
Document doc = uidoc.Document;
|
||||
DocumentSet docset = uiapp.Application.Documents;
|
||||
|
||||
Reference refer = uidoc.Selection.PickObject(ObjectType.Element, "请选择XXX");
|
||||
Element e = uidoc.Document.GetElement(refer);
|
||||
Options options = new Options()
|
||||
{
|
||||
ComputeReferences = true,
|
||||
DetailLevel = ViewDetailLevel.Fine,
|
||||
};
|
||||
var eleIds = e.GetGeneratingElementIds(e.get_Geometry(options));
|
||||
uidoc.Selection.SetElementIds(eleIds);
|
||||
|
||||
#region FilterExecute
|
||||
|
||||
//var walls = new FilteredElementCollector(doc).OfClass(typeof(Wall)).ToElements();
|
||||
//using (Transaction trans = new Transaction(doc, "default"))
|
||||
//{
|
||||
// try
|
||||
// {
|
||||
// trans.Start();
|
||||
// //Do Something.
|
||||
// trans.Commit();
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// message = ex.Message;
|
||||
// if (trans.GetStatus() == TransactionStatus.Started)
|
||||
// {
|
||||
// trans.RollBack();
|
||||
// }
|
||||
// return Result.Failed;
|
||||
// }
|
||||
//}
|
||||
|
||||
#endregion FilterExecute
|
||||
|
||||
#region RepeatExecute
|
||||
|
||||
//bool isCoutine = true;
|
||||
//using (Transaction trans = new Transaction(doc, "default"))
|
||||
//{
|
||||
// try
|
||||
// {
|
||||
// while (isCoutine)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// trans.Start();
|
||||
// //do something.
|
||||
// trans.Commit();
|
||||
// }
|
||||
// catch (Autodesk.Revit.Exceptions.OperationCanceledException ex)
|
||||
// {
|
||||
// trans.Commit();
|
||||
// return Result.Succeeded;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// message = ex.Message;
|
||||
// if (trans.GetStatus() == TransactionStatus.Started)
|
||||
// {
|
||||
// trans.RollBack();
|
||||
// }
|
||||
// return Result.Failed;
|
||||
// }
|
||||
//}
|
||||
|
||||
#endregion RepeatExecute
|
||||
|
||||
#region SelectExecute
|
||||
|
||||
//using (Transaction trans = new Transaction(doc, "default"))
|
||||
//{
|
||||
// try
|
||||
// {
|
||||
// Reference refer = uidoc.Selection.PickObject(ObjectType.Element, "请选择XXX");
|
||||
// Element e = uidoc.Document.GetElement(refer);
|
||||
|
||||
// trans.Start();
|
||||
|
||||
// trans.Commit();
|
||||
// }
|
||||
// catch (Autodesk.Revit.Exceptions.OperationCanceledException ex)
|
||||
// {
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// }
|
||||
//}
|
||||
|
||||
#endregion SelectExecute
|
||||
|
||||
return Result.Succeeded;
|
||||
}
|
||||
}
|
||||
}
|
||||
70
TestTools/TestTools.csproj
Normal file
70
TestTools/TestTools.csproj
Normal file
@@ -0,0 +1,70 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{1CCEEB54-FD53-4812-8C2D-3489E7883F86}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>TestTools</RootNamespace>
|
||||
<AssemblyName>TestTools</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="AdWindows, Version=2018.11.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Revit_API_x64.2020.0.0\lib\NET470\AdWindows.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="RevitAddInUtility, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Revit_API_x64.2020.0.0\lib\NET470\RevitAddInUtility.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="RevitAPI, Version=20.0.0.0, Culture=neutral, processorArchitecture=AMD64">
|
||||
<HintPath>..\packages\Revit_API_x64.2020.0.0\lib\NET470\RevitAPI.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="RevitAPIUI, Version=20.0.0.0, Culture=neutral, processorArchitecture=AMD64">
|
||||
<HintPath>..\packages\Revit_API_x64.2020.0.0\lib\NET470\RevitAPIUI.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="UIFramework, Version=20.0.0.0, Culture=neutral, processorArchitecture=AMD64">
|
||||
<HintPath>..\packages\Revit_API_x64.2020.0.0\lib\NET470\UIFramework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UIFrameworkServices, Version=20.0.0.0, Culture=neutral, processorArchitecture=AMD64">
|
||||
<HintPath>..\packages\Revit_API_x64.2020.0.0\lib\NET470\UIFrameworkServices.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Class1.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="TestCmd.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
4
TestTools/packages.config
Normal file
4
TestTools/packages.config
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Revit_API_x64" version="2020.0.0" targetFramework="net472" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user