C# Solidworks二次开发:获取主窗口API和创建新活动窗口API详解

今天要讲的是Solidworks中的两个API。

(1)Frame Method (ISldWorks):获取SOLIDWORKS主框架。

下面是API中给出的例子:

 public void Main(){ModelDoc2 swModelDoc = default(ModelDoc2);Frame swFrame = default(Frame);ModelWindow swModelWindow = default(ModelWindow);object[] modelWindows = null;int errors = 0;int warnings = 0;int HWnd = 0;string fileName = null;string strFolder = null;//Open the specified documents in their own windowsfileName = "C:\\Users\\Public\\Documents\\SOLIDWORKS\\SOLIDWORKS 2018\\samples\\tutorial\\assemblymates\\knee.sldprt";swModelDoc = (ModelDoc2)swApp.OpenDoc6(fileName, (int)swDocumentTypes_e.swDocPART, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", ref errors, ref warnings);//Open client model window containing the active documentswApp.CreateNewWindow();fileName = "C:\\Users\\Public\\Documents\\SOLIDWORKS\\SOLIDWORKS 2018\\samples\\tutorial\\assemblymates\\bracket.sldprt";swModelDoc = (ModelDoc2)swApp.OpenDoc6(fileName, (int)swDocumentTypes_e.swDocPART, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", ref errors, ref warnings);//Open client model window containing the active documentswApp.CreateNewWindow();fileName = "C:\\Users\\Public\\Documents\\SOLIDWORKS\\SOLIDWORKS 2018\\samples\\tutorial\\assemblymates\\clamp.sldprt";swModelDoc = (ModelDoc2)swApp.OpenDoc6(fileName, (int)swDocumentTypes_e.swDocPART, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", ref errors, ref warnings);//Open client model window containing the active documentswApp.CreateNewWindow();swFrame = (Frame)swApp.Frame();modelWindows = (object[])swFrame.ModelWindows;Debug.Print("Open documents in their own windows:");foreach (object obj in modelWindows){swModelWindow = (ModelWindow)obj;//Get the model document in this model windowswModelDoc = (ModelDoc2)swModelWindow.ModelDoc;//Rebuild the documentswModelDoc.EditRebuild3();swModelDoc = null;//Show the model windowDebug.Print("");swFrame.ShowModelWindow(swModelWindow);//Get and print the model window handleHWnd = swModelWindow.HWnd;Debug.Print("  Model window handle: " + HWnd);//Get and print the model title as it is seen in the model window's title barDebug.Print("  Model title as it seen in the model's window's title bar: " + swModelWindow.Title);}strFolder = "";//Specify true to close all documents, specify false to close//only the documents not modifiedswApp.CloseAllDocuments(true);}

通过这个API获取到的Frame对象是有很多应用的,比如获取所有文档模型窗口。也可以实现在左侧主状态下方显示文本字符串。

(2)CreateNewWindow Method (ISldWorks):创建包含活动文档的客户端窗口。

使用的例子,在上面的例子已经涉及了。

这篇文章就介绍这两个API,本篇文章到此结束,我们下篇文章再见。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/563136.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

网络安全实训Day8

写在前面 网络工程终于讲完了。这星期到了网络安全技术部分。 网络安全实训-网络安全技术 网络安全概述 信息安全:所有保障计算机硬件、系统、软件、数据不因有意或无意的行为导致的服务中断、数据损坏或丢失等安全事件的保障技术 网络安全:基于计算机…

解决淘宝镜像过期问题 ERR! request https://registry.npm.taobao.org

目录 一、问题描述 二、解决方案 2.1、针对于域名更换解决方案 2.2、针对于证书过期解决方案 三、进行测试 一、问题描述 针对于2022年5月31号和2024年1 月 22 日前的前端项目 npm.taobao.org和旧域名于2021年官方公告域名更换事件,已于2022年05月31日零时起…

Spark Stage

Spark Stage 什么是Stage Spark中的一个Stage只不过是物理执行计划其中的一个步骤,它是物理执行计划的一个执行单元。一个Job会被拆分为多组Task,每组任务被称为一个Stage,可以简单理解为MapReduce里面的Map Stage, Reduce Stag…

【Node.js】全局变量和全局 API

node 环境中没有 dom 和 bom ,此外 es 基本上都是可以正常使用的。 如果一定要使用 dom 和bom,可以借助第三方库 jsdom 帮助我们实现操作。npm i jsdom 实例: const fs require(node:fs) const {JSDOM} require(jsdom)const dom new JS…

YOLOv9/YOLOv8算法改进【NO.106】使用YOLOv7下采样进行改进

前 言 YOLO算法改进系列出到这,很多朋友问改进如何选择是最佳的,下面我就根据个人多年的写作发文章以及指导发文章的经验来看,按照优先顺序进行排序讲解YOLO算法改进方法的顺序选择。具体有需求的同学可以私信我沟通: 首推…

SQLiteC/C++接口详细介绍sqlite3_stmt类(六)

返回:SQLite—系列文章目录 上一篇:SQLiteC/C接口详细介绍sqlite3_stmt类(五) 下一篇: SQLiteC/C接口详细介绍sqlite3_stmt类(七) 17. sqlite3_clear_bindings函数 sqlite3_clear_bindings函…

Axure RP 9 for Mac中文激活版:原型设计工具

Axure RP 9 for Mac是一款值得设计师信赖的原型设计工具。它以其卓越的性能和稳定的运行赢得了广大用户的赞誉。 软件下载:Axure RP 9 for Mac中文激活版下载 在Axure RP 9中,您可以尽情发挥自己的设计才华,创造出独一无二的原型作品。无论是…

【排序算法】实现快速排序值(霍尔法三指针法挖坑法优化随机选key中位数法小区间法非递归版本)

文章目录 📝快速排序🌠霍尔法🌉三指针法🌠挖坑法✏️优化快速排序 🌠随机选key🌉三位数取中 🌠小区间选择走插入,可以减少90%左右的递归🌉 快速排序改非递归版本&#x1…

阿里云OSS存储的视频如何加水印

OSS是不能进行视频添加水印的,可以图片添加水印。 您可以在视频点播中进行配置: https://help.aliyun.com/zh/vod/user-guide/video-watermarks?spma2c4g.11186623.0.i2 原来的业务代码都是使用python 对oss的 视频进行上传 的,上传的视频路径已经保存到…

stm32平衡车

目录 一.所需材料 二.PID算法(简单说明) 直立环 速度环 串级PID 三.使用到的外设 1.定时器输出比较-PWM 2.定时器编码器模式 3.编码器读取速度 4.电机驱动函数 5.外部中断 四、小车 调试 一.所需材料 1.陀螺仪MPU6050--读取三轴的加速度…

Photoshop 工具使用详解(全集 · 2024版)

全面介绍 Photoshop 工具箱里的工具,点击下列表格中工具名称或图示,即可查阅工具的使用详解。 移动工具Move Tool移动选区、图层和参考线。画板工具Artboard Tool创建、移动多个画布或调整其大小。moVe快捷键:V 矩形选框工具 Rectangular Mar…

java数据结构与算法基础-----字符串------正则表达式的练习案例---持续补充中

java数据结构与算法刷题目录(剑指Offer、LeetCode、ACM)-----主目录-----持续更新(进不去说明我没写完):https://blog.csdn.net/grd_java/article/details/123063846 正则表达式基础:https://blog.csdn.net/grd_java/article/det…