├── README.md ├── Test ├── packages.config ├── TestGeometry.cs ├── TestSchema.cs ├── Properties │ └── AssemblyInfo.cs ├── TestExternalEventHandler.cs ├── Test.csproj └── DrawEdge.cs ├── RevitAPIToolbox ├── packages.config ├── Geometry │ ├── IGeometryFilter.cs │ ├── GeometryClassFilter.cs │ ├── GeometryElementExtension.cs │ ├── GeometryInstanceExtension.cs │ └── FilteredGeometryCollector.cs ├── UI │ ├── ControlUtility.cs │ ├── RibbonItemMixin.cs │ ├── RibbonCommandItemMixin.cs │ ├── SelectionExtension.cs │ └── UIFactory.cs ├── Misc │ ├── CurveDivide │ │ ├── ICurveDivider.cs │ │ ├── ControlledCurveDivider.cs │ │ └── CurveDivider.cs │ └── SchemaDesigner │ │ └── SchemaBase.cs ├── Attributes │ ├── SchemaFieldAttribute.cs │ ├── SchemaAttribute.cs │ └── TargetTypeAttribute.cs ├── Exceptions │ └── SchemaNotDefinedWithAttributeException.cs ├── Database │ ├── ReferenceExtension.cs │ ├── CurveExtension.cs │ ├── XYZExtension.cs │ ├── ParameterExtension.cs │ ├── FamilyManagerExtension.cs │ ├── DocumentExtension.cs │ ├── FamilyExtension.cs │ ├── PlaneExtension.cs │ ├── ViewExtension.cs │ └── ElementExtension.cs ├── Common │ ├── Int32Extension.cs │ ├── DelegateExternalEventHandler.cs │ ├── EnumerableExtension.cs │ ├── ParameterizedExternalEventHandler.cs │ ├── TypeExtension.cs │ ├── DoubleExtension.cs │ └── ExternalEventManager.cs ├── Properties │ └── AssemblyInfo.cs └── RevitAPIToolbox.csproj ├── RevitAPIWheel ├── packages.config ├── ExternalEvent │ ├── IExternalEventHandlerWheel.cs │ ├── ExternalEventHandlerDemo.cs │ ├── App.cs │ ├── Command.cs │ └── ExternalEventWheel.cs ├── RevitAPIWheel.addin ├── Properties │ └── AssemblyInfo.cs └── RevitAPIWheel.csproj ├── RevitAPIToolbox2014 ├── packages.config ├── Properties │ └── AssemblyInfo.cs └── RevitAPIToolbox2014.csproj ├── RevitAPIToolbox2015 ├── packages.config ├── Properties │ └── AssemblyInfo.cs └── RevitAPIToolbox2015.csproj ├── RevitAPIToolbox2016 ├── packages.config ├── Properties │ └── AssemblyInfo.cs └── RevitAPIToolbox2016.csproj ├── RevitAPIToolbox2017 ├── packages.config ├── Properties │ └── AssemblyInfo.cs └── RevitAPIToolbox2017.csproj ├── RevitAPIToolbox2018 ├── packages.config ├── Properties │ └── AssemblyInfo.cs └── RevitAPIToolbox2018.csproj ├── LICENSE ├── .gitignore └── RevitAPIToolbox.sln /README.md: -------------------------------------------------------------------------------- 1 | # RevitAPIToolbox 2 | A library containing some helping classes for Revit API developing 3 | -------------------------------------------------------------------------------- /Test/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /RevitAPIToolbox/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /RevitAPIWheel/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /RevitAPIToolbox2014/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /RevitAPIToolbox2015/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /RevitAPIToolbox2016/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /RevitAPIToolbox2017/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /RevitAPIToolbox2018/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /RevitAPIToolbox/Geometry/IGeometryFilter.cs: -------------------------------------------------------------------------------- 1 | using Autodesk.Revit.DB; 2 | 3 | namespace Techyard.Revit.Geometry 4 | { 5 | public interface IGeometryFilter 6 | { 7 | bool Filter(GeometryObject go); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /RevitAPIToolbox/UI/ControlUtility.cs: -------------------------------------------------------------------------------- 1 | namespace Techyard.Revit.UI 2 | { 3 | internal class ControlUtility 4 | { 5 | internal static string GenerateId(string parentId, string name) 6 | { 7 | return $"CustomCtrl_%{parentId}%{name}"; 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /RevitAPIToolbox/Misc/CurveDivide/ICurveDivider.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Autodesk.Revit.DB; 3 | 4 | namespace Techyard.Revit.Misc.CurveDivide 5 | { 6 | internal interface ICurveDivider 7 | { 8 | IEnumerable EquallyDivide(Curve curve, int number); 9 | } 10 | } -------------------------------------------------------------------------------- /RevitAPIToolbox/Attributes/SchemaFieldAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Techyard.Revit.Attributes 4 | { 5 | [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)] 6 | public class SchemaFieldAttribute : Attribute 7 | { 8 | public string Name { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /RevitAPIToolbox/Exceptions/SchemaNotDefinedWithAttributeException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Techyard.Revit.Exceptions 7 | { 8 | public class SchemaNotDefinedWithAttributeException : Exception 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /RevitAPIToolbox/Attributes/SchemaAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Techyard.Revit.Attributes 4 | { 5 | [AttributeUsage(AttributeTargets.Class)] 6 | public class SchemaAttribute : Attribute 7 | { 8 | public string Guid { get; set; } 9 | public string Name { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /RevitAPIToolbox/Attributes/TargetTypeAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Techyard.Revit.Attributes 4 | { 5 | internal class TargetTypeAttribute : Attribute 6 | { 7 | internal TargetTypeAttribute(params Type[] types) 8 | { 9 | Types = types; 10 | } 11 | 12 | internal Type[] Types { get; } 13 | } 14 | } -------------------------------------------------------------------------------- /RevitAPIToolbox/Database/ReferenceExtension.cs: -------------------------------------------------------------------------------- 1 | using Autodesk.Revit.DB; 2 | 3 | namespace Techyard.Revit.Database 4 | { 5 | public static class ReferenceExtension 6 | { 7 | public static Element ToElement(this Reference reference,Document document) 8 | { 9 | return document.GetElement(reference); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /RevitAPIToolbox/Database/CurveExtension.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Autodesk.Revit.DB; 3 | using Techyard.Revit.Misc.CurveDivide; 4 | 5 | namespace Techyard.Revit.Database 6 | { 7 | public static class CurveExtension 8 | { 9 | public static IEnumerable EquallyDivideByInterpolation(this Curve curve, int divideNum) 10 | { 11 | return CurveDivider.GetDivider(curve.GetType()).EquallyDivide(curve, divideNum); 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /RevitAPIWheel/ExternalEvent/IExternalEventHandlerWheel.cs: -------------------------------------------------------------------------------- 1 | using Autodesk.Revit.UI; 2 | 3 | namespace Techyard.Revit.Wheel.ExternalEvent 4 | { 5 | /// 6 | /// A simple rebuilt version of Autodesk.Revit.UI.IExternalEventHandler interface 7 | /// Autodesk.Revit.UI.IExternalEventHandler 的简易轮子,外部事件处理程序 8 | /// 9 | public interface IExternalEventHandlerWheel 10 | { 11 | void Execute(UIApplication app); 12 | } 13 | } -------------------------------------------------------------------------------- /RevitAPIToolbox/Geometry/GeometryClassFilter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Autodesk.Revit.DB; 3 | 4 | namespace Techyard.Revit.Geometry 5 | { 6 | public class GeometryClassFilter : IGeometryFilter 7 | { 8 | private Type Type { get; } 9 | 10 | public GeometryClassFilter(Type type) 11 | { 12 | Type = type; 13 | } 14 | 15 | public bool Filter(GeometryObject go) 16 | { 17 | return go.GetType() == Type; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /RevitAPIWheel/ExternalEvent/ExternalEventHandlerDemo.cs: -------------------------------------------------------------------------------- 1 | using Autodesk.Revit.UI; 2 | 3 | namespace Techyard.Revit.Wheel.ExternalEvent 4 | { 5 | public class ExternalEventHandlerDemo : IExternalEventHandlerWheel 6 | { 7 | public ExternalEventHandlerDemo(string name) 8 | { 9 | Name = name; 10 | } 11 | 12 | private string Name { get; } 13 | private int Count { get; set; } 14 | 15 | public void Execute(UIApplication app) 16 | { 17 | if (null == app) return; 18 | TaskDialog.Show("外部事件", $"这是{Name}第{++Count}次被调用"); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /RevitAPIToolbox/Database/XYZExtension.cs: -------------------------------------------------------------------------------- 1 | using Autodesk.Revit.DB; 2 | 3 | namespace Techyard.Revit.Database 4 | { 5 | public static class XYZExtension 6 | { 7 | public static XYZ LinearInterpolation(this XYZ first, XYZ second, double length2First) 8 | { 9 | var vector = second - first; 10 | return first + vector * (length2First / vector.GetLength()); 11 | } 12 | 13 | public static XYZ Copy(this XYZ xyz) 14 | { 15 | return new XYZ(xyz.X, xyz.Y, xyz.Z); 16 | } 17 | 18 | public static string AsString(this XYZ point) 19 | { 20 | return $"( {point.X} , {point.Y} , {point.Z} )"; 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /RevitAPIToolbox/Common/Int32Extension.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Techyard.Revit.Common 5 | { 6 | public static class Int32Extension 7 | { 8 | public static void TraverseFrom(this int number, int from, Action handler) 9 | { 10 | var value = from; 11 | while (value < number) 12 | handler?.Invoke(value++); 13 | } 14 | 15 | public static IEnumerable TraverseFrom(this int number, int from, Func handler) where T : class 16 | { 17 | var value = from; 18 | while (value <= number) 19 | yield return handler?.Invoke(value++); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /RevitAPIToolbox/Geometry/GeometryElementExtension.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using Autodesk.Revit.DB; 4 | 5 | namespace Techyard.Revit.Geometry 6 | { 7 | public static class GeometryElementExtension 8 | { 9 | public static IEnumerable GetObjects(this GeometryElement ge) 10 | { 11 | return ge.SelectMany(go => 12 | { 13 | switch (go) 14 | { 15 | case GeometryElement _: 16 | return (go as GeometryElement).GetObjects(); 17 | case GeometryInstance _: 18 | return (go as GeometryInstance).GetObjects(); 19 | } 20 | return new[] {go}; 21 | }); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /RevitAPIToolbox/Geometry/GeometryInstanceExtension.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using Autodesk.Revit.DB; 4 | 5 | namespace Techyard.Revit.Geometry 6 | { 7 | public static class GeometryInstanceExtension 8 | { 9 | public static IEnumerable GetObjects(this GeometryInstance gi) 10 | { 11 | return gi.GetInstanceGeometry().SelectMany(go => 12 | { 13 | switch (go) 14 | { 15 | case GeometryElement _: 16 | return (go as GeometryElement).GetObjects(); 17 | case GeometryInstance _: 18 | return (go as GeometryInstance).GetObjects(); 19 | } 20 | return new[] {go}; 21 | }); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /RevitAPIToolbox/Database/ParameterExtension.cs: -------------------------------------------------------------------------------- 1 | using Autodesk.Revit.DB; 2 | 3 | namespace Techyard.Revit.Database 4 | { 5 | public static class ParameterExtension 6 | { 7 | public static object GetValue(this Parameter parameter) 8 | { 9 | switch (parameter.StorageType) 10 | { 11 | case StorageType.Double: 12 | return parameter.AsDouble(); 13 | case StorageType.ElementId: 14 | return parameter.AsElementId(); 15 | case StorageType.Integer: 16 | return parameter.AsInteger(); 17 | case StorageType.String: 18 | return parameter.AsString(); 19 | default: 20 | return parameter.AsValueString(); 21 | } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /RevitAPIToolbox/Database/FamilyManagerExtension.cs: -------------------------------------------------------------------------------- 1 | 2 | using Autodesk.Revit.DB; 3 | 4 | namespace Techyard.Revit.Database 5 | { 6 | public static class FamilyManagerExtension 7 | { 8 | public static void SetParameter(this FamilyManager manager, FamilyParameter parameter, object value) 9 | { 10 | if (null == parameter) return; 11 | if (parameter.IsReadOnly || parameter.IsDeterminedByFormula) return; 12 | if (value is ElementId) 13 | manager.Set(parameter, (ElementId)value); 14 | else if (value is int) 15 | manager.Set(parameter, (int)value); 16 | else if (value is double) 17 | manager.Set(parameter, (double)value); 18 | else if (value is string) 19 | manager.Set(parameter, (string)value); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /RevitAPIWheel/ExternalEvent/App.cs: -------------------------------------------------------------------------------- 1 | using Autodesk.Revit.Attributes; 2 | using Autodesk.Revit.UI; 3 | 4 | namespace Techyard.Revit.Wheel.ExternalEvent 5 | { 6 | /// 7 | /// External application demenstrating how revit handles external events implemented by user 8 | /// 一个模拟Revit执行用户定义的外部事件(IExternalEventHandler)的Demo 9 | /// 10 | [Transaction(TransactionMode.Manual)] 11 | internal class App : IExternalApplication 12 | { 13 | public Result OnStartup(UIControlledApplication application) 14 | { 15 | ExternalEventWheel.Initialize(application); 16 | return Result.Succeeded; 17 | } 18 | 19 | public Result OnShutdown(UIControlledApplication application) 20 | { 21 | ExternalEventWheel.Destroy(); 22 | return Result.Succeeded; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /RevitAPIWheel/RevitAPIWheel.addin: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | RevitAPIWheel.dll 5 | 76308EFB-28B3-4742-BB7B-22B96DCFCB56 6 | Techyard.Revit.Wheel.ExternalEvent.App 7 | ExternalEventApp 8 | Kennan 9 | Kennan 10 | 11 | 12 | RevitAPIWheel.dll 13 | 31758EBB-28EC-47E7-B7C9-EA3577D035E1 14 | Techyard.Revit.Wheel.ExternalEvent.Command 15 | ExternalEventDemo 16 | AlwaysVisible 17 | Unknown 18 | Kennan 19 | Kennan 20 | 21 | 22 | -------------------------------------------------------------------------------- /Test/TestGeometry.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using Autodesk.Revit.Attributes; 4 | using Autodesk.Revit.DB; 5 | using Autodesk.Revit.UI; 6 | using Techyard.Revit.Geometry; 7 | using Techyard.Revit.UI; 8 | 9 | namespace Test 10 | { 11 | [Transaction(TransactionMode.Manual)] 12 | public class TestGeometry : IExternalCommand 13 | { 14 | public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) 15 | { 16 | var uiDocument = commandData.Application.ActiveUIDocument; 17 | var document = uiDocument.Document; 18 | var element = uiDocument.Selection.SelectSingle(document); 19 | var collector = new FilteredGeometryCollector(element).OfClass().Cast(); 20 | TaskDialog.Show($"Total:{collector.Count()}", $"{collector.Sum(solid => solid.Volume)}"); 21 | return Result.Succeeded; 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /RevitAPIWheel/ExternalEvent/Command.cs: -------------------------------------------------------------------------------- 1 | using Autodesk.Revit.Attributes; 2 | using Autodesk.Revit.DB; 3 | using Autodesk.Revit.UI; 4 | 5 | namespace Techyard.Revit.Wheel.ExternalEvent 6 | { 7 | [Transaction(TransactionMode.Manual)] 8 | public class Command : IExternalCommand 9 | { 10 | public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) 11 | { 12 | var event1 = ExternalEventWheel.Create(new ExternalEventHandlerDemo("张三")); 13 | var event2 = ExternalEventWheel.Create(new ExternalEventHandlerDemo("李四")); 14 | for (var i = 0; i < 3; i++) 15 | { 16 | //Events won't execute immediately 17 | //事件不会立即执行 18 | event1.Raise(); 19 | event2.Raise(); 20 | } 21 | TaskDialog.Show("OK", "事件发送结束,当前命令可以退出了"); 22 | return Result.Succeeded; 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /RevitAPIToolbox/Common/DelegateExternalEventHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Autodesk.Revit.UI; 3 | 4 | namespace Techyard.Revit.Common 5 | { 6 | public class DelegateExternalEventHandler : IExternalEventHandler 7 | { 8 | public DelegateExternalEventHandler(T parameter, Action handler) 9 | : this(parameter, handler, Guid.NewGuid().ToString()) 10 | { 11 | 12 | } 13 | 14 | public DelegateExternalEventHandler(T parameter, Action handler, string name) 15 | { 16 | Parameter = parameter; 17 | Handler = handler; 18 | Name = name; 19 | } 20 | 21 | private T Parameter { get; } 22 | 23 | private Action Handler { get; } 24 | 25 | private string Name { get; } 26 | 27 | public void Execute(UIApplication app) 28 | { 29 | Handler?.Invoke(app, Parameter); 30 | } 31 | 32 | public string GetName() 33 | { 34 | return Name; 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /RevitAPIToolbox/Common/EnumerableExtension.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | 5 | namespace Techyard.Revit.Common 6 | { 7 | public static class EnumerableExtension 8 | { 9 | public static IEnumerable Map(this IEnumerable enumerable, 10 | Func selector) 11 | where TSource : class 12 | where TResult : class 13 | { 14 | var enumerator = enumerable.GetEnumerator(); 15 | while (enumerator.MoveNext()) 16 | { 17 | var item = (TSource) enumerator.Current; 18 | yield return selector?.Invoke(item); 19 | } 20 | } 21 | 22 | public static IEnumerable AsList(this IEnumerable enumerable) 23 | where T : class 24 | { 25 | var enumerator = enumerable.GetEnumerator(); 26 | while (enumerator.MoveNext()) 27 | { 28 | var item = (T) enumerator.Current; 29 | yield return item; 30 | } 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Kennan Chan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /RevitAPIToolbox/Common/ParameterizedExternalEventHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Autodesk.Revit.UI; 4 | 5 | namespace Techyard.Revit.Common 6 | { 7 | [Obsolete("This class is deprecated, use DelegateExternalEventHandler instead")] 8 | public abstract class ParameterizedExternalEventHandler : IExternalEventHandler 9 | { 10 | private static Queue Parameters { get; } = new Queue(); 11 | 12 | public T EventParameter 13 | { 14 | get 15 | { 16 | lock (Parameters) 17 | { 18 | return Parameters.Dequeue(); 19 | } 20 | } 21 | set 22 | { 23 | lock (Parameters) 24 | { 25 | Parameters.Enqueue(value); 26 | } 27 | } 28 | } 29 | 30 | public void Execute(UIApplication app) 31 | { 32 | var parameter = EventParameter; 33 | Execute(app, parameter); 34 | } 35 | 36 | public abstract void Execute(UIApplication app, T parameter); 37 | 38 | public abstract string GetName(); 39 | } 40 | } -------------------------------------------------------------------------------- /RevitAPIToolbox/UI/RibbonItemMixin.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Autodesk.Windows; 3 | 4 | namespace Techyard.Revit.UI 5 | { 6 | internal static class RibbonItemMixin 7 | { 8 | public static string GetCommandId(this RibbonItem item) 9 | { 10 | return item.Id; 11 | } 12 | 13 | public static void SetCommandId(this RibbonItem item, string id) 14 | { 15 | RibbonTab parentTab; 16 | RibbonPanel parentPanel; 17 | item.Id = id; 18 | ComponentManager.Ribbon.FindItem(item.Id, false, out parentPanel, out parentTab, true); 19 | 20 | if (parentTab == null || parentPanel == null) 21 | return; 22 | 23 | if (string.IsNullOrEmpty(parentTab.Id)) 24 | parentTab.Id = Guid.NewGuid().ToString(); 25 | 26 | if (string.IsNullOrEmpty(parentPanel.Source.Id)) 27 | parentPanel.Source.Id = Guid.NewGuid().ToString(); 28 | item.GenerateId(parentPanel.Source.Id, id); 29 | } 30 | 31 | public static void GenerateId(this RibbonItem item, string parentId, string name) 32 | { 33 | item.Id = $"CustomCtrl_%{parentId}%{name}"; 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /Test/TestSchema.cs: -------------------------------------------------------------------------------- 1 | using System.Web.Script.Serialization; 2 | using Autodesk.Revit.Attributes; 3 | using Autodesk.Revit.DB; 4 | using Autodesk.Revit.UI; 5 | using Techyard.Revit.Attributes; 6 | using Techyard.Revit.Database; 7 | using Techyard.Revit.Misc.SchemaDesigner; 8 | using Techyard.Revit.UI; 9 | 10 | namespace Test 11 | { 12 | [Transaction(TransactionMode.Manual)] 13 | public class TestSchema : IExternalCommand 14 | { 15 | public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) 16 | { 17 | var uiDocument = commandData.Application.ActiveUIDocument; 18 | var document = uiDocument.Document; 19 | var element = uiDocument.Selection.SelectSingle(document); 20 | var mySchema = new CustomSchema { Editor = "Kennan", Age = 26 }; 21 | element.WriteData(mySchema); 22 | var value = element.ReadData(new CustomSchema()); 23 | TaskDialog.Show("Value", new JavaScriptSerializer().Serialize(value)); 24 | return Result.Succeeded; 25 | } 26 | } 27 | 28 | [Schema(Name = "MySchema", Guid = "09A33462-4979-49F0-A15E-90DFE444C243")] 29 | public class CustomSchema : SchemaBase 30 | { 31 | [SchemaField(Name = "Editor")] 32 | public string Editor { get; set; } 33 | 34 | [SchemaField(Name = "Age")] 35 | public int Age { get; set; } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /RevitAPIToolbox/Database/DocumentExtension.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using Autodesk.Revit.DB; 4 | 5 | namespace Techyard.Revit.Database 6 | { 7 | public static class DocumentExtension 8 | { 9 | public static View3D New3DView(this Document document, string name) 10 | { 11 | var viewFamilyType = 12 | new FilteredElementCollector(document).OfClass(typeof(ViewFamilyType)) 13 | .Cast() 14 | .FirstOrDefault(type => type.ViewFamily == ViewFamily.ThreeDimensional); 15 | return null == viewFamilyType ? null : View3D.CreateIsometric(document, viewFamilyType.Id); 16 | } 17 | 18 | public static bool Modify(this Document document, Action action) 19 | { 20 | return document.Modify(action, Guid.NewGuid().ToString()); 21 | } 22 | 23 | public static bool Modify(this Document document, Action action, string purpose) 24 | { 25 | using (var transaction = new Transaction(document, purpose)) 26 | { 27 | try 28 | { 29 | transaction.Start(); 30 | action?.Invoke(); 31 | transaction.Commit(); 32 | return true; 33 | } 34 | catch (Exception) 35 | { 36 | transaction.RollBack(); 37 | return false; 38 | } 39 | } 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /Test/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Test")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("Test")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("501c6034-9d52-4249-8ca2-572796932003")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /RevitAPIToolbox/Misc/CurveDivide/ControlledCurveDivider.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using Autodesk.Revit.DB; 4 | using Techyard.Revit.Attributes; 5 | using Techyard.Revit.Database; 6 | 7 | namespace Techyard.Revit.Misc.CurveDivide 8 | { 9 | [TargetType(typeof(HermiteSpline), typeof(NurbSpline), typeof(CylindricalHelix), typeof(Ellipse))] 10 | internal class ControlledCurveDivider : CurveDivider 11 | { 12 | internal override IEnumerable Divide(Curve curve, int number) 13 | { 14 | var length = curve.Length; 15 | var lengthEach = length / number; 16 | var accumulatedLength = 0D; 17 | XYZ lastPoint = null; 18 | return base.Divide(curve, number * 10).Take(number * 10 - 1).Select(point => 19 | { 20 | if (null == lastPoint) 21 | { 22 | lastPoint = point; 23 | return null; 24 | } 25 | var tempLength = point.DistanceTo(lastPoint); 26 | if (accumulatedLength + tempLength < lengthEach) 27 | { 28 | accumulatedLength += tempLength; 29 | return null; 30 | } 31 | var result = lastPoint.LinearInterpolation(point, lengthEach - accumulatedLength); 32 | accumulatedLength = accumulatedLength + tempLength - lengthEach; 33 | return result; 34 | }).Where(point => point != null); 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /RevitAPIToolbox/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | 8 | [assembly: AssemblyTitle("RevitAPIExtensions")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("RevitAPIExtensions")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | 21 | [assembly: ComVisible(false)] 22 | 23 | // The following GUID is for the ID of the typelib if this project is exposed to COM 24 | 25 | [assembly: Guid("4a64d10e-577c-456a-990d-e5ae631359d1")] 26 | 27 | // Version information for an assembly consists of the following four values: 28 | // 29 | // Major Version 30 | // Minor Version 31 | // Build Number 32 | // Revision 33 | // 34 | // You can specify all the values or you can default the Build and Revision Numbers 35 | // by using the '*' as shown below: 36 | // [assembly: AssemblyVersion("1.0.*")] 37 | 38 | [assembly: AssemblyVersion("1.0.0.0")] 39 | [assembly: AssemblyFileVersion("1.0.0.0")] -------------------------------------------------------------------------------- /RevitAPIWheel/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("RevitAPIWheel")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("RevitAPIWheel")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("eae03093-34ef-4159-884a-8e7d00556ab0")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /RevitAPIToolbox/Database/FamilyExtension.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using Autodesk.Revit.DB; 5 | using Techyard.Revit.Common; 6 | 7 | namespace Techyard.Revit.Database 8 | { 9 | public static class FamilyExtension 10 | { 11 | public static ElementId GetCategoryId(this Family family) 12 | { 13 | try 14 | { 15 | return family.FamilyCategory.Id; 16 | } 17 | catch 18 | { 19 | return GetFamilySymbols(family).FirstOrDefault()?.Category?.Id; 20 | } 21 | } 22 | 23 | internal static IEnumerable GetFamilySymbols(this Family family) 24 | { 25 | var document = family.Document; 26 | try 27 | { 28 | #if REVIT2014 29 | return family.Symbols.AsList(); 30 | #elif REVIT2015 || REVIT2016 || REVIT2017 || REVIT2018 31 | return 32 | family.GetFamilySymbolIds() 33 | .Map(symbolId => document.GetElement(symbolId) as FamilySymbol) 34 | .Where(symbol => symbol != null); 35 | #endif 36 | } 37 | catch 38 | { 39 | return 40 | new FilteredElementCollector(document).OfClass(typeof(FamilySymbol)) 41 | .Cast() 42 | .Where(symbol => family.Id.Equals(symbol.Family.Id)); 43 | } 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /RevitAPIToolbox2014/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("RevitAPIToolbox2014")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("RevitAPIToolbox2014")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("25973226-7287-47ee-a456-aad545f226e3")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /RevitAPIToolbox2015/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("RevitAPIToolbox2015")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("RevitAPIToolbox2015")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("4d4c1d78-d2a7-40e7-8a85-4d6c876e0c0c")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /RevitAPIToolbox2016/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("RevitAPIToolbox2016")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("RevitAPIToolbox2016")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("2e4f1590-b9b8-438a-8ec4-a4f6751c3b25")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /RevitAPIToolbox2017/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("RevitAPIToolbox2017")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("RevitAPIToolbox2017")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("857aed45-ca4d-4bcc-b027-7b5a2af06933")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /RevitAPIToolbox2018/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("RevitAPIToolbox2018")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("RevitAPIToolbox2018")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("c8ad8c48-f4ae-4c84-87bb-88e838099f05")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /RevitAPIToolbox/Misc/CurveDivide/CurveDivider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Concurrent; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Reflection; 6 | using Autodesk.Revit.DB; 7 | using Techyard.Revit.Attributes; 8 | using Techyard.Revit.Common; 9 | 10 | namespace Techyard.Revit.Misc.CurveDivide 11 | { 12 | [TargetType(typeof(Line), typeof(Arc))] 13 | internal class CurveDivider 14 | { 15 | private static IDictionary Dividers { get; } = 16 | new ConcurrentDictionary(); 17 | 18 | internal virtual IEnumerable Divide(Curve curve, int number) 19 | { 20 | return number.TraverseFrom(1, x => curve.Evaluate(1D / x, true)).ToList(); 21 | } 22 | 23 | internal static ICurveDivider GetDivider(Type curveType) 24 | { 25 | if (Dividers.ContainsKey(curveType)) 26 | return Dividers[curveType]; 27 | var dividerType = 28 | Assembly.GetExecutingAssembly() 29 | .GetTypes() 30 | .FirstOrDefault( 31 | t => t.GetCustomAttributes(typeof(TargetTypeAttribute), false) 32 | .Cast() 33 | .FirstOrDefault(attribute => attribute.Types.Contains(curveType)) != null); 34 | if (null == dividerType) throw new Exception("No divider defined to handle this kind of Curve"); 35 | var divider = Activator.CreateInstance(dividerType) as ICurveDivider; 36 | if (null == divider) throw new Exception($"Fail to create instance of {dividerType.FullName}"); 37 | Dividers.Add(curveType, divider); 38 | return divider; 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /RevitAPIToolbox/UI/RibbonCommandItemMixin.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Autodesk.Windows; 4 | using UIFramework; 5 | using UIFrameworkServices; 6 | 7 | namespace Techyard.Revit.UI 8 | { 9 | public static class RibbonCommandItemMixin 10 | { 11 | public static bool SetShortCut(this RibbonCommandItem commandItem, string key) 12 | { 13 | try 14 | { 15 | if (commandItem == null || string.IsNullOrEmpty(key)) 16 | return false; 17 | 18 | RibbonTab parentTab; 19 | RibbonPanel parentPanel; 20 | var commandId = ControlHelper.GetCommandId(commandItem); 21 | 22 | if (string.IsNullOrEmpty(commandId)) 23 | { 24 | commandId = Guid.NewGuid().ToString(); 25 | ControlHelper.SetCommandId(commandItem, commandId); 26 | } 27 | 28 | ComponentManager.Ribbon.FindItem(commandItem.Id, false, out parentPanel, out parentTab, true); 29 | 30 | if (parentTab == null || parentPanel == null) 31 | return false; 32 | 33 | var path = $"{parentTab.Id}>{parentPanel.Source.Id}"; 34 | 35 | var shortcutItem = new ShortcutItem(commandItem.Text, commandId, key, path) 36 | { 37 | ShortcutType = StType.RevitAPI 38 | }; 39 | KeyboardShortcutService.applyShortcutChanges( 40 | new Dictionary 41 | { 42 | { 43 | commandId, shortcutItem 44 | } 45 | }); 46 | return true; 47 | } 48 | catch (Exception) 49 | { 50 | return false; 51 | } 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /RevitAPIToolbox/UI/SelectionExtension.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using Autodesk.Revit.DB; 5 | using Autodesk.Revit.UI.Selection; 6 | 7 | namespace Techyard.Revit.UI 8 | { 9 | public static class SelectionExtension 10 | { 11 | public static IEnumerable SelectByRectangle(this Selection selection, 12 | Func filter = null) 13 | { 14 | return selection.PickElementsByRectangle(new SelectionFilter(filter)); 15 | } 16 | 17 | public static IEnumerable SelectMany(this Selection selection, Document document, 18 | Func filter = null) 19 | { 20 | return selection.PickObjects(ObjectType.Element, new SelectionFilter(filter)) 21 | .Select(document.GetElement); 22 | } 23 | 24 | public static Element SelectSingle(this Selection selection, Document document, Func filter = null) 25 | { 26 | return document.GetElement(selection.PickObject(ObjectType.Element, 27 | new SelectionFilter(filter))); 28 | } 29 | 30 | private class SelectionFilter : ISelectionFilter 31 | { 32 | private Func ElementFilter { get; } 33 | private Func ReferenceFilter { get; } 34 | 35 | internal SelectionFilter(Func elementFilter, 36 | Func referenceFilter = null) 37 | { 38 | ElementFilter = elementFilter; 39 | ReferenceFilter = referenceFilter; 40 | } 41 | 42 | public bool AllowElement(Element elem) 43 | { 44 | return null == ElementFilter || ElementFilter(elem); 45 | } 46 | 47 | public bool AllowReference(Reference reference, XYZ position) 48 | { 49 | return null == ReferenceFilter || ReferenceFilter(reference, position); 50 | } 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /RevitAPIToolbox/Common/TypeExtension.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Reflection; 4 | 5 | namespace Techyard.Revit.Common 6 | { 7 | public static class TypeExtension 8 | { 9 | //public static MethodInfo GetMethod(this Type type, string name, params Type[] types) 10 | //{ 11 | // return type.GetMethod( 12 | // name, 13 | // BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, 14 | // null, 15 | // types, 16 | // null); 17 | //} 18 | 19 | //public static MethodInfo GetGenericMethod(this Type type, string name, Type[] genericTypes, Type[] paramTypes) 20 | //{ 21 | // var resultMethod = type.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance) 22 | // .FirstOrDefault(method => 23 | // { 24 | // if (method.Name != name) return false; 25 | // if (!method.IsGenericMethod) return false; 26 | // var genericArgs = method.GetGenericArguments(); 27 | // if (genericArgs.Length != genericTypes.Length) 28 | // return false; 29 | // for (var i = 0; i < genericTypes.Length; i++) 30 | // { 31 | // if (genericArgs[i] != genericTypes[i]) 32 | // return false; 33 | // } 34 | // var parameters = method.GetParameters(); 35 | // if (parameters.Length != paramTypes.Length) 36 | // return false; 37 | // for (var i = 0; i < paramTypes.Length; i++) 38 | // { 39 | // if (paramTypes[i] != parameters[i].ParameterType) 40 | // return false; 41 | // } 42 | // return true; 43 | // })?.MakeGenericMethod(genericTypes); 44 | // if (null == resultMethod) 45 | // throw new MissingMethodException(); 46 | // return resultMethod; 47 | //} 48 | } 49 | } -------------------------------------------------------------------------------- /Test/TestExternalEventHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Autodesk.Revit.Attributes; 3 | using Autodesk.Revit.DB; 4 | using Autodesk.Revit.UI; 5 | using Techyard.Revit.Common; 6 | 7 | namespace Test 8 | { 9 | [Transaction(TransactionMode.Manual)] 10 | public class TestExternalEventHandler : IExternalCommand 11 | { 12 | public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) 13 | { 14 | ExternalEvent.Create(new DelegateExternalEventHandler("刘一", 15 | (app, p) => { TaskDialog.Show("外部事件", $"调用:{p}"); })).Raise(); 16 | ExternalEvent.Create(new DelegateExternalEventHandler("陈二", 17 | (app, p) => { TaskDialog.Show("外部事件", $"调用:{p}"); })).Raise(); 18 | ExternalEvent.Create(new DelegateExternalEventHandler("张三", 19 | (app, p) => { TaskDialog.Show("外部事件", $"调用:{p}"); })).Raise(); 20 | ExternalEvent.Create(new DelegateExternalEventHandler("李四", 21 | (app, p) => { TaskDialog.Show("外部事件", $"调用:{p}"); })).Raise(); 22 | ExternalEvent.Create(new DelegateExternalEventHandler("王五", 23 | (app, p) => { TaskDialog.Show("外部事件", $"调用:{p}"); })).Raise(); 24 | ExternalEvent.Create(new DelegateExternalEventHandler("赵六", 25 | (app, p) => { TaskDialog.Show("外部事件", $"调用:{p}"); })).Raise(); 26 | ExternalEvent.Create(new DelegateExternalEventHandler("孙七", 27 | (app, p) => { TaskDialog.Show("外部事件", $"调用:{p}"); })).Raise(); 28 | ExternalEvent.Create(new DelegateExternalEventHandler("周八", 29 | (app, p) => { TaskDialog.Show("外部事件", $"调用:{p}"); })).Raise(); 30 | ExternalEvent.Create(new DelegateExternalEventHandler("吴九", 31 | (app, p) => { TaskDialog.Show("外部事件", $"调用:{p}"); })).Raise(); 32 | ExternalEvent.Create(new DelegateExternalEventHandler("郑十", 33 | (app, p) => { TaskDialog.Show("外部事件", $"调用:{p}"); })).Raise(); 34 | TaskDialog.Show("Message", "你会先看到这一条"); 35 | return Result.Succeeded; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /RevitAPIToolbox/Common/DoubleExtension.cs: -------------------------------------------------------------------------------- 1 | using Autodesk.Revit.DB; 2 | 3 | namespace Techyard.Revit.Common 4 | { 5 | internal static class DoubleExtension 6 | { 7 | /// 8 | /// Convert a value in millimeter to revit internal unit 9 | /// 10 | /// Value in millimeter 11 | /// Value in feet 12 | internal static double MillimeterToInternal(this double millimeter) 13 | { 14 | return millimeter.ToInternal(DisplayUnitType.DUT_MILLIMETERS); 15 | } 16 | 17 | /// 18 | /// Convert a value in square millimeter to revit internal unit 19 | /// 20 | /// Value in square millimeter 21 | /// Value in square feet 22 | internal static double SquareMillimeterToInternal(this double squareMillimeter) 23 | { 24 | return squareMillimeter.ToInternal(DisplayUnitType.DUT_SQUARE_MILLIMETERS); 25 | } 26 | 27 | /// 28 | /// Convert a value in cube millimeter to revit internal unit 29 | /// 30 | /// Value in cube millimeter 31 | /// Value in cube feet 32 | internal static double CubeMillimeterToInternal(this double cubeMillimeter) 33 | { 34 | return cubeMillimeter.ToInternal(DisplayUnitType.DUT_CUBIC_MILLIMETERS); 35 | } 36 | 37 | /// 38 | /// Convert a value to revit internal unit 39 | /// 40 | /// Value 41 | /// Unit 42 | /// Value in revit internal unit 43 | internal static double ToInternal(this double value, DisplayUnitType unit) 44 | { 45 | return UnitUtils.ConvertToInternalUnits(value, unit); 46 | } 47 | 48 | /// 49 | /// Convert a value to revit display unit 50 | /// 51 | /// Value 52 | /// Unit 53 | /// Value in revit internal unit 54 | internal static double ToDisplay(this double value, DisplayUnitType unit) 55 | { 56 | return UnitUtils.ConvertFromInternalUnits(value, unit); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /RevitAPIToolbox/Database/PlaneExtension.cs: -------------------------------------------------------------------------------- 1 | using Autodesk.Revit.DB; 2 | 3 | namespace Techyard.Revit.Database 4 | { 5 | public static class PlaneExtension 6 | { 7 | /// 8 | /// Intersects the Line with current plane 9 | /// 10 | /// Invoking point 11 | /// Target line 12 | /// Intersection result object 13 | /// Intersection status 14 | public static SetComparisonResult Intersect(this Plane plane, Line line, out IntersectionResultArray result) 15 | { 16 | var startPojection = plane.Project(line.GetEndPoint(0)); 17 | var endProjection = plane.Project(line.GetEndPoint(1)); 18 | var projectionLine = line.IsBound 19 | ? Line.CreateBound(startPojection, endProjection) 20 | : Line.CreateUnbound(startPojection, endProjection - startPojection); 21 | return line.Intersect(projectionLine, out result); 22 | } 23 | 24 | /// 25 | /// Get a value indicating that a point resides 26 | /// 27 | /// Invoking plane 28 | /// Target point 29 | /// A value indicating whether the point is inside the plane 30 | public static bool ContainsPoint(this Plane plane, XYZ point) 31 | { 32 | return point.IsAlmostEqualTo(plane.Origin) || (point - plane.Origin).DotProduct(plane.Normal).Equals(0); 33 | } 34 | 35 | /// 36 | /// Project the point on the plane 37 | /// 38 | /// Invoking plane 39 | /// Target point 40 | /// Projection point 41 | public static XYZ Project(this Plane plane, XYZ point) 42 | { 43 | if (plane.ContainsPoint(point)) return point; 44 | using (var transform = Transform.Identity) 45 | { 46 | transform.BasisX = plane.XVec; 47 | transform.BasisY = plane.YVec; 48 | transform.BasisZ = plane.Normal; 49 | transform.Origin = plane.Origin; 50 | var pointInPlaneCoordinate = transform.Inverse.OfPoint(point); 51 | var pointOnPlane = new XYZ(pointInPlaneCoordinate.X, pointInPlaneCoordinate.Y, 0); 52 | return transform.OfPoint(pointOnPlane); 53 | } 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /RevitAPIToolbox/Database/ViewExtension.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using Autodesk.Revit.DB; 5 | 6 | namespace Techyard.Revit.Database 7 | { 8 | public static class ViewExtension 9 | { 10 | /// 11 | /// Hide a collection of elements in a specific view 12 | /// 13 | /// A view where the elements is to hide 14 | /// A collection of elements to hide 15 | public static void HideElementsInView(this View view, IEnumerable elements) 16 | { 17 | view.HideElementsInView(elements, true); 18 | } 19 | 20 | /// 21 | /// Hide a collection of elements in a specific view 22 | /// 23 | /// A view where the elements is to hide 24 | /// A collection of elements to hide 25 | public static void ShowElementsInView(this View view, IEnumerable elements) 26 | { 27 | view.HideElementsInView(elements, false); 28 | } 29 | 30 | /// 31 | /// Hide a collection of elements in a specific view 32 | /// 33 | /// A view where the elements is to hide 34 | /// A collection of elements to hide 35 | /// Hide or show 36 | private static void HideElementsInView(this View view, IEnumerable elements, bool hide) 37 | { 38 | try 39 | { 40 | if (null == view) 41 | return; 42 | var document = view.Document; 43 | var elementsToHide = elements 44 | .Where(element => element.Id != view.Id) 45 | .Where(element => element.CanBeHidden(view)) 46 | .Select(element => element.Id).ToArray(); 47 | if (!elementsToHide.Any()) 48 | return; 49 | using (var transaction = new Transaction(document, "Hide Elements")) 50 | { 51 | transaction.Start(); 52 | if (hide) 53 | view.HideElements(elementsToHide); 54 | else 55 | view.UnhideElements(elementsToHide); 56 | transaction.Commit(); 57 | } 58 | } 59 | catch (Exception) 60 | { 61 | // ignored 62 | } 63 | } 64 | } 65 | } -------------------------------------------------------------------------------- /RevitAPIToolbox/Common/ExternalEventManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Autodesk.Revit.UI; 4 | 5 | namespace Techyard.Revit.Common 6 | { 7 | public class ExternalEventManager 8 | { 9 | private ExternalEventManager() 10 | { 11 | } 12 | 13 | private IDictionary Events { get; } = 14 | new Dictionary(); 15 | 16 | public static ExternalEventManager Manager { get; } = new ExternalEventManager(); 17 | 18 | public bool Register(T handler) where T : IExternalEventHandler 19 | { 20 | var type = typeof(T); 21 | lock (Events) 22 | { 23 | if (Events.ContainsKey(type)) return false; 24 | Events.Add(type, new ExternalEventPair(ExternalEvent.Create(handler), handler)); 25 | return true; 26 | } 27 | } 28 | 29 | public bool Raise() where T : IExternalEventHandler 30 | { 31 | var type = typeof(T); 32 | return Events.ContainsKey(type) && PrivateRaise(type); 33 | } 34 | 35 | public bool Raise(TParameter parameter) 36 | where THandler : ParameterizedExternalEventHandler 37 | { 38 | var type = typeof(THandler); 39 | if (!Events.ContainsKey(type)) return false; 40 | if (!(Events[type].EventHandler is ParameterizedExternalEventHandler handler)) return false; 41 | handler.EventParameter = parameter; 42 | return PrivateRaise(type); 43 | } 44 | 45 | private bool PrivateRaise(Type type) 46 | { 47 | var request = Events[type].EventTrigger.Raise(); 48 | switch (request) 49 | { 50 | case ExternalEventRequest.Pending: 51 | case ExternalEventRequest.Accepted: 52 | return true; 53 | case ExternalEventRequest.Denied: 54 | case ExternalEventRequest.TimedOut: 55 | return false; 56 | default: 57 | return false; 58 | } 59 | } 60 | 61 | private struct ExternalEventPair 62 | { 63 | internal ExternalEventPair(ExternalEvent trigger, IExternalEventHandler handler) 64 | { 65 | EventTrigger = trigger; 66 | EventHandler = handler; 67 | } 68 | 69 | internal ExternalEvent EventTrigger { get; } 70 | internal IExternalEventHandler EventHandler { get; } 71 | } 72 | } 73 | } -------------------------------------------------------------------------------- /RevitAPIToolbox/Database/ElementExtension.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Autodesk.Revit.DB; 3 | using Autodesk.Revit.DB.ExtensibleStorage; 4 | using Techyard.Revit.Misc.SchemaDesigner; 5 | 6 | namespace Techyard.Revit.Database 7 | { 8 | public static class ElementExtension 9 | { 10 | public static ElementType GetElementType(this Element element) 11 | { 12 | return element.Document.GetElement(element.GetTypeId()) as ElementType; 13 | } 14 | 15 | public static T ReadData(this Element element, T data) where T : SchemaBase 16 | { 17 | var schema = data.GetOrCreateSchema(); 18 | var entity = element.GetEntity(schema); 19 | data.ExtractData(entity); 20 | return data; 21 | } 22 | 23 | public static T ReadData(this Element element, Schema schema, string fieldName) 24 | { 25 | var field = schema.GetField(fieldName); 26 | var entity = element.GetEntity(schema); 27 | return entity.IsValid() ? entity.Get(field) : default(T); 28 | } 29 | 30 | public static bool WriteData(this Element element, T data, bool withTransaction = true) where T : SchemaBase 31 | { 32 | var action = new Action(() => 33 | { 34 | var schema = data.GetOrCreateSchema(); 35 | var entity = new Entity(schema); 36 | data.FillData(entity); 37 | element.SetEntity(entity); 38 | }); 39 | try 40 | { 41 | if (withTransaction) 42 | return element.Document.Modify(action, "Write entity"); 43 | action(); 44 | return true; 45 | } 46 | catch (Exception e) 47 | { 48 | Console.WriteLine(e); 49 | return false; 50 | } 51 | } 52 | 53 | public static bool WriteData(this Element element, Schema schema, string fieldName, T data, 54 | bool withTransaction = true) 55 | where T : class 56 | { 57 | var action = new Action(() => 58 | { 59 | var entity = new Entity(schema); 60 | var field = schema.GetField(fieldName); 61 | entity.Set(field, data); 62 | element.SetEntity(entity); 63 | }); 64 | try 65 | { 66 | if (withTransaction) 67 | return element.Document.Modify(action, "Write entity"); 68 | action(); 69 | return true; 70 | } 71 | catch (Exception e) 72 | { 73 | Console.WriteLine(e); 74 | return false; 75 | } 76 | } 77 | } 78 | } -------------------------------------------------------------------------------- /RevitAPIToolbox/Geometry/FilteredGeometryCollector.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using Autodesk.Revit.DB; 5 | 6 | namespace Techyard.Revit.Geometry 7 | { 8 | public class FilteredGeometryCollector : IEnumerable 9 | { 10 | private List Filters { get; } = new List(); 11 | private Element SourceElement { get; } 12 | 13 | public FilteredGeometryCollector(Element element) 14 | { 15 | SourceElement = element; 16 | } 17 | 18 | public IEnumerator GetEnumerator() 19 | { 20 | return new InnerEnumerator(SourceElement, Filters); 21 | } 22 | 23 | IEnumerator IEnumerable.GetEnumerator() 24 | { 25 | return GetEnumerator(); 26 | } 27 | 28 | public FilteredGeometryCollector OfClass() where T : GeometryObject 29 | { 30 | return WherePasses(new GeometryClassFilter(typeof(T))); 31 | } 32 | 33 | public FilteredGeometryCollector WherePasses(IGeometryFilter filter) 34 | { 35 | Filters.Add(filter); 36 | return this; 37 | } 38 | 39 | public IEnumerable ToGeometryObjects() 40 | { 41 | var iterator = GetEnumerator(); 42 | iterator.Reset(); 43 | while (iterator.MoveNext()) 44 | { 45 | yield return iterator.Current; 46 | } 47 | iterator.Dispose(); 48 | } 49 | 50 | private class InnerEnumerator : IEnumerator 51 | { 52 | private GeometryElement Geometry { get; set; } 53 | 54 | private List _objects; 55 | 56 | private List Filters { get; } 57 | 58 | private IEnumerable Objects => _objects ?? 59 | (_objects = Geometry?.GetObjects().Where(go => 60 | Filters.Count == 0 || 61 | Filters.All(filter => filter.Filter(go))).ToList()); 62 | 63 | private int Position { get; set; } = -1; 64 | 65 | public int Count => Objects.Count(); 66 | 67 | public InnerEnumerator(Element element, List filters = null, Options options = null) 68 | { 69 | Geometry = element.get_Geometry(options ?? new Options()); 70 | Filters = filters ?? new List(); 71 | } 72 | 73 | public void Dispose() 74 | { 75 | _objects.Clear(); 76 | _objects = null; 77 | Geometry = null; 78 | } 79 | 80 | public bool MoveNext() 81 | { 82 | if (Position + 1 == Count) 83 | { 84 | return false; 85 | } 86 | Position++; 87 | return true; 88 | } 89 | 90 | public void Reset() 91 | { 92 | Position = -1; 93 | } 94 | 95 | public GeometryObject Current => Objects.ElementAt(Position); 96 | 97 | object IEnumerator.Current => Current; 98 | } 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /RevitAPIToolbox/UI/UIFactory.cs: -------------------------------------------------------------------------------- 1 | #region References 2 | 3 | using System; 4 | using System.Linq; 5 | using System.Windows.Media; 6 | using Autodesk.Windows; 7 | 8 | #endregion 9 | 10 | namespace Techyard.Revit.UI 11 | { 12 | public class UIFactory 13 | { 14 | private UIFactory() 15 | { 16 | } 17 | 18 | public static UIFactory Factory { get; } = new UIFactory(); 19 | 20 | private RibbonTab CreateTab(string tabName) 21 | { 22 | var tab = new RibbonTab 23 | { 24 | Name = tabName, 25 | Title = tabName, 26 | Id = tabName 27 | }; 28 | return tab; 29 | } 30 | 31 | public RibbonTab FindTab(string tabName, bool createIfAbsent = false) 32 | { 33 | var tab = ComponentManager.Ribbon.Tabs.FirstOrDefault(t => t.Title.Equals(tabName)); 34 | if (null == tab && createIfAbsent) 35 | tab = CreateTab(tabName); 36 | return tab; 37 | } 38 | 39 | public void SetTabColor(string tabName, Color color) 40 | { 41 | var tab = FindTab(tabName, true); 42 | tab.Theme.TabHeaderBackground = new SolidColorBrush(color); 43 | } 44 | 45 | public RibbonPanel CreatePanel(string tabName, string panelName) 46 | { 47 | var tab = FindTab(tabName, true); 48 | var panel = new RibbonPanel 49 | { 50 | Source = new RibbonPanelSource 51 | { 52 | Title = panelName, 53 | Name = panelName, 54 | Id = ControlUtility.GenerateId(tab.Id, panelName) 55 | } 56 | }; 57 | tab.Panels.Add(panel); 58 | return panel; 59 | } 60 | 61 | public RibbonPanel FindPanel(string tabName, string panelName, bool createIfAbsent = false) 62 | { 63 | var tab = FindTab(tabName, createIfAbsent); 64 | var panel = tab?.Panels.FirstOrDefault(p => p.Source.Name.Equals(panelName)); 65 | if (null == panel && createIfAbsent) 66 | panel = CreatePanel(tabName, panelName); 67 | return panel; 68 | } 69 | 70 | public T CreateItem(string tabName, string panelName, string itemName, Action callback = null) 71 | where T : RibbonItem 72 | { 73 | var panel = FindPanel(tabName, panelName, true); 74 | var item = Activator.CreateInstance(); 75 | item.GenerateId(panel.Source.Id, itemName); 76 | item.Name = itemName; 77 | panel.Source.Items.Add(item); 78 | callback?.Invoke(item); 79 | return item; 80 | } 81 | 82 | public T CreateItem(string itemName, Action callback) where T : RibbonItem 83 | { 84 | var item = Activator.CreateInstance(); 85 | item.Name = itemName; 86 | callback?.Invoke(item); 87 | return item; 88 | } 89 | 90 | public T FindItem(string tabName, string panelName, string itemName, bool createIfAbsent = false) 91 | where T : RibbonItem 92 | { 93 | var panel = FindPanel(tabName, panelName, true); 94 | var item = panel?.Source.Items.FirstOrDefault(b => b.Name.Equals(itemName)) as T; 95 | if (null == item && createIfAbsent) 96 | item = CreateItem(tabName, panelName, itemName); 97 | return item; 98 | } 99 | } 100 | } -------------------------------------------------------------------------------- /Test/Test.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {501C6034-9D52-4249-8CA2-572796932003} 8 | Library 9 | Properties 10 | Test 11 | Test 12 | v4.6 13 | 512 14 | 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | false 25 | 26 | 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | false 34 | 35 | 36 | 37 | ..\packages\Revit-2018.1-x64.Base.1.0.0\lib\net46\AdWindows.dll 38 | False 39 | 40 | 41 | ..\packages\Revit-2018.1-x64.Base.1.0.0\lib\net46\RevitAPI.dll 42 | False 43 | 44 | 45 | ..\packages\Revit-2018.1-x64.Base.1.0.0\lib\net46\RevitAPIIFC.dll 46 | False 47 | 48 | 49 | ..\packages\Revit-2018.1-x64.Base.1.0.0\lib\net46\RevitAPIMacros.dll 50 | False 51 | 52 | 53 | ..\packages\Revit-2018.1-x64.Base.1.0.0\lib\net46\RevitAPIUI.dll 54 | False 55 | 56 | 57 | ..\packages\Revit-2018.1-x64.Base.1.0.0\lib\net46\RevitAPIUIMacros.dll 58 | False 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | {c8ad8c48-f4ae-4c84-87bb-88e838099f05} 79 | RevitAPIToolbox2018 80 | 81 | 82 | 83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /RevitAPIWheel/RevitAPIWheel.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {EAE03093-34EF-4159-884A-8E7D00556AB0} 8 | Library 9 | Properties 10 | Techyard.Revit.Wheel 11 | RevitAPIWheel 12 | v4.6 13 | 512 14 | 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | false 25 | 26 | 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | false 34 | 35 | 36 | 37 | ..\packages\Revit-2018.1-x64.Base.1.0.0\lib\net46\AdWindows.dll 38 | False 39 | 40 | 41 | ..\packages\Revit-2018.1-x64.Base.1.0.0\lib\net46\RevitAPI.dll 42 | False 43 | 44 | 45 | ..\packages\Revit-2018.1-x64.Base.1.0.0\lib\net46\RevitAPIIFC.dll 46 | False 47 | 48 | 49 | ..\packages\Revit-2018.1-x64.Base.1.0.0\lib\net46\RevitAPIMacros.dll 50 | False 51 | 52 | 53 | ..\packages\Revit-2018.1-x64.Base.1.0.0\lib\net46\RevitAPIUI.dll 54 | False 55 | 56 | 57 | ..\packages\Revit-2018.1-x64.Base.1.0.0\lib\net46\RevitAPIUIMacros.dll 58 | False 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | Always 79 | 80 | 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /Test/DrawEdge.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using Autodesk.Revit.ApplicationServices; 5 | using Autodesk.Revit.Attributes; 6 | using Autodesk.Revit.DB; 7 | using Autodesk.Revit.UI; 8 | using Techyard.Revit.Common; 9 | using Techyard.Revit.Geometry; 10 | 11 | namespace Test 12 | { 13 | [Transaction(TransactionMode.Manual)] 14 | public class DrawEdge : IExternalCommand 15 | { 16 | private IEnumerable Points { get; } = new[] { XYZ.BasisX, XYZ.BasisY, XYZ.BasisZ }; 17 | 18 | public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) 19 | { 20 | var app = commandData.Application; 21 | //Application.RegisterFailuresProcessor(new FailureProcessor()); 22 | var uiDocument = app.ActiveUIDocument; 23 | var document = uiDocument.Document; 24 | using (var transaction = new Transaction(document, "draw")) 25 | { 26 | transaction.Start(); 27 | var elementList = uiDocument.Selection.GetElementIds().Select(id => document.GetElement(id)).ToList(); 28 | if (elementList.Count == 0) 29 | elementList = new FilteredElementCollector(document) 30 | .WherePasses( 31 | new ElementMulticlassFilter( 32 | new[] 33 | { 34 | typeof(GenericForm), 35 | typeof(FamilyInstance) 36 | })) 37 | .ToList(); 38 | elementList.ForEach(element => 39 | { 40 | try 41 | { 42 | var form = element as GenericForm; 43 | if (null != form && !form.IsSolid) 44 | return; 45 | new FilteredGeometryCollector(element) 46 | .OfClass() 47 | .Cast() 48 | .SelectMany(solid => solid.Edges.AsList()) 49 | .ToList() 50 | .ForEach( 51 | edge => 52 | { 53 | try 54 | { 55 | var curve = edge.AsCurve(); 56 | var sketchFace = edge.GetFace(0) as PlanarFace ?? edge.GetFace(1) as PlanarFace; 57 | var sketchPlane = SketchPlane.Create(document, 58 | null == sketchFace 59 | ? Plane.CreateByThreePoints(curve.GetEndPoint(0), curve.GetEndPoint(1), 60 | Points.First(p => !p.IsAlmostEqualTo(curve.Project(p).XYZPoint))) 61 | : Plane.CreateByNormalAndOrigin(sketchFace.FaceNormal, sketchFace.Origin)); 62 | document.FamilyCreate.NewModelCurve(curve, sketchPlane); 63 | } 64 | catch (Exception e) 65 | { 66 | Console.WriteLine(e); 67 | } 68 | }); 69 | 70 | } 71 | catch (Exception e) 72 | { 73 | Console.WriteLine(e); 74 | } 75 | }); 76 | transaction.Commit(); 77 | } 78 | return Result.Succeeded; 79 | } 80 | } 81 | 82 | public class FailureProcessor : IFailuresProcessor 83 | { 84 | public FailureProcessingResult ProcessFailures(FailuresAccessor data) 85 | { 86 | switch (data.GetSeverity()) 87 | { 88 | case FailureSeverity.Warning: 89 | data.ResolveFailures(data.GetFailureMessages()); 90 | return FailureProcessingResult.ProceedWithCommit; 91 | default: 92 | return FailureProcessingResult.ProceedWithRollBack; 93 | } 94 | } 95 | 96 | public void Dismiss(Document document) 97 | { 98 | 99 | } 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /RevitAPIWheel/ExternalEvent/ExternalEventWheel.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Autodesk.Revit.ApplicationServices; 3 | using Autodesk.Revit.UI; 4 | 5 | namespace Techyard.Revit.Wheel.ExternalEvent 6 | { 7 | /// 8 | /// A simple rebuilt version of Autodesk.Revit.UI.ExternalEvent class 9 | /// Autodesk.Revit.UI.ExternalEvent 的简易轮子,外部事件触发器 10 | /// 11 | public class ExternalEventWheel 12 | { 13 | /// 14 | /// Private constructor 15 | /// 构造函数私有化 16 | /// 17 | /// External event handler 18 | private ExternalEventWheel(IExternalEventHandlerWheel handler) 19 | { 20 | Handler = handler; 21 | } 22 | 23 | /// 24 | /// A queue who holds all the raised external event handler to be executed sequentially 25 | /// 外部事件队列,用于记录被触发的外部事件处理程序 26 | /// 27 | private static Queue Events { get; } = new Queue(); 28 | 29 | /// 30 | /// The external event handler binding to current external event 31 | /// 绑定到当前外部事件的处理程序 32 | /// 33 | private IExternalEventHandlerWheel Handler { get; } 34 | 35 | private static object _app; 36 | 37 | /// 38 | /// Initialize external event system 39 | /// 40 | /// 41 | public static void Initialize(UIApplication app) 42 | { 43 | if (null != _app) return; 44 | _app = app; 45 | app.Idling += App_Idling; 46 | } 47 | 48 | /// 49 | /// Initialize external event system 50 | /// 51 | /// 52 | public static void Initialize(UIControlledApplication app) 53 | { 54 | if (null != _app) return; 55 | _app = app; 56 | app.Idling += App_Idling; 57 | } 58 | 59 | /// 60 | /// Stop the external event system 61 | /// 62 | public static void Destroy() 63 | { 64 | if (null == _app) return; 65 | if (_app is UIApplication) 66 | ((UIApplication)_app).Idling -= App_Idling; 67 | else if (_app is UIControlledApplication) 68 | ((UIControlledApplication)_app).Idling -= App_Idling; 69 | } 70 | 71 | /// 72 | /// An event that revit signals repeatedly at idle time 73 | /// Revit在空闲时间反复调用的回调方法,当做 white(true){} 无限循环使用 74 | /// 75 | /// The revit UI level application 76 | /// Arguments to config the event 77 | private static void App_Idling(object sender, Autodesk.Revit.UI.Events.IdlingEventArgs e) 78 | { 79 | var handler = TryGetEvent(); 80 | if (null == handler) return; 81 | var app = sender as UIApplication; 82 | if (null == app) return; 83 | handler.Execute(app); 84 | } 85 | 86 | /// 87 | /// Create an external event to raise 88 | /// 创建一个外部事件 89 | /// 90 | /// External event handler 91 | /// An external event through which the user can trigger the executing of the handler 92 | public static ExternalEventWheel Create(IExternalEventHandlerWheel handler) 93 | { 94 | //Some other operations may be done here(e.g parameter validating) 95 | return new ExternalEventWheel(handler); 96 | } 97 | 98 | /// 99 | /// Trigger the event so that the revit main process can comsume 100 | /// 触发当前外部事件,让Revit主线程执行事件处理程序 101 | /// 102 | public void Raise() 103 | { 104 | lock (Events) 105 | { 106 | //Add current handler to the queue, waiting to be executed 107 | //将事件处理程序添加到队列,等待执行 108 | Events.Enqueue(Handler); 109 | } 110 | } 111 | 112 | /// 113 | /// Try to get a raised external event 114 | /// 尝试获取一个待执行的处理程序 115 | /// 116 | /// The first external event handler 117 | private static IExternalEventHandlerWheel TryGetEvent() 118 | { 119 | lock (Events) 120 | { 121 | //Get the very first external event handler for the queue 122 | //从队列获取一个事件处理程序 123 | return Events.Count > 0 ? Events.Dequeue() : null; 124 | } 125 | } 126 | } 127 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.suo 8 | *.user 9 | *.userosscache 10 | *.sln.docstates 11 | 12 | # User-specific files (MonoDevelop/Xamarin Studio) 13 | *.userprefs 14 | 15 | # Build results 16 | [Dd]ebug/ 17 | [Dd]ebugPublic/ 18 | [Rr]elease/ 19 | [Rr]eleases/ 20 | x64/ 21 | x86/ 22 | bld/ 23 | [Bb]in/ 24 | [Oo]bj/ 25 | [Ll]og/ 26 | [Bb]uild/ 27 | # Visual Studio 2015 cache/options directory 28 | .vs/ 29 | # Uncomment if you have tasks that create the project's static files in wwwroot 30 | #wwwroot/ 31 | 32 | # MSTest test Results 33 | [Tt]est[Rr]esult*/ 34 | [Bb]uild[Ll]og.* 35 | 36 | # NUNIT 37 | *.VisualState.xml 38 | TestResult.xml 39 | 40 | # Build Results of an ATL Project 41 | [Dd]ebugPS/ 42 | [Rr]eleasePS/ 43 | dlldata.c 44 | 45 | # .NET Core 46 | project.lock.json 47 | project.fragment.lock.json 48 | artifacts/ 49 | **/Properties/launchSettings.json 50 | 51 | *_i.c 52 | *_p.c 53 | *_i.h 54 | *.ilk 55 | *.meta 56 | *.obj 57 | *.pch 58 | *.pdb 59 | *.pgc 60 | *.pgd 61 | *.rsp 62 | *.sbr 63 | *.tlb 64 | *.tli 65 | *.tlh 66 | *.tmp 67 | *.tmp_proj 68 | *.log 69 | *.vspscc 70 | *.vssscc 71 | .builds 72 | *.pidb 73 | *.svclog 74 | *.scc 75 | 76 | # Chutzpah Test files 77 | _Chutzpah* 78 | 79 | # Visual C++ cache files 80 | ipch/ 81 | *.aps 82 | *.ncb 83 | *.opendb 84 | *.opensdf 85 | *.sdf 86 | *.cachefile 87 | *.VC.db 88 | *.VC.VC.opendb 89 | 90 | # Visual Studio profiler 91 | *.psess 92 | *.vsp 93 | *.vspx 94 | *.sap 95 | 96 | # TFS 2012 Local Workspace 97 | $tf/ 98 | 99 | # Guidance Automation Toolkit 100 | *.gpState 101 | 102 | # ReSharper is a .NET coding add-in 103 | _ReSharper*/ 104 | *.[Rr]e[Ss]harper 105 | *.DotSettings.user 106 | 107 | # JustCode is a .NET coding add-in 108 | .JustCode 109 | 110 | # TeamCity is a build add-in 111 | _TeamCity* 112 | 113 | # DotCover is a Code Coverage Tool 114 | *.dotCover 115 | 116 | # Visual Studio code coverage results 117 | *.coverage 118 | *.coveragexml 119 | 120 | # NCrunch 121 | _NCrunch_* 122 | .*crunch*.local.xml 123 | nCrunchTemp_* 124 | 125 | # MightyMoose 126 | *.mm.* 127 | AutoTest.Net/ 128 | 129 | # Web workbench (sass) 130 | .sass-cache/ 131 | 132 | # Installshield output folder 133 | [Ee]xpress/ 134 | 135 | # DocProject is a documentation generator add-in 136 | DocProject/buildhelp/ 137 | DocProject/Help/*.HxT 138 | DocProject/Help/*.HxC 139 | DocProject/Help/*.hhc 140 | DocProject/Help/*.hhk 141 | DocProject/Help/*.hhp 142 | DocProject/Help/Html2 143 | DocProject/Help/html 144 | 145 | # Click-Once directory 146 | publish/ 147 | 148 | # Publish Web Output 149 | *.[Pp]ublish.xml 150 | *.azurePubxml 151 | # TODO: Comment the next line if you want to checkin your web deploy settings 152 | # but database connection strings (with potential passwords) will be unencrypted 153 | *.pubxml 154 | *.publishproj 155 | 156 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 157 | # checkin your Azure Web App publish settings, but sensitive information contained 158 | # in these scripts will be unencrypted 159 | PublishScripts/ 160 | 161 | # NuGet Packages 162 | *.nupkg 163 | # The packages folder can be ignored because of Package Restore 164 | **/packages/* 165 | # except build/, which is used as an MSBuild target. 166 | !**/packages/build/ 167 | # Uncomment if necessary however generally it will be regenerated when needed 168 | #!**/packages/repositories.config 169 | # NuGet v3's project.json files produces more ignorable files 170 | *.nuget.props 171 | *.nuget.targets 172 | 173 | # Microsoft Azure Build Output 174 | csx/ 175 | *.build.csdef 176 | 177 | # Microsoft Azure Emulator 178 | ecf/ 179 | rcf/ 180 | 181 | # Windows Store app package directories and files 182 | AppPackages/ 183 | BundleArtifacts/ 184 | Package.StoreAssociation.xml 185 | _pkginfo.txt 186 | 187 | # Visual Studio cache files 188 | # files ending in .cache can be ignored 189 | *.[Cc]ache 190 | # but keep track of directories ending in .cache 191 | !*.[Cc]ache/ 192 | 193 | # Others 194 | ClientBin/ 195 | ~$* 196 | *~ 197 | *.dbmdl 198 | *.dbproj.schemaview 199 | *.jfm 200 | *.pfx 201 | *.publishsettings 202 | orleans.codegen.cs 203 | 204 | # Since there are multiple workflows, uncomment next line to ignore bower_components 205 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 206 | #bower_components/ 207 | 208 | # RIA/Silverlight projects 209 | Generated_Code/ 210 | 211 | # Backup & report files from converting an old project file 212 | # to a newer Visual Studio version. Backup files are not needed, 213 | # because we have git ;-) 214 | _UpgradeReport_Files/ 215 | Backup*/ 216 | UpgradeLog*.XML 217 | UpgradeLog*.htm 218 | 219 | # SQL Server files 220 | *.mdf 221 | *.ldf 222 | 223 | # Business Intelligence projects 224 | *.rdl.data 225 | *.bim.layout 226 | *.bim_*.settings 227 | 228 | # Microsoft Fakes 229 | FakesAssemblies/ 230 | 231 | # GhostDoc plugin setting file 232 | *.GhostDoc.xml 233 | 234 | # Node.js Tools for Visual Studio 235 | .ntvs_analysis.dat 236 | node_modules/ 237 | 238 | # Typescript v1 declaration files 239 | typings/ 240 | 241 | # Visual Studio 6 build log 242 | *.plg 243 | 244 | # Visual Studio 6 workspace options file 245 | *.opt 246 | 247 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 248 | *.vbw 249 | 250 | # Visual Studio LightSwitch build output 251 | **/*.HTMLClient/GeneratedArtifacts 252 | **/*.DesktopClient/GeneratedArtifacts 253 | **/*.DesktopClient/ModelManifest.xml 254 | **/*.Server/GeneratedArtifacts 255 | **/*.Server/ModelManifest.xml 256 | _Pvt_Extensions 257 | 258 | # Paket dependency manager 259 | .paket/paket.exe 260 | paket-files/ 261 | 262 | # FAKE - F# Make 263 | .fake/ 264 | 265 | # JetBrains Rider 266 | .idea/ 267 | *.sln.iml 268 | 269 | # CodeRush 270 | .cr/ 271 | 272 | # Python Tools for Visual Studio (PTVS) 273 | __pycache__/ 274 | *.pyc 275 | 276 | # Cake - Uncomment if you are using it 277 | # tools/** 278 | # !tools/packages.config 279 | 280 | # Telerik's JustMock configuration file 281 | *.jmconfig 282 | 283 | # BizTalk build output 284 | *.btp.cs 285 | *.btm.cs 286 | *.odx.cs 287 | *.xsd.cs 288 | -------------------------------------------------------------------------------- /RevitAPIToolbox.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27004.2010 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RevitAPIToolbox", "RevitAPIToolbox\RevitAPIToolbox.csproj", "{4A64D10E-577C-456A-990D-E5AE631359D1}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RevitAPIToolbox2014", "RevitAPIToolbox2014\RevitAPIToolbox2014.csproj", "{25973226-7287-47EE-A456-AAD545F226E3}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RevitAPIToolbox2015", "RevitAPIToolbox2015\RevitAPIToolbox2015.csproj", "{4D4C1D78-D2A7-40E7-8A85-4D6C876E0C0C}" 11 | EndProject 12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RevitAPIToolbox2016", "RevitAPIToolbox2016\RevitAPIToolbox2016.csproj", "{2E4F1590-B9B8-438A-8EC4-A4F6751C3B25}" 13 | EndProject 14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RevitAPIToolbox2017", "RevitAPIToolbox2017\RevitAPIToolbox2017.csproj", "{857AED45-CA4D-4BCC-B027-7B5A2AF06933}" 15 | EndProject 16 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RevitAPIToolbox2018", "RevitAPIToolbox2018\RevitAPIToolbox2018.csproj", "{C8AD8C48-F4AE-4C84-87BB-88E838099F05}" 17 | EndProject 18 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RevitAPIWheel", "RevitAPIWheel\RevitAPIWheel.csproj", "{EAE03093-34EF-4159-884A-8E7D00556AB0}" 19 | EndProject 20 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{501C6034-9D52-4249-8CA2-572796932003}" 21 | EndProject 22 | Global 23 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 24 | Debug|Any CPU = Debug|Any CPU 25 | Debug|x64 = Debug|x64 26 | Release|Any CPU = Release|Any CPU 27 | Release|x64 = Release|x64 28 | EndGlobalSection 29 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 30 | {4A64D10E-577C-456A-990D-E5AE631359D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 31 | {4A64D10E-577C-456A-990D-E5AE631359D1}.Debug|Any CPU.Build.0 = Debug|Any CPU 32 | {4A64D10E-577C-456A-990D-E5AE631359D1}.Debug|x64.ActiveCfg = Debug|x64 33 | {4A64D10E-577C-456A-990D-E5AE631359D1}.Debug|x64.Build.0 = Debug|x64 34 | {4A64D10E-577C-456A-990D-E5AE631359D1}.Release|Any CPU.ActiveCfg = Release|Any CPU 35 | {4A64D10E-577C-456A-990D-E5AE631359D1}.Release|Any CPU.Build.0 = Release|Any CPU 36 | {4A64D10E-577C-456A-990D-E5AE631359D1}.Release|x64.ActiveCfg = Release|x64 37 | {4A64D10E-577C-456A-990D-E5AE631359D1}.Release|x64.Build.0 = Release|x64 38 | {25973226-7287-47EE-A456-AAD545F226E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 39 | {25973226-7287-47EE-A456-AAD545F226E3}.Debug|Any CPU.Build.0 = Debug|Any CPU 40 | {25973226-7287-47EE-A456-AAD545F226E3}.Debug|x64.ActiveCfg = Debug|x64 41 | {25973226-7287-47EE-A456-AAD545F226E3}.Debug|x64.Build.0 = Debug|x64 42 | {25973226-7287-47EE-A456-AAD545F226E3}.Release|Any CPU.ActiveCfg = Release|Any CPU 43 | {25973226-7287-47EE-A456-AAD545F226E3}.Release|Any CPU.Build.0 = Release|Any CPU 44 | {25973226-7287-47EE-A456-AAD545F226E3}.Release|x64.ActiveCfg = Release|x64 45 | {25973226-7287-47EE-A456-AAD545F226E3}.Release|x64.Build.0 = Release|x64 46 | {4D4C1D78-D2A7-40E7-8A85-4D6C876E0C0C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 47 | {4D4C1D78-D2A7-40E7-8A85-4D6C876E0C0C}.Debug|Any CPU.Build.0 = Debug|Any CPU 48 | {4D4C1D78-D2A7-40E7-8A85-4D6C876E0C0C}.Debug|x64.ActiveCfg = Debug|x64 49 | {4D4C1D78-D2A7-40E7-8A85-4D6C876E0C0C}.Debug|x64.Build.0 = Debug|x64 50 | {4D4C1D78-D2A7-40E7-8A85-4D6C876E0C0C}.Release|Any CPU.ActiveCfg = Release|Any CPU 51 | {4D4C1D78-D2A7-40E7-8A85-4D6C876E0C0C}.Release|Any CPU.Build.0 = Release|Any CPU 52 | {4D4C1D78-D2A7-40E7-8A85-4D6C876E0C0C}.Release|x64.ActiveCfg = Release|x64 53 | {4D4C1D78-D2A7-40E7-8A85-4D6C876E0C0C}.Release|x64.Build.0 = Release|x64 54 | {2E4F1590-B9B8-438A-8EC4-A4F6751C3B25}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 55 | {2E4F1590-B9B8-438A-8EC4-A4F6751C3B25}.Debug|Any CPU.Build.0 = Debug|Any CPU 56 | {2E4F1590-B9B8-438A-8EC4-A4F6751C3B25}.Debug|x64.ActiveCfg = Debug|x64 57 | {2E4F1590-B9B8-438A-8EC4-A4F6751C3B25}.Debug|x64.Build.0 = Debug|x64 58 | {2E4F1590-B9B8-438A-8EC4-A4F6751C3B25}.Release|Any CPU.ActiveCfg = Release|Any CPU 59 | {2E4F1590-B9B8-438A-8EC4-A4F6751C3B25}.Release|Any CPU.Build.0 = Release|Any CPU 60 | {2E4F1590-B9B8-438A-8EC4-A4F6751C3B25}.Release|x64.ActiveCfg = Release|x64 61 | {2E4F1590-B9B8-438A-8EC4-A4F6751C3B25}.Release|x64.Build.0 = Release|x64 62 | {857AED45-CA4D-4BCC-B027-7B5A2AF06933}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 63 | {857AED45-CA4D-4BCC-B027-7B5A2AF06933}.Debug|Any CPU.Build.0 = Debug|Any CPU 64 | {857AED45-CA4D-4BCC-B027-7B5A2AF06933}.Debug|x64.ActiveCfg = Debug|x64 65 | {857AED45-CA4D-4BCC-B027-7B5A2AF06933}.Debug|x64.Build.0 = Debug|x64 66 | {857AED45-CA4D-4BCC-B027-7B5A2AF06933}.Release|Any CPU.ActiveCfg = Release|Any CPU 67 | {857AED45-CA4D-4BCC-B027-7B5A2AF06933}.Release|Any CPU.Build.0 = Release|Any CPU 68 | {857AED45-CA4D-4BCC-B027-7B5A2AF06933}.Release|x64.ActiveCfg = Release|x64 69 | {857AED45-CA4D-4BCC-B027-7B5A2AF06933}.Release|x64.Build.0 = Release|x64 70 | {C8AD8C48-F4AE-4C84-87BB-88E838099F05}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 71 | {C8AD8C48-F4AE-4C84-87BB-88E838099F05}.Debug|Any CPU.Build.0 = Debug|Any CPU 72 | {C8AD8C48-F4AE-4C84-87BB-88E838099F05}.Debug|x64.ActiveCfg = Debug|x64 73 | {C8AD8C48-F4AE-4C84-87BB-88E838099F05}.Debug|x64.Build.0 = Debug|x64 74 | {C8AD8C48-F4AE-4C84-87BB-88E838099F05}.Release|Any CPU.ActiveCfg = Release|Any CPU 75 | {C8AD8C48-F4AE-4C84-87BB-88E838099F05}.Release|Any CPU.Build.0 = Release|Any CPU 76 | {C8AD8C48-F4AE-4C84-87BB-88E838099F05}.Release|x64.ActiveCfg = Release|x64 77 | {C8AD8C48-F4AE-4C84-87BB-88E838099F05}.Release|x64.Build.0 = Release|x64 78 | {EAE03093-34EF-4159-884A-8E7D00556AB0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 79 | {EAE03093-34EF-4159-884A-8E7D00556AB0}.Debug|Any CPU.Build.0 = Debug|Any CPU 80 | {EAE03093-34EF-4159-884A-8E7D00556AB0}.Debug|x64.ActiveCfg = Debug|Any CPU 81 | {EAE03093-34EF-4159-884A-8E7D00556AB0}.Debug|x64.Build.0 = Debug|Any CPU 82 | {EAE03093-34EF-4159-884A-8E7D00556AB0}.Release|Any CPU.ActiveCfg = Release|Any CPU 83 | {EAE03093-34EF-4159-884A-8E7D00556AB0}.Release|Any CPU.Build.0 = Release|Any CPU 84 | {EAE03093-34EF-4159-884A-8E7D00556AB0}.Release|x64.ActiveCfg = Release|Any CPU 85 | {EAE03093-34EF-4159-884A-8E7D00556AB0}.Release|x64.Build.0 = Release|Any CPU 86 | {501C6034-9D52-4249-8CA2-572796932003}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 87 | {501C6034-9D52-4249-8CA2-572796932003}.Debug|Any CPU.Build.0 = Debug|Any CPU 88 | {501C6034-9D52-4249-8CA2-572796932003}.Debug|x64.ActiveCfg = Debug|Any CPU 89 | {501C6034-9D52-4249-8CA2-572796932003}.Debug|x64.Build.0 = Debug|Any CPU 90 | {501C6034-9D52-4249-8CA2-572796932003}.Release|Any CPU.ActiveCfg = Release|Any CPU 91 | {501C6034-9D52-4249-8CA2-572796932003}.Release|Any CPU.Build.0 = Release|Any CPU 92 | {501C6034-9D52-4249-8CA2-572796932003}.Release|x64.ActiveCfg = Release|Any CPU 93 | {501C6034-9D52-4249-8CA2-572796932003}.Release|x64.Build.0 = Release|Any CPU 94 | EndGlobalSection 95 | GlobalSection(SolutionProperties) = preSolution 96 | HideSolutionNode = FALSE 97 | EndGlobalSection 98 | GlobalSection(ExtensibilityGlobals) = postSolution 99 | SolutionGuid = {4360FC72-2EB2-414C-8FC6-2C24428BF6AF} 100 | EndGlobalSection 101 | EndGlobal 102 | -------------------------------------------------------------------------------- /RevitAPIToolbox/RevitAPIToolbox.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {4A64D10E-577C-456A-990D-E5AE631359D1} 8 | Library 9 | Properties 10 | Techyard.Revit 11 | RevitAPIExtensions 12 | v4.0 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | true 34 | bin\x64\Debug\ 35 | TRACE;DEBUG;REVIT2014 36 | full 37 | x64 38 | prompt 39 | MinimumRecommendedRules.ruleset 40 | 41 | 42 | bin\x64\Release\ 43 | TRACE 44 | true 45 | pdbonly 46 | x64 47 | prompt 48 | MinimumRecommendedRules.ruleset 49 | 50 | 51 | 52 | ..\packages\Revit2014x64-SDK.1.0.0\lib\net40\AdWindows.dll 53 | False 54 | 55 | 56 | 57 | 58 | ..\packages\Revit2014x64-SDK.1.0.0\lib\net40\RevitAPI.dll 59 | False 60 | 61 | 62 | ..\packages\Revit2014x64-SDK.1.0.0\lib\net40\RevitAPIIFC.dll 63 | False 64 | 65 | 66 | ..\packages\Revit2014x64-SDK.1.0.0\lib\net40\RevitAPIMacros.dll 67 | False 68 | 69 | 70 | ..\packages\Revit2014x64-SDK.1.0.0\lib\net40\RevitAPIUI.dll 71 | False 72 | 73 | 74 | ..\packages\Revit2014x64-SDK.1.0.0\lib\net40\RevitNET.dll 75 | False 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | ..\packages\Revit2014x64-SDK.1.0.0\lib\net40\UIFramework.dll 87 | False 88 | 89 | 90 | ..\packages\Revit2014x64-SDK.1.0.0\lib\net40\UIFrameworkServices.dll 91 | False 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | -------------------------------------------------------------------------------- /RevitAPIToolbox/Misc/SchemaDesigner/SchemaBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using Autodesk.Revit.DB.ExtensibleStorage; 6 | using Techyard.Revit.Attributes; 7 | using Techyard.Revit.Exceptions; 8 | 9 | namespace Techyard.Revit.Misc.SchemaDesigner 10 | { 11 | public abstract class SchemaBase 12 | { 13 | private List> _properties; 14 | private List> _fields; 15 | private SchemaAttribute _schema; 16 | private MethodInfo _entityGet; 17 | private MethodInfo _entitySet; 18 | 19 | private SchemaAttribute SchemaDefinition 20 | { 21 | get 22 | { 23 | if (null == _schema) 24 | { 25 | var schemaDefinition = 26 | GetType() 27 | .GetCustomAttributes(typeof(SchemaAttribute), false) 28 | .Cast() 29 | .FirstOrDefault(); 30 | _schema = schemaDefinition; 31 | if (null == _schema) 32 | throw new SchemaNotDefinedWithAttributeException(); 33 | } 34 | return _schema; 35 | } 36 | } 37 | 38 | /// 39 | /// Get metadata of Autodesk.DB.ExtensibleStorage.Get(string name) method 40 | /// 41 | private MethodInfo EntityGet 42 | { 43 | get 44 | { 45 | if (null == _entityGet) 46 | { 47 | var type = typeof(Entity); 48 | _entityGet = type.GetMethods(BindingFlags.Public | BindingFlags.Instance) 49 | .FirstOrDefault(method => 50 | { 51 | if (method.Name != "Get") return false; 52 | if (!method.IsGenericMethod) return false; 53 | var parameters = method.GetParameters(); 54 | if (parameters.Length != 1) 55 | return false; 56 | return typeof(string) == parameters[0].ParameterType; 57 | }); 58 | } 59 | return _entityGet; 60 | } 61 | } 62 | 63 | /// 64 | /// Get metadata of Autodesk.DB.ExtensibleStorage.Set(string name,T value) method 65 | /// 66 | private MethodInfo EntitySet 67 | { 68 | get 69 | { 70 | if (null == _entitySet) 71 | { 72 | var type = typeof(Entity); 73 | _entitySet = type.GetMethods(BindingFlags.Public | BindingFlags.Instance) 74 | .FirstOrDefault(method => 75 | { 76 | if (method.Name != "Set") return false; 77 | if (!method.IsGenericMethod) return false; 78 | var parameters = method.GetParameters(); 79 | if (parameters.Length != 2) 80 | return false; 81 | return typeof(string) == parameters[0].ParameterType; 82 | }); 83 | } 84 | return _entitySet; 85 | } 86 | } 87 | 88 | private Guid SchemaId => new Guid(SchemaDefinition.Guid); 89 | 90 | private string SchemaName => SchemaDefinition.Name; 91 | 92 | /// 93 | /// Cache property metadata of user-difined schema 94 | /// 95 | private List> Properties => 96 | _properties ?? 97 | (_properties = GetType() 98 | .GetProperties() 99 | .Select( 100 | p => new Tuple(p.GetCustomAttributes(typeof(SchemaFieldAttribute), false) 101 | .Cast() 102 | .FirstOrDefault()?.Name, p)) 103 | .Where(pp => pp.Item1 != null) 104 | .ToList()); 105 | 106 | private List> Fields => 107 | _fields ?? 108 | (_fields = GetType() 109 | .GetFields() 110 | .Select( 111 | f => new Tuple(f.GetCustomAttributes(typeof(SchemaFieldAttribute), false) 112 | .Cast() 113 | .FirstOrDefault()?.Name, f)) 114 | .Where(fp => fp.Item1 != null) 115 | .ToList()); 116 | 117 | /// 118 | /// Get or create the schema from class definition 119 | /// 120 | /// 121 | public Schema GetOrCreateSchema() 122 | { 123 | var schema = Schema.Lookup(SchemaId); 124 | if (null != schema) 125 | return schema; 126 | var builder = new SchemaBuilder(SchemaId); 127 | builder.SetSchemaName(SchemaName); 128 | 129 | //Get all attributed properties to build the schema 130 | Properties.ToList() 131 | .ForEach(pp => 132 | { 133 | builder.AddSimpleField(pp.Item1, pp.Item2.PropertyType); 134 | }); 135 | 136 | //Get all attributed fields to build the schema 137 | Fields.ToList() 138 | .ForEach(fp => 139 | { 140 | builder.AddSimpleField(fp.Item1, fp.Item2.FieldType); 141 | }); 142 | return builder.Finish(); 143 | } 144 | 145 | /// 146 | /// Extract data from the Entity object to current object 147 | /// 148 | /// 149 | internal void ExtractData(Entity entity) 150 | { 151 | Properties.ForEach(tuple => 152 | { 153 | var name = tuple.Item1; 154 | var property = tuple.Item2; 155 | var genericMethod = EntityGet?.MakeGenericMethod(property.PropertyType); 156 | var value = genericMethod?.Invoke(entity, new object[] { name }); 157 | property.SetValue(this, value, null); 158 | }); 159 | 160 | Fields.ForEach(tuple => 161 | { 162 | var name = tuple.Item1; 163 | var field = tuple.Item2; 164 | var genericMethod = EntityGet?.MakeGenericMethod(field.FieldType); 165 | var value = genericMethod?.Invoke(entity, new object[] { name }); 166 | field.SetValue(this, value); 167 | }); 168 | } 169 | 170 | /// 171 | /// Fill data of current object to the Entity object 172 | /// 173 | /// 174 | internal void FillData(Entity entity) 175 | { 176 | Properties.ForEach(tuple => 177 | { 178 | var name = tuple.Item1; 179 | var property = tuple.Item2; 180 | var value = property.GetValue(this, null); 181 | var genericMethod = EntitySet?.MakeGenericMethod(property.PropertyType); 182 | genericMethod?.Invoke(entity, new[] { name, value }); 183 | }); 184 | 185 | Fields.ForEach(tuple => 186 | { 187 | var name = tuple.Item1; 188 | var field = tuple.Item2; 189 | var value = field.GetValue(this); 190 | var genericMethod = EntitySet?.MakeGenericMethod(field.FieldType); 191 | genericMethod?.Invoke(entity, new[] { name, value }); 192 | }); 193 | } 194 | } 195 | } -------------------------------------------------------------------------------- /RevitAPIToolbox2014/RevitAPIToolbox2014.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {25973226-7287-47EE-A456-AAD545F226E3} 8 | Library 9 | Properties 10 | Techyard.Revit 11 | RevitAPIToolbox 12 | v4.0 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | true 34 | bin\x64\Debug\ 35 | TRACE;DEBUG;REVIT2014 36 | full 37 | x64 38 | prompt 39 | MinimumRecommendedRules.ruleset 40 | 41 | 42 | bin\x64\Release\ 43 | TRACE 44 | true 45 | pdbonly 46 | x64 47 | prompt 48 | MinimumRecommendedRules.ruleset 49 | 50 | 51 | 52 | ..\packages\Revit2014x64-SDK.1.0.0\lib\net40\AdWindows.dll 53 | False 54 | 55 | 56 | 57 | 58 | ..\packages\Revit2014x64-SDK.1.0.0\lib\net40\RevitAPI.dll 59 | False 60 | 61 | 62 | ..\packages\Revit2014x64-SDK.1.0.0\lib\net40\RevitAPIIFC.dll 63 | False 64 | 65 | 66 | ..\packages\Revit2014x64-SDK.1.0.0\lib\net40\RevitAPIMacros.dll 67 | False 68 | 69 | 70 | ..\packages\Revit2014x64-SDK.1.0.0\lib\net40\RevitAPIUI.dll 71 | False 72 | 73 | 74 | ..\packages\Revit2014x64-SDK.1.0.0\lib\net40\RevitNET.dll 75 | False 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | ..\packages\Revit2014x64-SDK.1.0.0\lib\net40\UIFramework.dll 87 | False 88 | 89 | 90 | ..\packages\Revit2014x64-SDK.1.0.0\lib\net40\UIFrameworkServices.dll 91 | False 92 | 93 | 94 | 95 | 96 | 97 | Attributes\SchemaAttribute.cs 98 | 99 | 100 | Attributes\SchemaFieldAttribute.cs 101 | 102 | 103 | Attributes\TargetTypeAttribute.cs 104 | 105 | 106 | Common\DelegateExternalEventHandler.cs 107 | 108 | 109 | Common\DoubleExtension.cs 110 | 111 | 112 | Common\EnumerableExtension.cs 113 | 114 | 115 | Common\ExternalEventManager.cs 116 | 117 | 118 | Common\Int32Extension.cs 119 | 120 | 121 | Common\ParameterizedExternalEventHandler.cs 122 | 123 | 124 | Common\TypeExtension.cs 125 | 126 | 127 | Database\CurveExtension.cs 128 | 129 | 130 | Database\DocumentExtension.cs 131 | 132 | 133 | Database\ElementExtension.cs 134 | 135 | 136 | Database\FamilyExtension.cs 137 | 138 | 139 | Database\PlaneExtension.cs 140 | 141 | 142 | Database\ViewExtension.cs 143 | 144 | 145 | Database\XYZExtension.cs 146 | 147 | 148 | Exceptions\SchemaNotDefinedWithAttributeException.cs 149 | 150 | 151 | Geometry\FilteredGeometryCollector.cs 152 | 153 | 154 | Geometry\GeometryClassFilter.cs 155 | 156 | 157 | Geometry\GeometryElementExtension.cs 158 | 159 | 160 | Geometry\GeometryInstanceExtension.cs 161 | 162 | 163 | Geometry\IGeometryFilter.cs 164 | 165 | 166 | Misc\CurveDivide\ControlledCurveDivider.cs 167 | 168 | 169 | Misc\CurveDivide\CurveDivider.cs 170 | 171 | 172 | Misc\CurveDivide\ICurveDivider.cs 173 | 174 | 175 | Misc\SchemaDesigner\SchemaBase.cs 176 | 177 | 178 | UI\ControlUtility.cs 179 | 180 | 181 | UI\RibbonCommandItemMixin.cs 182 | 183 | 184 | UI\RibbonItemMixin.cs 185 | 186 | 187 | UI\SelectionExtension.cs 188 | 189 | 190 | UI\UIFactory.cs 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | -------------------------------------------------------------------------------- /RevitAPIToolbox2016/RevitAPIToolbox2016.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {2E4F1590-B9B8-438A-8EC4-A4F6751C3B25} 8 | Library 9 | Properties 10 | Techyard.Revit 11 | RevitAPIToolbox 12 | v4.5.1 13 | 512 14 | 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | false 25 | 26 | 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | false 34 | 35 | 36 | true 37 | bin\x64\Debug\ 38 | TRACE;DEBUG;REVIT2016 39 | full 40 | x64 41 | prompt 42 | MinimumRecommendedRules.ruleset 43 | 44 | 45 | bin\x64\Release\ 46 | TRACE 47 | true 48 | pdbonly 49 | x64 50 | prompt 51 | MinimumRecommendedRules.ruleset 52 | 53 | 54 | 55 | ..\packages\Revit-2016x64.Base.1.0.0\lib\net45\AdWindows.dll 56 | False 57 | 58 | 59 | 60 | 61 | ..\packages\Revit-2016x64.Base.1.0.0\lib\net45\RevitAPI.dll 62 | False 63 | 64 | 65 | ..\packages\Revit-2016x64.Base.1.0.0\lib\net45\RevitAPIIFC.dll 66 | False 67 | 68 | 69 | ..\packages\Revit-2016x64.Base.1.0.0\lib\net45\RevitAPIMacros.dll 70 | False 71 | 72 | 73 | ..\packages\Revit-2016x64.Base.1.0.0\lib\net45\RevitAPIUI.dll 74 | False 75 | 76 | 77 | ..\packages\Revit-2016x64.Base.1.0.0\lib\net45\RevitAPIUIMacros.dll 78 | False 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | C:\Program Files\Autodesk\Revit 2016\UIFramework.dll 90 | False 91 | 92 | 93 | C:\Program Files\Autodesk\Revit 2016\UIFrameworkServices.dll 94 | False 95 | 96 | 97 | 98 | 99 | 100 | Attributes\SchemaAttribute.cs 101 | 102 | 103 | Attributes\SchemaFieldAttribute.cs 104 | 105 | 106 | Attributes\TargetTypeAttribute.cs 107 | 108 | 109 | Common\DelegateExternalEventHandler.cs 110 | 111 | 112 | Common\DoubleExtension.cs 113 | 114 | 115 | Common\EnumerableExtension.cs 116 | 117 | 118 | Common\ExternalEventManager.cs 119 | 120 | 121 | Common\Int32Extension.cs 122 | 123 | 124 | Common\ParameterizedExternalEventHandler.cs 125 | 126 | 127 | Common\TypeExtension.cs 128 | 129 | 130 | Database\CurveExtension.cs 131 | 132 | 133 | Database\DocumentExtension.cs 134 | 135 | 136 | Database\ElementExtension.cs 137 | 138 | 139 | Database\FamilyExtension.cs 140 | 141 | 142 | Database\PlaneExtension.cs 143 | 144 | 145 | Database\ViewExtension.cs 146 | 147 | 148 | Database\XYZExtension.cs 149 | 150 | 151 | Exceptions\SchemaNotDefinedWithAttributeException.cs 152 | 153 | 154 | Geometry\FilteredGeometryCollector.cs 155 | 156 | 157 | Geometry\GeometryClassFilter.cs 158 | 159 | 160 | Geometry\GeometryElementExtension.cs 161 | 162 | 163 | Geometry\GeometryInstanceExtension.cs 164 | 165 | 166 | Geometry\IGeometryFilter.cs 167 | 168 | 169 | Misc\CurveDivide\ControlledCurveDivider.cs 170 | 171 | 172 | Misc\CurveDivide\CurveDivider.cs 173 | 174 | 175 | Misc\CurveDivide\ICurveDivider.cs 176 | 177 | 178 | Misc\SchemaDesigner\SchemaBase.cs 179 | 180 | 181 | UI\ControlUtility.cs 182 | 183 | 184 | UI\RibbonCommandItemMixin.cs 185 | 186 | 187 | UI\RibbonItemMixin.cs 188 | 189 | 190 | UI\SelectionExtension.cs 191 | 192 | 193 | UI\UIFactory.cs 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | -------------------------------------------------------------------------------- /RevitAPIToolbox2015/RevitAPIToolbox2015.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {4D4C1D78-D2A7-40E7-8A85-4D6C876E0C0C} 8 | Library 9 | Properties 10 | Techyard.Revit 11 | RevitAPIToolbox 12 | v4.5 13 | 512 14 | 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | false 25 | 26 | 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | false 34 | 35 | 36 | true 37 | bin\x64\Debug\ 38 | TRACE;DEBUG;REVIT2015 39 | full 40 | x64 41 | prompt 42 | MinimumRecommendedRules.ruleset 43 | 44 | 45 | bin\x64\Release\ 46 | TRACE 47 | true 48 | pdbonly 49 | x64 50 | prompt 51 | MinimumRecommendedRules.ruleset 52 | 53 | 54 | 55 | ..\packages\Revit-2015x64.Base.1.0.0\lib\net45\AdWindows.dll 56 | False 57 | 58 | 59 | 60 | 61 | ..\packages\Revit-2015x64.Base.1.0.0\lib\net45\RevitAPI.dll 62 | False 63 | 64 | 65 | ..\packages\Revit-2015x64.Base.1.0.0\lib\net45\RevitAPIIFC.dll 66 | False 67 | 68 | 69 | ..\packages\Revit-2015x64.Base.1.0.0\lib\net45\RevitAPIMacros.dll 70 | False 71 | 72 | 73 | ..\packages\Revit-2015x64.Base.1.0.0\lib\net45\RevitAPIUI.dll 74 | False 75 | 76 | 77 | ..\packages\Revit-2015x64.Base.1.0.0\lib\net45\RevitAPIUIMacros.dll 78 | False 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | C:\Program Files\Autodesk\Revit 2015\UIFramework.dll 90 | False 91 | 92 | 93 | C:\Program Files\Autodesk\Revit 2015\UIFrameworkServices.dll 94 | False 95 | 96 | 97 | 98 | 99 | 100 | Attributes\SchemaAttribute.cs 101 | 102 | 103 | Attributes\SchemaFieldAttribute.cs 104 | 105 | 106 | Attributes\TargetTypeAttribute.cs 107 | 108 | 109 | Common\DelegateExternalEventHandler.cs 110 | 111 | 112 | Common\DoubleExtension.cs 113 | 114 | 115 | Common\EnumerableExtension.cs 116 | 117 | 118 | Common\ExternalEventManager.cs 119 | 120 | 121 | Common\Int32Extension.cs 122 | 123 | 124 | Common\ParameterizedExternalEventHandler.cs 125 | 126 | 127 | Common\TypeExtension.cs 128 | 129 | 130 | Database\CurveExtension.cs 131 | 132 | 133 | Database\DocumentExtension.cs 134 | 135 | 136 | Database\ElementExtension.cs 137 | 138 | 139 | Database\FamilyExtension.cs 140 | 141 | 142 | Database\PlaneExtension.cs 143 | 144 | 145 | Database\ViewExtension.cs 146 | 147 | 148 | Database\XYZExtension.cs 149 | 150 | 151 | Exceptions\SchemaNotDefinedWithAttributeException.cs 152 | 153 | 154 | Geometry\FilteredGeometryCollector.cs 155 | 156 | 157 | Geometry\GeometryClassFilter.cs 158 | 159 | 160 | Geometry\GeometryElementExtension.cs 161 | 162 | 163 | Geometry\GeometryInstanceExtension.cs 164 | 165 | 166 | Geometry\IGeometryFilter.cs 167 | 168 | 169 | Misc\CurveDivide\ControlledCurveDivider.cs 170 | 171 | 172 | Misc\CurveDivide\CurveDivider.cs 173 | 174 | 175 | Misc\CurveDivide\ICurveDivider.cs 176 | 177 | 178 | Misc\SchemaDesigner\SchemaBase.cs 179 | 180 | 181 | UI\ControlUtility.cs 182 | 183 | 184 | UI\RibbonCommandItemMixin.cs 185 | 186 | 187 | UI\RibbonItemMixin.cs 188 | 189 | 190 | UI\SelectionExtension.cs 191 | 192 | 193 | UI\UIFactory.cs 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | -------------------------------------------------------------------------------- /RevitAPIToolbox2017/RevitAPIToolbox2017.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {857AED45-CA4D-4BCC-B027-7B5A2AF06933} 8 | Library 9 | Properties 10 | Techyard.Revit 11 | RevitAPIToolbox 12 | v4.5.2 13 | 512 14 | 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | false 25 | 26 | 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | false 34 | 35 | 36 | true 37 | bin\x64\Debug\ 38 | TRACE;DEBUG;REVIT2017 39 | full 40 | x64 41 | prompt 42 | MinimumRecommendedRules.ruleset 43 | 44 | 45 | bin\x64\Release\ 46 | TRACE 47 | true 48 | pdbonly 49 | x64 50 | prompt 51 | MinimumRecommendedRules.ruleset 52 | 53 | 54 | 55 | ..\packages\Revit-2017.1.1-x64.Base.2.0.0\lib\net452\AdWindows.dll 56 | False 57 | 58 | 59 | 60 | 61 | ..\packages\Revit-2017.1.1-x64.Base.2.0.0\lib\net452\RevitAPI.dll 62 | False 63 | 64 | 65 | ..\packages\Revit-2017.1.1-x64.Base.2.0.0\lib\net452\RevitAPIIFC.dll 66 | False 67 | 68 | 69 | ..\packages\Revit-2017.1.1-x64.Base.2.0.0\lib\net452\RevitAPIMacros.dll 70 | False 71 | 72 | 73 | ..\packages\Revit-2017.1.1-x64.Base.2.0.0\lib\net452\RevitAPIUI.dll 74 | False 75 | 76 | 77 | ..\packages\Revit-2017.1.1-x64.Base.2.0.0\lib\net452\RevitAPIUIMacros.dll 78 | False 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | C:\Program Files\Autodesk\Revit 2017\UIFramework.dll 90 | False 91 | 92 | 93 | C:\Program Files\Autodesk\Revit 2017\UIFrameworkServices.dll 94 | False 95 | 96 | 97 | 98 | 99 | 100 | Attributes\SchemaAttribute.cs 101 | 102 | 103 | Attributes\SchemaFieldAttribute.cs 104 | 105 | 106 | Attributes\TargetTypeAttribute.cs 107 | 108 | 109 | Common\DelegateExternalEventHandler.cs 110 | 111 | 112 | Common\DoubleExtension.cs 113 | 114 | 115 | Common\EnumerableExtension.cs 116 | 117 | 118 | Common\ExternalEventManager.cs 119 | 120 | 121 | Common\Int32Extension.cs 122 | 123 | 124 | Common\ParameterizedExternalEventHandler.cs 125 | 126 | 127 | Common\TypeExtension.cs 128 | 129 | 130 | Database\CurveExtension.cs 131 | 132 | 133 | Database\DocumentExtension.cs 134 | 135 | 136 | Database\ElementExtension.cs 137 | 138 | 139 | Database\FamilyExtension.cs 140 | 141 | 142 | Database\PlaneExtension.cs 143 | 144 | 145 | Database\ViewExtension.cs 146 | 147 | 148 | Database\XYZExtension.cs 149 | 150 | 151 | Exceptions\SchemaNotDefinedWithAttributeException.cs 152 | 153 | 154 | Geometry\FilteredGeometryCollector.cs 155 | 156 | 157 | Geometry\GeometryClassFilter.cs 158 | 159 | 160 | Geometry\GeometryElementExtension.cs 161 | 162 | 163 | Geometry\GeometryInstanceExtension.cs 164 | 165 | 166 | Geometry\IGeometryFilter.cs 167 | 168 | 169 | Misc\CurveDivide\ControlledCurveDivider.cs 170 | 171 | 172 | Misc\CurveDivide\CurveDivider.cs 173 | 174 | 175 | Misc\CurveDivide\ICurveDivider.cs 176 | 177 | 178 | Misc\SchemaDesigner\SchemaBase.cs 179 | 180 | 181 | UI\ControlUtility.cs 182 | 183 | 184 | UI\RibbonCommandItemMixin.cs 185 | 186 | 187 | UI\RibbonItemMixin.cs 188 | 189 | 190 | UI\SelectionExtension.cs 191 | 192 | 193 | UI\UIFactory.cs 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | -------------------------------------------------------------------------------- /RevitAPIToolbox2018/RevitAPIToolbox2018.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {C8AD8C48-F4AE-4C84-87BB-88E838099F05} 8 | Library 9 | Properties 10 | Techyard.Revit 11 | RevitAPIToolbox 12 | v4.6 13 | 512 14 | 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | false 25 | 26 | 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | false 34 | 35 | 36 | true 37 | bin\x64\Debug\ 38 | TRACE;DEBUG;REVIT2018 39 | full 40 | x64 41 | prompt 42 | MinimumRecommendedRules.ruleset 43 | 44 | 45 | bin\x64\Release\ 46 | TRACE 47 | true 48 | pdbonly 49 | x64 50 | prompt 51 | MinimumRecommendedRules.ruleset 52 | 53 | 54 | 55 | ..\packages\Revit-2018.1-x64.Base.1.0.0\lib\net46\AdWindows.dll 56 | False 57 | 58 | 59 | 60 | 61 | ..\packages\Revit-2018.1-x64.Base.1.0.0\lib\net46\RevitAPI.dll 62 | False 63 | 64 | 65 | ..\packages\Revit-2018.1-x64.Base.1.0.0\lib\net46\RevitAPIIFC.dll 66 | False 67 | 68 | 69 | ..\packages\Revit-2018.1-x64.Base.1.0.0\lib\net46\RevitAPIMacros.dll 70 | False 71 | 72 | 73 | ..\packages\Revit-2018.1-x64.Base.1.0.0\lib\net46\RevitAPIUI.dll 74 | False 75 | 76 | 77 | ..\packages\Revit-2018.1-x64.Base.1.0.0\lib\net46\RevitAPIUIMacros.dll 78 | False 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | C:\Program Files\Autodesk\Revit 2018\UIFramework.dll 90 | False 91 | False 92 | 93 | 94 | C:\Program Files\Autodesk\Revit 2018\UIFrameworkServices.dll 95 | False 96 | False 97 | 98 | 99 | 100 | 101 | 102 | Attributes\SchemaAttribute.cs 103 | 104 | 105 | Attributes\SchemaFieldAttribute.cs 106 | 107 | 108 | Attributes\TargetTypeAttribute.cs 109 | 110 | 111 | Common\DelegateExternalEventHandler.cs 112 | 113 | 114 | Common\DoubleExtension.cs 115 | 116 | 117 | Common\EnumerableExtension.cs 118 | 119 | 120 | Common\ExternalEventManager.cs 121 | 122 | 123 | Common\Int32Extension.cs 124 | 125 | 126 | Common\ParameterizedExternalEventHandler.cs 127 | 128 | 129 | Common\TypeExtension.cs 130 | 131 | 132 | Database\CurveExtension.cs 133 | 134 | 135 | Database\DocumentExtension.cs 136 | 137 | 138 | Database\ElementExtension.cs 139 | 140 | 141 | Database\FamilyExtension.cs 142 | 143 | 144 | Database\PlaneExtension.cs 145 | 146 | 147 | Database\ViewExtension.cs 148 | 149 | 150 | Database\XYZExtension.cs 151 | 152 | 153 | Exceptions\SchemaNotDefinedWithAttributeException.cs 154 | 155 | 156 | Geometry\FilteredGeometryCollector.cs 157 | 158 | 159 | Geometry\GeometryClassFilter.cs 160 | 161 | 162 | Geometry\GeometryElementExtension.cs 163 | 164 | 165 | Geometry\GeometryInstanceExtension.cs 166 | 167 | 168 | Geometry\IGeometryFilter.cs 169 | 170 | 171 | Misc\CurveDivide\ControlledCurveDivider.cs 172 | 173 | 174 | Misc\CurveDivide\CurveDivider.cs 175 | 176 | 177 | Misc\CurveDivide\ICurveDivider.cs 178 | 179 | 180 | Misc\SchemaDesigner\SchemaBase.cs 181 | 182 | 183 | UI\ControlUtility.cs 184 | 185 | 186 | UI\RibbonCommandItemMixin.cs 187 | 188 | 189 | UI\RibbonItemMixin.cs 190 | 191 | 192 | UI\SelectionExtension.cs 193 | 194 | 195 | UI\UIFactory.cs 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | --------------------------------------------------------------------------------