Initial working version

This commit is contained in:
2026-05-02 10:18:00 +08:00
commit 5bc65d33ad
14 changed files with 1762 additions and 0 deletions

123
README.md Normal file
View File

@@ -0,0 +1,123 @@
# UserStringProperty
Rhino 插件,根据用户自定义 XML 配置,给 Block 实例附加属性UserString
## 功能
- 根据 XML 配置文件动态生成属性编辑界面
- 支持 `string` 类型字段TextBox`list` 类型字段ComboBox
- 自动保存到 Rhino Block 的 UserString
- 支持多个 XML 模板同时加载、合并
- 模板自动持久化Rhino 重启后自动恢复
- 导入时检测属性集冲突,覆盖或新增
## 安装
### 编译
```bash
cd UserStringProperty
dotnet build
```
输出:`UserStringProperty/bin/UserStringProperty.dll`
### 加载到 Rhino
1.`bin/UserStringProperty.dll` 重命名为 `UserStringProperty.rhp`
2. Rhino → `Options``Plug-ins``Install` → 选择 `.rhp` 文件
### 使用
1. 在 Rhino 中输入命令:`UserstringProperty`
2. 选择要编辑的 Block 实例
3. 默认模板首次启动自动加载;点 **加载XML** 导入自定义模板
4. 在弹出的对话框中选择 cmig 和属性集,若同名已存在则需确认覆盖
5. 在下拉框中选择属性集,编辑各字段值
6. 点击 **写入属性**
## 模板导入
加载 XML 时,会弹出对话框让选择 cmig 和属性集,检测同名冲突:
- **同名属性集不存在** → 直接保存为新模板
- **同名属性集已存在** → 需确认是否覆盖
## XML 配置格式
插件根据 XML 动态生成 UI。示例 XML 格式如下:
```xml
<?xml version="1.0" encoding="utf-8"?>
<cmig name="构件属性">
<propertyset name="构件属性-基本" exclusive="false">
<!-- string 类型 → TextBox -->
<property name="0-00-02-年代" type="string" default="PRC"/>
<!-- list 类型 → ComboBox -->
<property name="0-00-06-构件类型" type="list" default="DS-JG">
<option>DS-JG</option>
<option>DS-WH</option>
<option>DS-SB</option>
</property>
<!-- 分隔标题default 值为一串 dash 且 type="string" -->
<property name="0-01-00-构件基本属性" type="string" default="--------------------" />
</propertyset>
</cmig>
```
### 字段类型
| type | 控件 | 说明 |
|------|------|------|
| `string` | TextBox | 自由文本输入 |
| `list` | ComboBox | 下拉选项(通过 `<option>` 定义) |
### 分隔标题
属性名的 `default` 值以 `---` 开头时(即 `default="--------------------"`),该属性显示为分组标题栏。
## 模板存储
已加载的 XML 模板会复制一份保存到插件目录,重启 Rhino 后自动恢复:
```
%APPDATA%\McNeel\Rhinoceros\8.0\plugins\UserStringProperty\
├── template_index.txt # 记录已加载的 XML 路径
└── *.xml # 模板副本
```
## 项目结构
```
UserStringProperty/
├── CLAUDE.md # agent 指示
├── PLAN.md # 待办事项与开发计划
├── UserStringProperty.csproj
├── UserStringProperty.cs # 插件主类
├── Core/
│ ├── XmlPropertyConfig.cs # XML 解析器
│ └── TemplateManager.cs # 模板管理与持久化
├── Commands/
│ └── CmdUserstringProperty.cs # 命令入口
├── UI/
│ ├── MainDialog.cs # 主窗口
│ └── XmlImportDialog.cs # 导入模式选择对话框
└── Resources/
└── EmbeddedTemplates.cs # 内嵌默认 XML 模板
```
## 编译环境
- **.NET SDK 8.0**
- **Rhino 8**(包含 RhinoCommon.dll SDK 引用)
- Windows 10/11
## 运行时要求
- Rhino 8
## License
MIT