140 lines
4.6 KiB
Markdown
140 lines
4.6 KiB
Markdown
---
|
||
name: nw-api
|
||
description: Navisworks API 开发助手,用于开发 Navisworks 插件。功能包括:(1) 查看 NET API 文档位置和使用方法,(2) 查看官方 NET API 示例代码,(3) 搜索 Navisworks NET API 使用方法和示例。当用户询问 Navisworks API、插件开发、NET API、C# 开发相关内容时使用此技能。
|
||
---
|
||
|
||
# Navisworks NET API 开发助手
|
||
|
||
帮助开发 Autodesk Navisworks 插件的专用技能。主要基于 .NET API,COM API 作为补充参考。
|
||
|
||
## 本地文档位置
|
||
|
||
### API 文档(主要)
|
||
|
||
| 类型 | 路径 | 格式 |
|
||
|------|------|------|
|
||
| NET API | `doc/navisworks_api/NET/documentation/NET API.chm` | CHM 帮助文件 |
|
||
| NET API HTML | `doc/navisworks_api/NET/documentation/NetAPIHtml/` | HTML 文档 |
|
||
|
||
**推荐导航入口**: `doc/navisworks_api/NET/documentation/NetAPIHtml/index.html`
|
||
|
||
**原始 HTML 文档入口**: `doc/navisworks_api/NET/documentation/NetAPIHtml/html/index.html`
|
||
|
||
### API 文档搜索方法
|
||
|
||
HTML 文档已生成为可搜索的网页形式,可以直接用 Grep 工具搜索:
|
||
|
||
```bash
|
||
# 搜索 ModelItem 的属性
|
||
Grep -i "ModelItem.*property" doc/navisworks_api/NET/documentation/NetAPIHtml/html/
|
||
|
||
# 搜索特定方法
|
||
Grep -i "BoundingBox" doc/navisworks_api/NET/documentation/NetAPIHtml/html/
|
||
|
||
# 搜索类定义
|
||
Grep "class.*ModelItem" doc/navisworks_api/NET/documentation/NetAPIHtml/html/
|
||
```
|
||
|
||
**文件命名规律**:
|
||
|
||
- 类型页面: `T_Autodesk_Navisworks_Api_{ClassName}.htm`
|
||
- 属性页面: `P_Autodesk_Navisworks_Api_{ClassName}_{PropertyName}.htm`
|
||
- 方法页面: `M_Autodesk_Navisworks_Api_{ClassName}_{MethodName}.htm`
|
||
- 所有成员: `AllMembers_T_Autodesk_Navisworks_Api_{ClassName}.htm`
|
||
- 属性列表: `Properties_T_Autodesk_Navisworks_Api_{ClassName}.htm`
|
||
- 方法列表: `Methods_T_Autodesk_Navisworks_Api_{ClassName}.htm`
|
||
|
||
### 官方示例代码(NET API)
|
||
|
||
| 示例类型 | 路径 |
|
||
|----------|------|
|
||
| 基础插件 | `doc/navisworks_api/NET/examples/Basic Examples/CSharp/` |
|
||
| 插件集合 | `doc/navisworks_api/NET/examples/PlugIns/` |
|
||
| 自动化 | `doc/navisworks_api/NET/examples/Automation/` |
|
||
| 控件集成 | `doc/navisworks_api/NET/examples/Controls/` |
|
||
| 工具插件 | `doc/navisworks_api/NET/examples/Tools/` |
|
||
|
||
### 项目设计文档
|
||
|
||
- `doc/design/2026/NavisworksAPI使用方法.md` - API 使用指南
|
||
- `doc/migration/API_Migration_Analysis_2017_to_2026.md` - 版本迁移指南
|
||
- `doc/migration/Navisworks_2026_API_Changes.md` - 2026 API 变更
|
||
|
||
## COM API 参考(补充)
|
||
|
||
| 类型 | 路径 |
|
||
|------|------|
|
||
| COM API 文档 | `doc/navisworks_api/COM/documentation/NavisWorksCOM.chm` |
|
||
| COM 示例 | `doc/navisworks_api/COM/examples/` |
|
||
|
||
## 在线资源
|
||
|
||
- **Autodesk Platform Services**: <https://aps.autodesk.com/developer/overview/navisworks>
|
||
- **AEC DevBlog**: <https://adndevblog.typepad.com/aec/navisworks/>
|
||
- **ApiDocs (2017-2018)**: <https://apidocs.co/apps/navisworks/>
|
||
|
||
## 快速参考
|
||
|
||
### 命名空间
|
||
|
||
```csharp
|
||
// 核心 API
|
||
using Autodesk.Navisworks.Api;
|
||
using Autodesk.Navisworks.Api.Plugins;
|
||
using Autodesk.Navisworks.Api.Clash;
|
||
using Autodesk.Navisworks.Api.Timeliner;
|
||
|
||
// COM API(需要时)
|
||
using Autodesk.Navisworks.ComApi;
|
||
using Autodesk.Navisworks.Interop.ComApi;
|
||
```
|
||
|
||
### 插件类型
|
||
|
||
| 基类 | 用途 | 示例位置 |
|
||
|------|------|----------|
|
||
| `DockPanePlugin` | 停靠面板插件 | `Basic Examples/CSharp/BasicDockPanePlugin/` |
|
||
| `ToolPlugin` | 鼠标交互工具 | `PlugIns/InputAndRenderHandling/` |
|
||
| `RenderPlugin` | 3D 渲染插件 | `PlugIns/InputAndRenderHandling/` |
|
||
| `AddInPlugin` | 简单命令插件 | `PlugIns/Examiner/` |
|
||
| `EventWatcherPlugin` | 监听文档事件 | `PlugIns/ClashDetective/EventLog/` |
|
||
|
||
### 关键 API 入口
|
||
|
||
```csharp
|
||
// 当前文档
|
||
Document doc = Application.ActiveDocument;
|
||
|
||
// 当前选择
|
||
ModelItemCollection selection = doc.CurrentSelection.SelectedItems;
|
||
|
||
// 模型遍历
|
||
foreach (ModelItem item in doc.Models.RootItemDescendantsAndSelf) { }
|
||
|
||
// 搜索
|
||
Search search = new Search();
|
||
search.SearchConditions.Add(SearchCondition.HasCategoryByName(PropertyCategoryNames.Geometry));
|
||
ModelItemCollection results = search.FindAll(doc, false);
|
||
```
|
||
|
||
## 参考资料
|
||
|
||
- **常用 API 模式**: 见 `references/api-usage-patterns.md`
|
||
- **插件类型详解**: 见 `references/plugin-types.md`
|
||
- **NET 示例速查**: 见 `references/net-examples-guide.md`
|
||
|
||
## Web 搜索
|
||
|
||
如需查找最新的 API 用法或示例,使用 `SearchWeb` 工具搜索:
|
||
|
||
```
|
||
SearchWeb: "Navisworks .NET API {query} example C#"
|
||
```
|
||
|
||
常用搜索模板:
|
||
|
||
- `Navisworks .NET API ModelItem transform example`
|
||
- `Navisworks .NET API plugin DockPane C#`
|
||
- `Navisworks .NET API search condition example`
|
||
- `Navisworks 2026 .NET API changes`
|