Files
UserStringProperty/README.md
230238001 c54bdebe59 Initial commit: UserStringProperty Rhino plugin
- Rhino 8 C# plugin for managing Block UserString properties
- XML template import with merge modes
- WinForms UI for property editing
- .NET Framework 4.8
2026-05-02 10:18:00 +08:00

122 lines
3.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 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. 在下拉框中选择属性集,编辑各字段值
5. 点击 **保存**
## 模板导入模式
加载 XML 时,如果已有模板,会弹出对话框让选择导入模式:
| 模式 | 说明 |
|------|------|
| 添加为新属性集 | 追加到现有列表末尾 |
| 完全替代现有模板 | 清空所有现有属性集 |
| 合并更新 | 同名属性集覆盖,其他保留 |
| 智能合并 | 同名覆盖,同时追加新属性集 |
## XML 配置格式
插件根据 XML 动态生成 UI。示例参见 `Component_Property_base.xml``Component_Property_carbon.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 模板
```
## 环境要求
- Rhino 8
- .NET Framework 4.8
- .NET SDK 8.0(编译用)
## License
MIT