C# Solidworks二次开发:比较两个solidworks文档属性相关API详解

ops/2024/11/15 7:26:05/
htmledit_views">

大家好,今天要讲的文章是关于如何比较两个solidworks文档。

下面是API的介绍:

(1)第一个为Close,这个API的含义为在比较solidworks文档以后执行必要的清理。下面是官方的具体解释:

其没有输入参数,返回值为定义的错误 gtError_e,其错误类型如下所示:

MemberDescription
gtErrArgument1Incorrect11001 = Feature paint 11001 thorugh 12000
gtErrArgument2Incorrect11002
gtErrArgumentOutofRange22
gtErrAssemblyInEditPartMode26
gtErrBsdAlreadyOpenNot used
gtErrBsdDefaultDrwTemplateNot used
gtErrBsdDocNotSavedNot used
gtErrBsdInvalidArgNot used
gtErrBsdInvalidSaveLocationPathNot used
gtErrBsdInvalidSheetFormatPathNot used
gtErrBsdLowMemoryNot used
gtErrBsdNoActivePartDocNot used
gtErrBsdNoSheetMetalFeatureFoundNot used
gtErrBsdNotInitializedNot used
gtErrBsdOpenedReadOnlyNot used
gtErrBsdUserCanceledNot used
gtErrBsdVirtualComponentNot used
gtErrCompareFacesFailed7001 = Compare geometry 7001 through 8000
gtErrCompareFeaturesFailed6001 = Compare features 6001 through 7000
gtErrCompareGeometryNotExecuted7007
gtErrCompareVolFailed7002
gtErrCompareVolumeNotExecuted7013
gtErrCompDocsAlreadyOpen5001 = Compare documents 5001 through 6000
gtErrCompDocsInvalidModConfig5008
gtErrCompDocsInvalidModFile5006
gtErrCompDocsInvalidRefConfig5007
gtErrCompDocsInvalidRefFile5005
gtErrCompDocsNotExecuted5002
gtErrCompDocsOperationOptions5003 = Operation out of range
gtErrCompDocsResultOptions5004 = Result option out of range
gtErrCompDocsSameRefModFilesConfigs5009
gtErrCompFeatAlreadyRunning6004
gtErrCompFeatInvalidModConfig6010
gtErrCompFeatInvalidModFile6003
gtErrCompFeatInvalidRefConfig6009
gtErrCompFeatInvalidRefFile6002
gtErrCompFeatModNoSolidBodies6007
gtErrCompFeatNotExecuted6008
gtErrCompFeatRefNoSolidBodies6006
gtErrCompFeatResultOptions6005
gtErrCompFeatSameRefModFilesConfigs6011
gtErrCompGeomAlreadyOpen7008
gtErrCompGeomInvalidModConfig7015
gtErrCompGeomInvalidModFile7010
gtErrCompGeomInvalidRefConfig7014
gtErrCompGeomInvalidRefFile7009
gtErrCompGeomOperationOptions7011
gtErrCompGeomResultOptions7012
gtErrCompGeomSameRefModFilesConfigs7016
gtErrCouldNotCreateReportFolders14
gtErrDesignBinderReportAlreadyExists30
gtErrDoc1NotSelected33
gtErrDoc2NotSelected34
gtErrDocInEditSketchMode12
gtErrDocIsEmpty5
gtErrDocNotSelected2
gtErrDocOpenedViewOnly8
gtErrDocsAreSame4
gtErrDocsConfigNotExist29
gtErrDocsConfigsAreSame28
gtErrEdrawingFileAlreadyExists12018
gtErrFaceComparisonNotPossibleInAssemblies27
gtErrFacesIdentical7003
gtErrFileAlreadyExists20
gtErrFileNotFound18
gtErrFindText12019 = Property IFindReplaceAnnotations::FindText is not set
gtErrGckAlreadyOpen8001 = Geometry analysis 8001 through 9000
gtErrGckDRTError8003
gtErrGckInsufficientMemoryProvided8006
gtErrGckInvalidEntityParamater8008
gtErrGckNoActivePartDoc8002
gtErrGckNoGetCountFunctionCalled8005
gtErrGckNotInitialized8007
gtErrGckResultsAlreadyPresent8004
gtErrIncompatibleFile6
gtErrIncorrectFileName3
gtErrIncorrectReportPath15
gtErrInvalidFile17
gtErrNonSimilarParts7004
gtErrNoPartDocs25
gtErrNoSolidBodies19
gtErrNoSourceFeature11003
gtErrNoTargetFeature11004
gtErrNoUI12022
gtErrNoValidIndex12023
gtErrOpeningFile1
gtErrPslAlreadyRunning10014
gtErrPslAngleOutofRange10006
gtErrPslBothConvexConcaveNotSet10004
gtErrPslColorOutofRange10007
gtErrPslErrFilterTypeOutofRange10010
gtErrPslErrOperatorOutofRange10005
gtErrPslErrorInSelection10017
gtErrPslFeatureTypeOutofRange10008
gtErrPslIncorrectFeatureNameString10009
gtErrPslIncorrectFeatureTypeArray10018
gtErrPslNoActivePartDoc10016
gtErrPslNoFeatureTypeFilterSet10011
gtErrPslNoFilterSet10002
gtErrPslNoSelectEntitySet10001 = PowerSelect 10001 through 10019
gtErrPslNotInitialized10015
gtErrPslNotRun10013
gtErrPslResultOptions10019
gtErrPslSpecifiedFilterNotSet10003
gtErrPslUIRunning10012
gtErrReferenceBOMNotSelected31
gtErrReplaceText12020 = Property IFindReplaceAnnotations::ReplaceText is not set
gtErrReportAlreadyExists13
gtErrResultUIOn23
gtErrRollback11008
gtErrSameNameDocAlreadyOpen7
gtErrSameSourceTargetFeature11005
gtErrSavingFile16
gtErrSavingVolDiffResults7005
gtErrSharedByCompDocs11
gtErrSharedByFeatDiff10
gtErrSharedByGeomDiff9
gtErrSourceFeatErr11006
gtErrSourceFeatureRolledBack11009
gtErrSourceNoBodyFeature11011
gtErrTargetFeatErr11007
gtErrTargetFeatureRolledBack11010
gtErrTargetNoBodyFeature11012
gtErrtckBodyDoesNotExist12005
gtErrtckBodyNotSet12006
gtErrtckNoActivePartDoc12001 = Thickness analysis 12001 through 13000
gtErrTckNotInitialized12004
gtErrTckNotPerformed12015
gtErrTckNotValid12016
gtErrTckResolution12003
gtErrTckResultOptions12002
gtErrtckTesselationFailed12008
gtErrTcktThickRegnLimitNotInRange12014
gtErrTcktTrgThicknessNotInRange12013
gtErrtckUIRunning12007
gtErrThicknessRangeNotValid12017
gtErrToBeComparedBOMNotSelected32
gtErrToolNotSupported21  = Returned by IUtilities::GetToolInterface
gtErrUIInvoked12021 = PropertyManager page is already displayed
gtErrUtilityAlreadyRunning24
gtErrVolDiffResultsAlreadySaved7006
gtNOErr0 = No error
gtUnknownErr-1 = Common -1 through 5000
gtWarningTckThickAnalRangeAboveMaxThick12011
gtWarningTckThickAnalRangeBelowMaxThick12012
gtWarningTckThinAnalMinMaxThckSameAsTrg12010
gtWarningTckThinAnalRangeBelowMaxThick12009

