htmledit_views">
大家好,今天要讲的文章是关于如何比较两个solidworks文档。
下面是API的介绍:
(1)第一个为Close,这个API的含义为在比较solidworks文档以后执行必要的清理。下面是官方的具体解释:
其没有输入参数,返回值为定义的错误 gtError_e,其错误类型如下所示:
Member | Description |
---|---|
gtErrArgument1Incorrect | 11001 = Feature paint 11001 thorugh 12000 |
gtErrArgument2Incorrect | 11002 |
gtErrArgumentOutofRange | 22 |
gtErrAssemblyInEditPartMode | 26 |
gtErrBsdAlreadyOpen | Not used |
gtErrBsdDefaultDrwTemplate | Not used |
gtErrBsdDocNotSaved | Not used |
gtErrBsdInvalidArg | Not used |
gtErrBsdInvalidSaveLocationPath | Not used |
gtErrBsdInvalidSheetFormatPath | Not used |
gtErrBsdLowMemory | Not used |
gtErrBsdNoActivePartDoc | Not used |
gtErrBsdNoSheetMetalFeatureFound | Not used |
gtErrBsdNotInitialized | Not used |
gtErrBsdOpenedReadOnly | Not used |
gtErrBsdUserCanceled | Not used |
gtErrBsdVirtualComponent | Not used |
gtErrCompareFacesFailed | 7001 = Compare geometry 7001 through 8000 |
gtErrCompareFeaturesFailed | 6001 = Compare features 6001 through 7000 |
gtErrCompareGeometryNotExecuted | 7007 |
gtErrCompareVolFailed | 7002 |
gtErrCompareVolumeNotExecuted | 7013 |
gtErrCompDocsAlreadyOpen | 5001 = Compare documents 5001 through 6000 |
gtErrCompDocsInvalidModConfig | 5008 |
gtErrCompDocsInvalidModFile | 5006 |
gtErrCompDocsInvalidRefConfig | 5007 |
gtErrCompDocsInvalidRefFile | 5005 |
gtErrCompDocsNotExecuted | 5002 |
gtErrCompDocsOperationOptions | 5003 = Operation out of range |
gtErrCompDocsResultOptions | 5004 = Result option out of range |
gtErrCompDocsSameRefModFilesConfigs | 5009 |
gtErrCompFeatAlreadyRunning | 6004 |
gtErrCompFeatInvalidModConfig | 6010 |
gtErrCompFeatInvalidModFile | 6003 |
gtErrCompFeatInvalidRefConfig | 6009 |
gtErrCompFeatInvalidRefFile | 6002 |
gtErrCompFeatModNoSolidBodies | 6007 |
gtErrCompFeatNotExecuted | 6008 |
gtErrCompFeatRefNoSolidBodies | 6006 |
gtErrCompFeatResultOptions | 6005 |
gtErrCompFeatSameRefModFilesConfigs | 6011 |
gtErrCompGeomAlreadyOpen | 7008 |
gtErrCompGeomInvalidModConfig | 7015 |
gtErrCompGeomInvalidModFile | 7010 |
gtErrCompGeomInvalidRefConfig | 7014 |
gtErrCompGeomInvalidRefFile | 7009 |
gtErrCompGeomOperationOptions | 7011 |
gtErrCompGeomResultOptions | 7012 |
gtErrCompGeomSameRefModFilesConfigs | 7016 |
gtErrCouldNotCreateReportFolders | 14 |
gtErrDesignBinderReportAlreadyExists | 30 |
gtErrDoc1NotSelected | 33 |
gtErrDoc2NotSelected | 34 |
gtErrDocInEditSketchMode | 12 |
gtErrDocIsEmpty | 5 |
gtErrDocNotSelected | 2 |
gtErrDocOpenedViewOnly | 8 |
gtErrDocsAreSame | 4 |
gtErrDocsConfigNotExist | 29 |
gtErrDocsConfigsAreSame | 28 |
gtErrEdrawingFileAlreadyExists | 12018 |
gtErrFaceComparisonNotPossibleInAssemblies | 27 |
gtErrFacesIdentical | 7003 |
gtErrFileAlreadyExists | 20 |
gtErrFileNotFound | 18 |
gtErrFindText | 12019 = Property IFindReplaceAnnotations::FindText is not set |
gtErrGckAlreadyOpen | 8001 = Geometry analysis 8001 through 9000 |
gtErrGckDRTError | 8003 |
gtErrGckInsufficientMemoryProvided | 8006 |
gtErrGckInvalidEntityParamater | 8008 |
gtErrGckNoActivePartDoc | 8002 |
gtErrGckNoGetCountFunctionCalled | 8005 |
gtErrGckNotInitialized | 8007 |
gtErrGckResultsAlreadyPresent | 8004 |
gtErrIncompatibleFile | 6 |
gtErrIncorrectFileName | 3 |
gtErrIncorrectReportPath | 15 |
gtErrInvalidFile | 17 |
gtErrNonSimilarParts | 7004 |
gtErrNoPartDocs | 25 |
gtErrNoSolidBodies | 19 |
gtErrNoSourceFeature | 11003 |
gtErrNoTargetFeature | 11004 |
gtErrNoUI | 12022 |
gtErrNoValidIndex | 12023 |
gtErrOpeningFile | 1 |
gtErrPslAlreadyRunning | 10014 |
gtErrPslAngleOutofRange | 10006 |
gtErrPslBothConvexConcaveNotSet | 10004 |
gtErrPslColorOutofRange | 10007 |
gtErrPslErrFilterTypeOutofRange | 10010 |
gtErrPslErrOperatorOutofRange | 10005 |
gtErrPslErrorInSelection | 10017 |
gtErrPslFeatureTypeOutofRange | 10008 |
gtErrPslIncorrectFeatureNameString | 10009 |
gtErrPslIncorrectFeatureTypeArray | 10018 |
gtErrPslNoActivePartDoc | 10016 |
gtErrPslNoFeatureTypeFilterSet | 10011 |
gtErrPslNoFilterSet | 10002 |
gtErrPslNoSelectEntitySet | 10001 = PowerSelect 10001 through 10019 |
gtErrPslNotInitialized | 10015 |
gtErrPslNotRun | 10013 |
gtErrPslResultOptions | 10019 |
gtErrPslSpecifiedFilterNotSet | 10003 |
gtErrPslUIRunning | 10012 |
gtErrReferenceBOMNotSelected | 31 |
gtErrReplaceText | 12020 = Property IFindReplaceAnnotations::ReplaceText is not set |
gtErrReportAlreadyExists | 13 |
gtErrResultUIOn | 23 |
gtErrRollback | 11008 |
gtErrSameNameDocAlreadyOpen | 7 |
gtErrSameSourceTargetFeature | 11005 |
gtErrSavingFile | 16 |
gtErrSavingVolDiffResults | 7005 |
gtErrSharedByCompDocs | 11 |
gtErrSharedByFeatDiff | 10 |
gtErrSharedByGeomDiff | 9 |
gtErrSourceFeatErr | 11006 |
gtErrSourceFeatureRolledBack | 11009 |
gtErrSourceNoBodyFeature | 11011 |
gtErrTargetFeatErr | 11007 |
gtErrTargetFeatureRolledBack | 11010 |
gtErrTargetNoBodyFeature | 11012 |
gtErrtckBodyDoesNotExist | 12005 |
gtErrtckBodyNotSet | 12006 |
gtErrtckNoActivePartDoc | 12001 = Thickness analysis 12001 through 13000 |
gtErrTckNotInitialized | 12004 |
gtErrTckNotPerformed | 12015 |
gtErrTckNotValid | 12016 |
gtErrTckResolution | 12003 |
gtErrTckResultOptions | 12002 |
gtErrtckTesselationFailed | 12008 |
gtErrTcktThickRegnLimitNotInRange | 12014 |
gtErrTcktTrgThicknessNotInRange | 12013 |
gtErrtckUIRunning | 12007 |
gtErrThicknessRangeNotValid | 12017 |
gtErrToBeComparedBOMNotSelected | 32 |
gtErrToolNotSupported | 21 = Returned by IUtilities::GetToolInterface |
gtErrUIInvoked | 12021 = PropertyManager page is already displayed |
gtErrUtilityAlreadyRunning | 24 |
gtErrVolDiffResultsAlreadySaved | 7006 |
gtNOErr | 0 = No error |
gtUnknownErr | -1 = Common -1 through 5000 |
gtWarningTckThickAnalRangeAboveMaxThick | 12011 |
gtWarningTckThickAnalRangeBelowMaxThick | 12012 |
gtWarningTckThinAnalMinMaxThckSameAsTrg | 12010 |
gtWarningTckThinAnalRangeBelowMaxThick | 12009 |
(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介绍的一致。
本篇文章要介绍的就是这些,我们下篇文章再见。