Files
UserStringProperty/README.md
230238001 37888b5f7e Add plugin GUID, fix template import and dialog improvements
- Add [assembly: Guid(...)] for proper Rhino plugin registration
- Fix Import() to add new config to _configs after importing XML
- Simplify XmlImportDialog: remove section labels, add conflict confirmation
- Move plugin data folder to standard Plug-ins path with GUID suffix
- Add ContractXml as third embedded template
- Update README with correct import flow and build requirements
- Fix csproj duplicate PropertyGroup issue
2026-05-02 11:34:51 +08:00

123 lines
3.5 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. 在弹出的对话框中选择 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