added Revit 2022 SDK minus except *rvt and *rfa

This commit is contained in:
Jeremy Tammik
2021-04-20 11:36:21 +02:00
parent 1133a82dc5
commit 7e327986e8
3034 changed files with 1245318 additions and 0 deletions
@@ -0,0 +1,85 @@
//
// (C) Copyright 2003-2019 by Autodesk, Inc. All rights reserved.
//
// Permission to use, copy, modify, and distribute this software in
// object code form for any purpose and without fee is hereby granted
// provided that the above copyright notice appears in all copies and
// that both that copyright notice and the limited warranty and
// restricted rights notice below appear in all supporting
// documentation.
//
// AUTODESK PROVIDES THIS PROGRAM 'AS IS' AND WITH ALL ITS FAULTS.
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
// UNINTERRUPTED OR ERROR FREE.
//
// Use, duplication, or disclosure by the U.S. Government is subject to
// restrictions set forth in FAR 52.227-19 (Commercial Computer
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
// (Rights in Technical Data and Computer Software), as applicable.
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.IO;
using Autodesk;
using Autodesk.Revit;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.ExternalService;
using Autodesk.Revit.UI;
using Autodesk.Revit.ApplicationServices;
namespace Revit.SDK.Samples.ExternalResourceUIServer.CS
{
/// <summary>
/// <para>Implements the Revit add-in interface IExternalApplication.</para>
/// <para>An IExternalResourceUIServer can be registered at any time during a Revit session.
/// However, the most straightforward approach is to register during start-up, in the
/// OnStartUp method of a Revit external application. This should be a (UI-level)
/// IExternalApplication, and NOT an IExternalDBApplication.</para>
/// </summary>
class UIServerApplication : IExternalApplication
{
#region IExternalApplication Members
/// <summary>
/// Registers an instance of a SampleExternalResourceUIServer with the ExternalService
/// of type ExternalResourceUIService.
/// </summary>
/// <param name="application">An object that is passed to the external application
/// which contains the controlled application.</param>
/// <returns>Return the status of the external application. A result of Succeeded
/// means that the external application was able to register the IExternalResourceUIServer.
/// </returns>
public Result OnStartup(UIControlledApplication application)
{
ExternalService externalResourceUIService = ExternalServiceRegistry.GetService(ExternalServices.BuiltInExternalServices.ExternalResourceUIService);
if (externalResourceUIService == null)
return Result.Failed;
// Create an instance of your IExternalResourceUIServer and register it with the ExternalResourceUIService.
IExternalResourceUIServer sampleUIServer = new SampleExternalResourceUIServer();
externalResourceUIService.AddServer(sampleUIServer);
return Result.Succeeded;
}
/// <summary>
/// Implements the OnShutdown event.
/// <para>The server implementer may wish to perform clean-up tasks here. However, in the
/// simplest case, no server-related code is required, and the server will be
/// destroyed as Revit shuts down.</para>
/// </summary>
/// <param name="application">An object that is passed to the external application
/// which contains the controlled application.</param>
/// <returns>Return the status of the external application.</returns>
public Result OnShutdown(UIControlledApplication application)
{
return Result.Succeeded;
}
#endregion IExternalApplication Members
}
}
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<RevitAddIns>
<AddIn Type="Application">
<Name>ExternalResourceUIServer</Name>
<Assembly>ExternalResourceUIServer.dll</Assembly>
<ClientId>82e5614c-237b-4599-a7eb-4adc4d682a3e</ClientId>
<FullClassName>Revit.SDK.Samples.ExternalResourceUIServer.CS.UIServerApplication</FullClassName>
<VendorId>ADSK</VendorId>
<VendorDescription>Autodesk, www.autodesk.com</VendorDescription>
</AddIn>
</RevitAddIns>
@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{1BA33B5D-C64B-4AA3-A367-240A349E47FE}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Revit.SDK.Samples.ExternalResourceUIServer.CS</RootNamespace>
<AssemblyName>ExternalResourceUIServer</AssemblyName>
<StartupObject>
</StartupObject>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<DocumentationFile>bin\Debug\ExternalResourceUIServer.XML</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DocumentationFile>bin\Debug\ExternalResourceUIServer.XML</DocumentationFile>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup>
<RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Application.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SampleExternalResourceUIServer.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\ExternalResourceDBServer\CS\ExternalResourceDBServer.csproj">
<Project>{77ce4920-1be6-4174-88bb-2892e71acd11}</Project>
<Name>ExternalResourceDBServer</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(SolutionDir)VSProps\SDKSamples.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<PropertyGroup>
<PostBuildEvent>set FILEFORSAMPLEREG="$(SolutionDir)..\..\..\..\Regression\API\SDKSamples\UpdateSampleDllForRegression.pl"
if exist %25FILEFORSAMPLEREG%25 perl %25FILEFORSAMPLEREG%25 $(ProjectExt) "$(ProjectPath)" "$(TargetPath)" "$(SolutionDir)"</PostBuildEvent>
</PropertyGroup>
<PropertyGroup>
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
</PropertyGroup>
</Project>
@@ -0,0 +1,55 @@
//
// (C) Copyright 2003-2019 by Autodesk, Inc.
//
// Permission to use, copy, modify, and distribute this software in
// object code form for any purpose and without fee is hereby granted,
// provided that the above copyright notice appears in all copies and
// that both that copyright notice and the limited warranty and
// restricted rights notice below appear in all supporting
// documentation.
//
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
// UNINTERRUPTED OR ERROR FREE.
//
// Use, duplication, or disclosure by the U.S. Government is subject to
// restrictions set forth in FAR 52.227-19 (Commercial Computer
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
// (Rights in Technical Data and Computer Software), as applicable.
//
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 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("ExternalResourceUIServer")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("Copyright © Autodesk, Inc. 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("809814bf-6a09-412a-80f5-ce9612a26380")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -0,0 +1,252 @@
//
// (C) Copyright 2003-2019 by Autodesk, Inc.
//
// Permission to use, copy, modify, and distribute this software in
// object code form for any purpose and without fee is hereby granted,
// provided that the above copyright notice appears in all copies and
// that both that copyright notice and the limited warranty and
// restricted rights notice below appear in all supporting
// documentation.
//
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
// UNINTERRUPTED OR ERROR FREE.
//
// Use, duplication, or disclosure by the U.S. Government is subject to
// restrictions set forth in FAR 52.227-19 (Commercial Computer
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
// (Rights in Technical Data and Computer Software), as applicable.
//
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autodesk.Revit;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.ExternalService;
using Autodesk.Revit.UI;
using Revit.SDK.Samples.ExternalResourceDBServer.CS;
namespace Revit.SDK.Samples.ExternalResourceUIServer.CS
{
class SampleExternalResourceUIServer : IExternalResourceUIServer
{
// Methods that must be implemented by a server for any of Revit's external services
#region IExternalServer Implementation
/// <summary>
/// Return the Id of the server.
/// </summary>
public System.Guid GetServerId()
{
return m_myServerId;
}
/// <summary>
/// Return the Id of the service that the server belongs to.
/// </summary>
public ExternalServiceId GetServiceId()
{
return ExternalServices.BuiltInExternalServices.ExternalResourceUIService;
}
/// <summary>
/// Return the server's name.
/// </summary>
public System.String GetName()
{
return "SDK Sample ExtRes UI Server";
}
/// <summary>
/// Return the server's vendor Id.
/// </summary>
public System.String GetVendorId()
{
return "ADSK";
}
/// <summary>
/// Return the description of the server.
/// </summary>
public System.String GetDescription()
{
return "Simple UI server for the Revit SDK sample external resource server";
}
#endregion IExternalServer Implementation
#region IExternalResourceUIServer Interface Implementation
/// <summary>
/// Return the Id of the related DB server.
/// </summary>
///
public System.Guid GetDBServerId()
{
return m_myDBServerId;
}
/// <summary>
/// Reports the results of loads from the DB server (SampleExternalResourceServer).
/// This method should be implemented to provide UI to communicate success or failure
/// of a particular external resource load operation to the user.
/// </summary>
/// <param name="doc">The Revit model into which the External Resource was loaded.
/// </param>
/// <param name="loadDataList">Contains a list of ExternalResourceLoadData with results
/// for all external resources loaded by the DB server. It is possible for the DB server
/// to have loaded more than one resource (for example, loading several linked files
/// when a host file is opened by the user).
/// </param>
public void HandleLoadResourceResults(Document doc, IList<ExternalResourceLoadData> loadDataList)
{
foreach (ExternalResourceLoadData data in loadDataList)
{
ExternalResourceType resourceType = data.ExternalResourceType;
// This message will be posted in a dialog box at the end of this method.
String myMessage = String.Empty;
ExternalResourceLoadContext loadContext = data.GetLoadContext();
ExternalResourceReference desiredRef = data.GetExternalResourceReference();
ExternalResourceReference currentlyLoadedRef = loadContext.GetCurrentlyLoadedReference();
LoadOperationType loadType = loadContext.LoadOperationType;
switch (loadType)
{
case LoadOperationType.Automatic:
myMessage = "This is an Automatic load operation. ";
break;
case LoadOperationType.Explicit:
myMessage = "This is an Explicit load operation. ";
break;
default:
myMessage = "There is no load type information!! ";
break;
}
bool bUnrecognizedStatus = false;
if (data.LoadStatus == ExternalResourceLoadStatus.ResourceAlreadyCurrent)
{
if (data.GetLoadContext().LoadOperationType == LoadOperationType.Explicit)
{
string resourcePath = currentlyLoadedRef.InSessionPath;
myMessage += "\n No new changes to load for link: " + resourcePath;
}
else
continue;
}
else if (data.LoadStatus == ExternalResourceLoadStatus.Uninitialized)
{
myMessage += "\n The load status is uninitialized - this generally shouldn't happen";
}
else if (data.LoadStatus == ExternalResourceLoadStatus.Failure)
{
myMessage += "\n The load failed and the reason is unknown.";
}
else if (data.LoadStatus == ExternalResourceLoadStatus.Success)
{
if (resourceType == ExternalResourceTypes.BuiltInExternalResourceTypes.KeynoteTable)
{
string resourcePath = data.GetExternalResourceReference().InSessionPath;
myMessage += "\n Version " + data.GetLoadContent().Version + " of keynote data \'" + resourcePath + "\' has been loaded successfully";
}
else if (resourceType == ExternalResourceTypes.BuiltInExternalResourceTypes.RevitLink)
{
string resourcePath = data.GetExternalResourceReference().InSessionPath;
LinkLoadContent ldrlc = (LinkLoadContent)(data.GetLoadContent());
string destinationPath = ModelPathUtils.ConvertModelPathToUserVisiblePath(ldrlc.GetLinkDataPath());
myMessage += "\n Version " + data.GetLoadContent().Version +
" of the file: " + resourcePath +
" has been downloaded into the cached folder: " + destinationPath +
" for this Revit Link.";
}
}
else
{
myMessage += "Unrecognized external resource load status.";
bUnrecognizedStatus = true;
}
if (!bUnrecognizedStatus && resourceType == ExternalResourceTypes.BuiltInExternalResourceTypes.RevitLink)
{
// For Revit links, the UI server can also obtain a RevitLinkLoadResult which contains detailed
// information about the status of the attempt to load the local copy of the link into Revit.
LinkLoadContent ldrlc = (LinkLoadContent)(data.GetLoadContent());
LinkLoadResult loadResult = ldrlc.GetLinkLoadResult();
if (loadResult != null)
{
myMessage += "\n LinkLoadResultType: " + loadResult.LoadResult.ToString("g");
}
}
System.Windows.Forms.MessageBox.Show(myMessage, "UI Server for SDK Sample External Resource Server");
}
}
/// <summary>
/// Use this method to report any problems that occurred while the user was browsing for External Resources.
/// Revit will call this method each time the end user browses to a new folder location, or selects an item
/// and clicks Open.
/// </summary>
public void HandleBrowseResult(ExternalResourceUIBrowseResultType resultType, string browsingItemPath)
{
if (resultType == ExternalResourceUIBrowseResultType.Success)
return;
String resultString = resultType.ToString("g");
// While executing its SetupBrowserData() method, the "DB server" - SampleExternalResourceServer - can store
// detailed information about browse failures that occurred (user not logged in, network down, etc.).
// Subsequently, when Revit calls this method, the details can be read from the DB server and reported to the user.
ExternalService externalResourceService = ExternalServiceRegistry.GetService(ExternalServices.BuiltInExternalServices.ExternalResourceService);
if (externalResourceService == null)
{
System.Windows.Forms.MessageBox.Show("External Resource Service unexpectedly not found.");
return;
}
SampleExternalResourceDBServer myDBServer = externalResourceService.GetServer(GetDBServerId()) as SampleExternalResourceDBServer;
if (myDBServer == null)
{
System.Windows.Forms.MessageBox.Show("Cannot get SampleExternalResourceDBServer from ExternalResourceService.");
return;
}
// ... Retrieve detailed failure information from SampleExternalResourceServer here.
String message = String.Format("The browse result for <{0}> was: <{1}>.", browsingItemPath, resultString);
System.Windows.Forms.MessageBox.Show(message);
}
#endregion IExternalResourceUIServer Interface Implementation
#region SampleExternalResourceUIServer Implementations
#endregion SampleExternalResourceUIServer Implementations
#region SampleExternalResourceUIServer Member Variables
private static Guid m_myServerId = new Guid("E9B6C194-62DE-4134-900D-BA8DF7AD33FA");
private static Guid m_myDBServerId = new Guid("5F3CAA13-F073-4F93-BDC2-B7F4B806CDAF");
#endregion SampleExternalResourceUIServer Member Variables
}
}