修复图例问题和标记问题

This commit is contained in:
GG Z
2021-11-23 16:37:19 +08:00
parent e16b1c0f4a
commit c08ea509f8
131 changed files with 1310 additions and 1948 deletions

View File

@@ -0,0 +1,104 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{C60B068A-90A8-4852-B6DC-28A2D3FF2753}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>AddinDeployer</RootNamespace>
<AssemblyName>AddinDeployer</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>x64</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<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>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="AdWindows, Version=2018.11.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Revit_API_x64.2020.0.0\lib\NET470\AdWindows.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="PresentationFramework" />
<Reference Include="RevitAddInUtility, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Revit_API_x64.2020.0.0\lib\NET470\RevitAddInUtility.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="RevitAPI, Version=20.0.0.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\Revit_API_x64.2020.0.0\lib\NET470\RevitAPI.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="RevitAPIUI, Version=20.0.0.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\Revit_API_x64.2020.0.0\lib\NET470\RevitAPIUI.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration.Install" />
<Reference Include="System.Core" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="UIFramework, Version=20.0.0.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\Revit_API_x64.2020.0.0\lib\NET470\UIFramework.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UIFrameworkServices, Version=20.0.0.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\Revit_API_x64.2020.0.0\lib\NET470\UIFrameworkServices.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="CustomActionClass.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -0,0 +1,232 @@
using Autodesk.Revit.DB;
using Autodesk.RevitAddIns;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static Autodesk.Internal.Windows.SwfMediaPlayer;
namespace AddinDeployer
{
[RunInstaller(true)]
public class CustomActionClass : Installer
{
//public static void Main(string[] args)
//{
//}
private string path;
private static string assemblyname = "RookieStation";
private static string addinname = "RookieStation.addin";
private static string dllname = "RookieStation.dll";
private string fullclassname1 = "RookieStation.RibbonMenu.RsApp";
public CustomActionClass()
{
this.BeforeInstall += CustomActionClass_BeforeInstall;
this.BeforeUninstall += CustomActionClass_BeforeUninstall;
this.AfterInstall += CustomActionClass_AfterInstall;
}
//private string revitvernum = "2020";
public static void KillProcess(string strProcessesByName)//关闭线程
{
foreach (Process p in Process.GetProcesses())//GetProcessesByName(strProcessesByName))
{
if (p.ProcessName.ToUpper().Contains(strProcessesByName))
{
try
{
p.Kill();
p.WaitForExit(); // possibly with a timeout
}
catch (Win32Exception e)
{
MessageBox.Show(e.Message.ToString()); // process was terminating or can't be terminated - deal with it
}
catch (InvalidOperationException e)
{
MessageBox.Show(e.Message.ToString()); // process has already exited - might be able to let this one go
}
}
}
}
private void CustomActionClass_BeforeUninstall(object sender, InstallEventArgs e)
{
KillProcess("REVIT");
//var dialogResult = System.Windows.Forms.MessageBox.Show("是否关闭Revit以卸载插件", "提示", System.Windows.Forms.MessageBoxButtons.YesNo);
//if (dialogResult == System.Windows.Forms.DialogResult.Yes)
//{
//}
//while (MessageBox.Show("退出当前窗体?", "", MessageBoxButtons.YesNo) == DialogResult.No)
//{
// for (int j = 1; j <= i; j++)
// {
// listBox1.Items.Add(j);
// }
//}
//System.Environment.Exit(System.Environment.ExitCode);
//var ps = Process.GetProcessesByName("Revit.exe");
//foreach (var p in ps)
//{
// p.Kill();
//}
}
private void CustomActionClass_BeforeInstall(object sender, InstallEventArgs e)
{
KillProcess("REVIT");
//var dialogResult = System.Windows.Forms.MessageBox.Show("是否关闭Revit以安装插件", "提示", System.Windows.Forms.MessageBoxButtons.YesNo);
//if (dialogResult == System.Windows.Forms.DialogResult.Yes)
//{
//}
//var ps = Process.GetProcessesByName("Revit.exe");
//foreach (var p in ps)
//{
// p.Kill();
//}
//else
//{
// //this.Exit()
//}
}
private static void CustomActionClass_AfterInstall(object sender, InstallEventArgs e)
{
}
private static void CustomActionClass_AfterUninstall(object sender, InstallEventArgs e)
{
//DeleteFolder(path);
//DelAddinFromPath("C:\\ProgramData\\Autodesk\\Revit\\Addins");
List<RevitProduct> revitProducts = RevitProductUtility.GetAllInstalledRevitProducts();
foreach (var p in revitProducts)
{
string version = p.Version.ToString();
string versionnum = version.Trim("Revit".ToCharArray());
AddInInstaller addin = new AddInInstaller(versionnum);
addin.Uninstall();
}
}
public static void DeleteFolder(string dir)
{
if (Directory.Exists(dir)) //如果存在这个文件夹删除之
{
foreach (string d in Directory.GetFileSystemEntries(dir))
{
if (File.Exists(d))
File.Delete(d); //直接删除其中的文件
else
DeleteFolder(d); //递归删除子文件夹
}
Directory.Delete(dir, true); //删除已空文件夹
}
}
public static void DelAddinFromPath(string dir)
{
if (Directory.Exists(dir))
{
foreach (string d in Directory.GetFileSystemEntries(dir))
{
if (File.Exists(d) && d.EndsWith(addinname))
File.Delete(d); //直接删除其中的文件
else
DelAddinFromPath(d);
}
}
}
public override void Rollback(IDictionary savedState)
{
base.Rollback(savedState);
}
public override void Commit(IDictionary savedState)
{
base.Commit(savedState);
}
public override void Install(IDictionary stateSaver)
{
base.Install(stateSaver);
}
public override void Uninstall(IDictionary savedState)
{
base.Uninstall(savedState);
}
}
internal class AddInInstaller
{
private string addinname = "RookieStation.addin";
private string vendorid = "YTX";
private string vendorDescription = "YTX";
internal AddInInstaller(string revitVersion)
{
this.Manifest = new RevitAddInManifest();
this.ManifestPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Autodesk\\Revit\\Addins", revitVersion, addinname);
}
private RevitAddInManifest Manifest { get; }
private string ManifestPath { get; }
internal void CreateApplication(string name, string assemblyPath, string fullClassName)
{
RevitAddInApplication item = new RevitAddInApplication(name, assemblyPath, Guid.NewGuid(), fullClassName, vendorid)
{
VendorDescription = vendorDescription
};
this.Manifest.AddInApplications.Add(item);
}
internal void CreateCommand(string assemblyPath, string fullClassName)
{
RevitAddInCommand item = new RevitAddInCommand(assemblyPath, Guid.NewGuid(), fullClassName, vendorid)
{
VendorDescription = vendorDescription
};
this.Manifest.AddInCommands.Add(item);
}
internal void Install()
{
DirectoryInfo directory = new FileInfo(this.ManifestPath).Directory;
if (directory == null)
{
return;
}
if (!directory.Exists)
{
Directory.CreateDirectory(directory.FullName);
}
this.Manifest.SaveAs(this.ManifestPath);
}
internal void Uninstall()
{
if (File.Exists(this.ManifestPath))
{
File.Delete(this.ManifestPath);
}
}
}
}

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("AddinDeployer")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AddinDeployer")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("c60b068a-90a8-4852-b6dc-28a2d3ff2753")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Revit_API_x64" version="2020.0.0" targetFramework="net472" />
</packages>