(2)第二个为CompareDocument2:,这个API的含义为比较指定的solidworks文档的属性并生成报告,下面是官方的具体解释:

下面是官方使用的例子,因为没有C#的,只有VBA的,如下所示:

This example shows how to compare the volumes of two parts and save the results of the comparison using the SOLIDWORKS Utilities API.

'------------------------------------------------------------------------------
' Preconditions:
' 1. Add the SOLIDWORKS Utilities as an add-in
'    (in SOLIDWORKS, click Tools > Add-Ins > SOLIDWORKS Utilities).
' 2. Add the SOLIDWORKS Utilities type library as a reference
'    (in the SOLIDWORKS Microsoft Visual Basic for Applications IDE, click
'    Tools > References > SolidWorks Utilities <version> Type Library).
' 3. Verify that the specified parts exist.
' 4. Verify that C:\test\ exists.
'
' Postconditions:
' 1. Creates the document comparison report, C:\test\Report\gtReportIndex.htm.
' 2. Gets document comparison statuses.
' 3. Examine C:\test\Report\gtReportIndex.htm.
'
' NOTE: Because the parts are used elsewhere, do not save changes.
'------------------------------------------------------------------------------
Option Explicit
Sub main()
    Dim swapp As SldWorks.SldWorksDim swUtil As SWUtilities.gtcocswUtilitiesDim swUtilCompdoc As SWUtilities.gtcocswCompareDocumentDim longStatus As LongDim bAddToBinder As BooleanDim bOverwrite As BooleanDim file1 As StringDim file2 As String
    ' Connect to SOLIDWORKSSet swapp = Application.SldWorks
   ' Get the SOLIDWORKS Utilities interfaceSet swUtil = swapp.GetAddInObject("Utilities.UtilitiesApp")
   ' Set the SOLIDWORKS Utilities tool to compare documentsSet swUtilCompdoc = swUtil.GetToolInterface(gtSwToolCompDocs, 0)
    ' Compare the volumes of the specified part documents; do not show the Results' dialog box, but do save the results to a file in the specified pathfile1 = "C:\Users\Public\Documents\SOLIDWORKS\SOLIDWORKS 2018\samples\tutorial\swutilities\bracket_a.sldprt"file2 = "C:\Users\Public\Documents\SOLIDWORKS\SOLIDWORKS 2018\samples\tutorial\swutilities\bracket_b.sldprt"bAddToBinder = FalsebOverwrite = TruelongStatus = swUtilCompdoc.CompareDocument2(file1, "", file2, "", gtCodVolumeCompare, gtResultSaveReport, "C:\test\Report", bAddToBinder, bOverwrite)
    ' Perform any necessary clean uplongStatus = swUtilCompdoc.Close()
