实现插件弹出,使用命令PARAM_PANEL
This commit is contained in:
parent
9481aae0f8
commit
bf015be21a
32
.gitignore
vendored
Normal file
32
.gitignore
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
# Build outputs
|
||||
bin/
|
||||
obj/
|
||||
|
||||
# Visual Studio
|
||||
.vs/
|
||||
*.user
|
||||
*.suo
|
||||
|
||||
# Debugging and logs
|
||||
*.pdb
|
||||
*.log
|
||||
|
||||
# Temporary/cache files
|
||||
*.tmp
|
||||
*.temp
|
||||
*.cache
|
||||
|
||||
# NuGet
|
||||
packages/
|
||||
*.nupkg
|
||||
project.lock.json
|
||||
*.snupkg
|
||||
|
||||
# ReSharper / Rider / VS tooling
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# AutoCAD related temp (safe to ignore)
|
||||
*.bak
|
||||
*.sv$
|
||||
59
CadParamPluging.csproj
Normal file
59
CadParamPluging.csproj
Normal file
@ -0,0 +1,59 @@
|
||||
<?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>{AD96D669-51E6-4EA0-A460-3667C13AE2D9}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>CadParamPluging</RootNamespace>
|
||||
<AssemblyName>CadParamPluging</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="accoremgd">
|
||||
<HintPath>C:\Program Files\Autodesk\AutoCAD 2014\accoremgd.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="acdbmgd">
|
||||
<HintPath>C:\Program Files\Autodesk\AutoCAD 2014\acdbmgd.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="acmgd">
|
||||
<HintPath>C:\Program Files\Autodesk\AutoCAD 2014\acmgd.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="PluginEntry.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
25
CadParamPluging.sln
Normal file
25
CadParamPluging.sln
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.11.35303.130
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CadParamPluging", "CadParamPluging.csproj", "{AD96D669-51E6-4EA0-A460-3667C13AE2D9}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{AD96D669-51E6-4EA0-A460-3667C13AE2D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{AD96D669-51E6-4EA0-A460-3667C13AE2D9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{AD96D669-51E6-4EA0-A460-3667C13AE2D9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{AD96D669-51E6-4EA0-A460-3667C13AE2D9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {262AD728-3893-4960-9684-63A95DAEC88F}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
23
PackageContents.xml
Normal file
23
PackageContents.xml
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ApplicationPackage SchemaVersion="1.0"
|
||||
AppVersion="1.0"
|
||||
ProductCode="{CC85F3CB-E948-41BF-AF08-E61E9427EFA0}"
|
||||
Name="CadParamPluging"
|
||||
Description="Parametric drawing plugin"
|
||||
Author="XXX"
|
||||
AppName="CadParamPluging"
|
||||
UpgradeCode="{E2DCC434-D482-4852-A4D8-6BB8694CCFF8}">
|
||||
<CompanyDetails Name="YourCompany" />
|
||||
<Components>
|
||||
<ComponentEntry AppName="CadParamPluging"
|
||||
Version="1.0"
|
||||
ModuleName="./Contents/Windows/CadParamPluging.dll"
|
||||
LoadOnAutoCADStartup="True"
|
||||
LoadReasons="Startup"
|
||||
OS="Win32|Win64"
|
||||
Platform="AutoCAD"
|
||||
SeriesMin="R19.1"
|
||||
SeriesMax="R19.1">
|
||||
</ComponentEntry>
|
||||
</Components>
|
||||
</ApplicationPackage>
|
||||
37
Plan.md
Normal file
37
Plan.md
Normal file
@ -0,0 +1,37 @@
|
||||
## 开发计划与里程碑(按 Readme 要求,模板为 CAD 文件路径)
|
||||
|
||||
### 阶段 1:项目骨架与环境
|
||||
- 目标:插件可在 AutoCAD 2014 启动后自动加载,面板可见。
|
||||
- 里程碑:解决方案结构就绪(Plugin/Domain/Data/Common 或等效命名空间);实现 `IExtensionApplication`,PaletteSet 显示占位;`.bundle` 自动加载和 `PARAM_PANEL` 可用。
|
||||
|
||||
### 阶段 2:参数模型与业务入口
|
||||
- 目标:定义参数契约供 UI/算法使用。
|
||||
- 里程碑:完成 `TemplateParams`, `DrawingParams`, `TemplateInfo` 等模型;Domain 入口 `DomainFacade.SelectTemplate/ValidateParameters/DrawByParams` 定义(可先空实现)。
|
||||
|
||||
### 阶段 3:模板路径配置与匹配
|
||||
- 目标:以 CAD 模板文件路径为基础完成匹配,不依赖 JSON。
|
||||
- 里程碑:确定模板路径来源(常量/配置文件/app.config);实现 `ITemplateRepository`(按路径列表筛选);完成按 `TemplateParams` 匹配唯一模板并返回 `TemplateInfo`;UI 能点击“匹配模板”并显示结果。
|
||||
|
||||
### 阶段 4:CAD 封装与基本出图
|
||||
- 目标:打通最小绘图链路,基于模板新建图纸并绘制简单几何。
|
||||
- 里程碑:实现 `CadContext`、`CadDrawingService` 基础操作;`TemplateDrawingService` 支持基于模板文件创建新 Document;`DomainFacade.DrawByParams` 最小实现(示例几何)验证端到端。
|
||||
|
||||
### 阶段 5:UI 面板完善
|
||||
- 目标:完成 Readme 所述四区 UI。
|
||||
- 里程碑:模板参数区 + 匹配按钮与结果;出图参数区占位输入;操作区(生成图纸/保存/打开配置);日志区显示匹配、校验、出图进度与错误。
|
||||
|
||||
### 阶段 6:参数校验与错误提示
|
||||
- 目标:输入校验闭环。
|
||||
- 里程碑:`ValidateParameters` 校验必填/范围并抛业务异常;UI 捕获并日志提示具体字段问题。
|
||||
|
||||
### 阶段 7:生成与保存体验
|
||||
- 目标:生成成功提示并可保存 DWG。
|
||||
- 里程碑:生成完成提示;保存对话框调用 `Database.SaveAs()`;插件加载后面板自动显示,无需用户命令。
|
||||
|
||||
### 阶段 8:业务规则迭代
|
||||
- 目标:接入真实模板和绘图策略。
|
||||
- 里程碑:补充真实模板路径列表与匹配策略;扩展不同图纸类型的绘图策略类;可选:批量生成/指定目录一键生成。
|
||||
|
||||
### 阶段 9:测试与验收
|
||||
- 目标:覆盖匹配、校验、绘图、保存的自测。
|
||||
- 里程碑:多组参数验证匹配唯一性与错误提示;验证绘图随参数变化的结果与图层/文字/标注;验证保存的 DWG 可正常重开。
|
||||
53
PluginEntry.cs
Normal file
53
PluginEntry.cs
Normal file
@ -0,0 +1,53 @@
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using Autodesk.AutoCAD.Runtime;
|
||||
using Autodesk.AutoCAD.Windows;
|
||||
|
||||
namespace CadParamPluging
|
||||
{
|
||||
public class PluginEntry : IExtensionApplication
|
||||
{
|
||||
private static PaletteSet _palette;
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
ShowPalette();
|
||||
}
|
||||
|
||||
public void Terminate()
|
||||
{
|
||||
// 可在此释放资源或记录日志
|
||||
}
|
||||
|
||||
private void ShowPalette()
|
||||
{
|
||||
if (_palette == null)
|
||||
{
|
||||
_palette = new PaletteSet("参数化出图")
|
||||
{
|
||||
Style = PaletteSetStyles.ShowCloseButton |
|
||||
PaletteSetStyles.ShowAutoHideButton |
|
||||
PaletteSetStyles.Snappable
|
||||
};
|
||||
|
||||
var placeholder = new Label
|
||||
{
|
||||
Text = "Param panel placeholder",
|
||||
Dock = DockStyle.Fill,
|
||||
TextAlign = ContentAlignment.MiddleCenter
|
||||
};
|
||||
|
||||
_palette.Add("Main", placeholder);
|
||||
_palette.MinimumSize = new Size(240, 200);
|
||||
}
|
||||
|
||||
_palette.Visible = true;
|
||||
}
|
||||
|
||||
[CommandMethod("PARAM_PANEL")]
|
||||
public void ShowPanelCommand()
|
||||
{
|
||||
ShowPalette();
|
||||
}
|
||||
}
|
||||
}
|
||||
33
Properties/AssemblyInfo.cs
Normal file
33
Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,33 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 有关程序集的一般信息由以下
|
||||
// 控制。更改这些特性值可修改
|
||||
// 与程序集关联的信息。
|
||||
[assembly: AssemblyTitle("CadParamPluging")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("CadParamPluging")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2025")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// 将 ComVisible 设置为 false 会使此程序集中的类型
|
||||
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
|
||||
//请将此类型的 ComVisible 特性设置为 true。
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
|
||||
[assembly: Guid("ad96d669-51e6-4ea0-a460-3667c13ae2d9")]
|
||||
|
||||
// 程序集的版本信息由下列四个值组成:
|
||||
//
|
||||
// 主版本
|
||||
// 次版本
|
||||
// 生成号
|
||||
// 修订号
|
||||
//
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
Loading…
Reference in New Issue
Block a user