integrate Revit 2025 SDK

This commit is contained in:
Jeremy Tammik
2024-04-11 13:47:20 +02:00
parent e786953544
commit f414362f2b
889 changed files with 26676 additions and 26865 deletions
@@ -0,0 +1,5 @@
{
"recommendations": [
"ms-dotnettools.csharp",
]
}
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Attach to Revit",
"type": "coreclr",
"request": "attach",
"processName": "revit.exe",
"justMyCode": true
}
]
}
@@ -0,0 +1,14 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build"
],
"problemMatcher": "$msCompile"
},
]
}
@@ -0,0 +1,38 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<PlatformTarget>x64</PlatformTarget>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<Optimize>False</Optimize>
<DebugSymbols>True</DebugSymbols>
<DebugType>Portable</DebugType>
<OutputPath>..\..\Addin\</OutputPath>
<AssemblyName>GetTimeElapsed</AssemblyName>
<BaseInterMediateOutputPath>obj\</BaseInterMediateOutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<InterMediateOutputPath>obj\Debug</InterMediateOutputPath>
<Deterministic>false</Deterministic>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
</PropertyGroup>
<ItemGroup>
<Reference Include="..\..\..\..\..\RevitAPI.dll">
<Private>False</Private>
</Reference>
<Reference Include="..\..\..\..\..\RevitAPIUI.dll">
<Private>False</Private>
</Reference>
</ItemGroup>
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="del $(OutputPath)\*.dll" />
</Target>
</Project>
@@ -0,0 +1,31 @@
#region Using directives
using System;
using System.Reflection;
using System.Runtime.InteropServices;
#endregion
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("NewModule")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NewModule")]
[assembly: AssemblyCopyright("Copyright 2023")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// This sets the default COM visibility of types in the assembly to invisible.
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
[assembly: ComVisible(false)]
// The assembly version has following format :
//
// Major.Minor.Build.Revision
//
// You can specify all the values or you can use the default the Revision and
// Build Numbers by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.*")]
@@ -0,0 +1,54 @@
namespace GetTimeElapsed
{
public sealed partial class ThisApplication : Autodesk.Revit.UI.Macros.ApplicationEntryPoint
{
public event System.EventHandler Startup;
public event System.EventHandler Shutdown;
///
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
private void OnStartup()
{
}
///
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
protected override void FinishInitialization()
{
base.FinishInitialization();
this.OnStartup();
this.InternalStartup();
if ((this.Startup != null))
{
this.Startup(this, System.EventArgs.Empty);
}
}
///
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
protected override void OnShutdown()
{
if ((this.Shutdown != null))
{
this.Shutdown(this, System.EventArgs.Empty);
}
base.OnShutdown();
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
protected override string PrimaryCookie
{
get
{
return "ThisApplication";
}
}
}
}
@@ -0,0 +1,139 @@
using System;
using Autodesk.Revit.UI;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Events;
using Autodesk.Revit.UI.Selection;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using Autodesk.Revit.DB.ExtensibleStorage;
namespace GetTimeElapsed
{
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
[Autodesk.Revit.DB.Macros.AddInId("4FD02D8C-2CDD-4FA8-89E0-0D03B812A398")]
public partial class ThisApplication
{
Dictionary<Document, DateTime> m_dicLastSaved = new Dictionary<Document, DateTime>();
private void Module_Startup(object? sender, EventArgs e)
{
InitializeDicLastSaved();
this.Application.DocumentSaved += new EventHandler<DocumentSavedEventArgs>(ThisApplication_DocumentSaved);
this.Application.DocumentOpened += new EventHandler<DocumentOpenedEventArgs>(ThisApplication_DocumentOpened);
this.Application.DocumentCreated += new EventHandler<DocumentCreatedEventArgs>(ThisApplication_DocumentCreated);
this.Application.DocumentClosing += new EventHandler<DocumentClosingEventArgs>(ThisApplication_DocumentClosing);
}
private void Module_Shutdown(object? sender, EventArgs e)
{
this.Application.DocumentSaved -= new EventHandler<DocumentSavedEventArgs>(ThisApplication_DocumentSaved);
this.Application.DocumentOpened -= new EventHandler<DocumentOpenedEventArgs>(ThisApplication_DocumentOpened);
this.Application.DocumentCreated -= new EventHandler<DocumentCreatedEventArgs>(ThisApplication_DocumentCreated);
this.Application.DocumentClosing -= new EventHandler<DocumentClosingEventArgs>(ThisApplication_DocumentClosing);
}
#region Revit Macros generated code
private void InternalStartup()
{
this.Startup += new System.EventHandler(Module_Startup);
this.Shutdown += new System.EventHandler(Module_Shutdown);
}
#endregion
/// <summary>
/// Initialize
/// </summary>
private void InitializeDicLastSaved()
{
foreach (Document document in this.Application.Documents)
{
m_dicLastSaved.Add(document, DateTime.MaxValue);
}
}
/// <summary>
/// DocumentCreated event, add the created document into m_dicLastSaved
/// </summary>
/// <param name="sender">sender</param>
/// <param name="args">DocumentCreatedEventArgs</param>
public void ThisApplication_DocumentCreated(object? sender, DocumentCreatedEventArgs args)
{
m_dicLastSaved.Add(args.Document, DateTime.MaxValue);
}
/// <summary>
/// DocumentClosing event, remove the closing document from m_dicLastSaved
/// </summary>
/// <param name="sender">sender</param>
/// <param name="args">DocumentClosingEventArgs</param>
public void ThisApplication_DocumentClosing(object? sender, DocumentClosingEventArgs args)
{
m_dicLastSaved.Remove(args.Document);
}
/// <summary>
/// DocumentOpened event, add the opened document into m_dicLastSaved
/// </summary>
/// <param name="sender">sender</param>
/// <param name="args">DocumentOpenedEventArgs</param>
public void ThisApplication_DocumentOpened(object? sender, DocumentOpenedEventArgs args)
{
m_dicLastSaved.Add(args.Document, DateTime.MaxValue);
}
/// <summary>
/// DocumentSaved event, record the current DataTime for the saved document
/// </summary>
/// <param name="sender">sender</param>
/// <param name="args">DocumentSavedEventArgs</param>
public void ThisApplication_DocumentSaved(object? sender, DocumentSavedEventArgs args)
{
this.m_dicLastSaved[args.Document] = DateTime.Now;
}
/// <summary>
/// FormatTimeSpan
/// </summary>
/// <param name="elapse">TimeSpan</param>
/// <returns>the string of TimeSpan</returns>
public String FormatTimeSpan(TimeSpan elapse)
{
String elapseStr = elapse.ToString();
int lastIndexOfDot = elapseStr.LastIndexOf('.');
return elapseStr.Substring(0, lastIndexOfDot);
}
/// <summary>
/// GetTimeElapsedSinceLastSave
/// </summary>
public void GetTimeElapsedSinceLastSave()
{
String text = String.Format("{0,-30}{1,-30}",
"Document Full Name",
"Elapse Time Since Last Save(day.hh:mm:ss)")
+ "\n";
foreach (KeyValuePair<Document, DateTime> pair in m_dicLastSaved)
{
String strElapsed = String.Empty;
if (pair.Value == DateTime.MaxValue)
{
strElapsed = "Never";
}
else
{
strElapsed = FormatTimeSpan(DateTime.Now - pair.Value);
}
String fileName = System.IO.Path.GetFileName(pair.Key.PathName);
if (String.IsNullOrEmpty(fileName))
{
fileName = "*New*";
}
text += String.Format("{0,-30}{1,-30}", fileName, strElapsed) + "\n";
}
TaskDialog.Show("Macro GetTimeElapsedSinceLastSave", text);
}
}
}