End Sub

(3)第三个为SaveCompareVolumeResults,这个API的含义为比较完文档以后,将比较结果保存为solidworks部件文档,下面是官方的具体解释:

返回值和第一个API介绍的一致。

本篇文章要介绍的就是这些,我们下篇文章再见。


http://www.ppmy.cn/ops/5791.html

相关文章

攻防演练,作为蓝方,centos的服务器 怎么检查文件是不是被修改或者被拷贝

在基于CentOS的服务器上&#xff0c;作为蓝方进行攻防演练时&#xff0c;检查文件是否被修改或拷贝可以采用以下方法&#xff1a; 1. 安装并配置 Auditd 系统 Auditd 是 Linux 下的一个用来审计系统使用情况的工具&#xff0c;可以用来监控对文件的访问、修改和拷贝操作。 安…

动力学重构/微分方程参数拟合 - 基于模型

这一篇文章&#xff0c;主要是给非线性动力学&#xff0c;对微分方程模型参数拟合感兴趣的朋友写的。笼统的来说&#xff0c;这与混沌系统的预测有关&#xff1b;传统的机器学习的模式识别虽然也会谈论预测结果&#xff0c;但他们一般不会涉及连续的预测。这里我们考虑的是&…

VScode配置launch+tasks[自己备用]

VScode配置launchtasks[自己备用]&#xff0c;配置文件详解 launch.json 字段 name &#xff1a;启动配置的名称&#xff0c;也就是显示在调试配置下拉菜单中的名字&#xff0c;如果添加了多个配置可以用此作为区分 字段 program &#xff1a;可执行文件完整路径。 ① 由于 C…

js生成word

js生成word 下载依赖 npm install html-docx-js引入 import htmlDocx from html-docx-js/dist/html-docx;代码 //参数 html 文件名字 下载完执行回调函数 function html2word (html,fileName,callback){const converted htmlDocx.asBlob(html);const link document.cre…

设计模式学习笔记 - 开源实战一(上):通过剖析JDK源码学习灵活应用设计模式

工厂模式在 Calendar 类中的应用 在前面讲到工厂模式的时候&#xff0c;大部分工厂类都是以 Factory 作为后缀来命名&#xff0c;并且工厂类主要负责创建对象这样一件事情。但在实际的项目开发中&#xff0c;工厂类的设计更加灵活。我们来看下&#xff0c;工厂模式在 Java JDK…

Golang | Leetcode Golang题解之第29题两数相除

题目&#xff1a; 题解&#xff1a; func divide(dividend, divisor int) int {if dividend math.MinInt32 { // 考虑被除数为最小值的情况if divisor 1 {return math.MinInt32}if divisor -1 {return math.MaxInt32}}if divisor math.MinInt32 { // 考虑除数为最小值的情…

网站结构规范对于独立站的重要性

网站结构是指通过优化网站的内部结构和布局&#xff0c;以提高其在搜索引擎结果页面&#xff08;SERP&#xff09;中的排名和可见性的过程。 涉及到网站内部链接、导航菜单、网站url路径、网站地图等细节。 网站结构的优化可以更好地帮助搜索引擎了索引网站的内容&#xff0c…

HCIP-OSPF综合实验

一实验拓扑图 二.实验要求 1、R4为ISP&#xff0c;其上只配置IP地址&#xff1b;R4与其他所直连设备间均使用公有IP&#xff1b; 2、R3-R5、R6、R7为MGRE环境&#xff0c;R3为中心站点&#xff1b; 3、整个OSPF环境IP基于172.16.0.0/16划分&#xff1b;除了R12有两个环回&…