|
经典图书 在输入SW档案路径下,批量开启零件及组件档,并写入" 模型组态指定 "之属性
是他网的练习做参考(简体版 "配置特定",繁体版 "模型组态指定")
OpenFile_Configuration.rar
(11.62 KB, 下载次数: 144)
SWP档2015/12/4 13:55更新
'
' 在某文件路径下批量开零件及装配件并写入配置特定
' 开 SW 软件,执行 main 主程式
' sc liang 2015/12/3
' 测试版 2012 sp4
'
'定义变数型态
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc
Dim boolstatus As Boolean
Dim Part As Object
Dim sFileName As String
Dim path As String
Dim Type_ As String
Dim nErrors As Long
Dim nWarnings As Long
Dim S1 As Integer
Dim S2 As Integer
Dim Path_Name As String
Dim Code_Name_C As String
Dim Code_ As String
Dim Name_ As String
Dim strmat As String
Dim strmas As String
Dim swModelDoc As SldWorks.ModelDoc2
Dim swConfig As SldWorks.Configuration
Dim CustPropMgr As SldWorks.CustomPropertyManager
'~~~ 主程式 ~~~
Sub Main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
path = InputBox("Enter a folder path containing any Solidworks files (For example '' C:\test\ '' )", "Parts path location") '键入存档路径
sFileName = Dir(path & "*.sld*") '取出SW档
'循环开档
Do Until sFileName = ""
Type_ = Right(sFileName, 3) '取得SW文件扩展名后三位
Select Case Type_ '判定SW文件型式
'开零件档
Case "PRT"
Set swModel = swApp.OpenDoc6(path + sFileName, swDocPART, swOpenDocOptions_Silent, "", nErrors, nWarnings)
Call Configuration_ '唿叫副程式
'开组件档
Case "ASM"
Set swModel = swApp.OpenDoc6(path + sFileName, swDocASSEMBLY, swOpenDocOptions_Silent, "", nErrors, nWarnings)
Call Configuration_ '唿叫副程式
End Select
复制代码 |
|