一区二区三区日韩精品-日韩经典一区二区三区-五月激情综合丁香婷婷-欧美精品中文字幕专区

分享

API 批量修改solidwork屬性

 jimmyhuang00 2010-05-20

'定義solidwork
Dim swApp As Object
Dim Part As Object
Dim SelMgr As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
 

Dim Feature As Object
'定義excel
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
 
Dim a As String
Dim b As String
Dim m As String
Dim e As String
Dim c As String
Dim j As Integer
Dim t As Integer
Dim f As String
Dim g As String
Dim h As String
Dim i As Integer
Dim k As Integer
Dim p As Integer
 
 
 
Sub main()
 
On Error GoTo aa
 

'link solidworks
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Set SelMgr = Part.SelectionManager
swApp.ActiveDoc.ActiveView.FrameState = 1
 
'設(shè)定零件地址
f = "D:\"
 

'link excel
Set oExcel = Excel.Application
oExcel.Visible = False
Set oWB = oExcel.Workbooks.Open("f:\***.xls")   'excel表格位置
Set oWS = oWB.Worksheets(1)
 

'設(shè)置在excel中的查找代碼,查找各個屬性
j = 2
 
Do Until Sheets(1).Cells(j, 2) = ""
 
h = Sheets(1).Cells(j, 2)
 
i = 1
Do Until Mid(h, i, 1) = "."
i = i + 1
Loop
i = i + 1
 
b = Mid(h, i, 6)
 
Select Case b
Case Is = "SLDPRT"
k = 1
Case Is = "SLDASM"
k = 2
End Select
 

'生成零件具體位置
g = f & h ' & ".SLDPRT"
 

Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Set SelMgr = Part.SelectionManager
swApp.ActiveDoc.ActiveView.FrameState = 1
'打開零件
'Part.OpenCompFile
Set Part = swApp.OpenDoc6(g, k, 0, "", longstatus, longwarnings)
 
'記錄零件名稱
h = Sheets(1).Cells(j, 2)
 

'經(jīng)excel賦值
a = Sheets(1).Cells(j, 3) 'Description
'm = Sheets(1).Cells(j, 4)
'e = Sheets(1).Cells(j, 3)
 
'編輯零件
 
'清空solidwork舊的屬性
 
blnretval = Part.DeleteCustomInfo2("", "物料編碼")
'blnretval = Part.DeleteCustomInfo2("", "坯料尺寸")
 

'加入新的solidwork屬性
 
blnretval = Part.AddCustomInfo3("", "Material", swCustomInfoText, a)
'blnretval = Part.AddCustomInfo3("", "坯料尺寸", swCustomInfoText, m)
 

'關(guān)閉編輯完的零件
Set Part = swApp.ActivateDoc2(g, False, longstatus)
Part.Save2 True
Part.ClearSelection2 True
Set Part = Nothing
swApp.CloseDoc g
 
'顯示當(dāng)前文件
Set Part = swApp.ActivateDoc2("****.SLDPRT", False, longstatus)
 

aa:
j = j + 1
 
Loop
 

'關(guān)閉excel
oExcel.DisplayAlerts = False
oWB.Close
oExcel.Quit
Set oWS = Nothing
Set oWB = Nothing
Set oExcel = Nothing
 

strErrMsg = "SetCustomProps Sub Routine" & strErrMsg
End Sub

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多

    国产一区二区三区免费福利| 亚洲妇女作爱一区二区三区| 亚洲天堂精品在线视频| 最近中文字幕高清中文字幕无| 欧美欧美日韩综合一区| 久久亚洲精品中文字幕| 欧美成人高清在线播放| 在线观看视频日韩成人| 东京干男人都知道的天堂| 黄色国产自拍在线观看| 激情爱爱一区二区三区| 国产欧美亚洲精品自拍| 丁香七月啪啪激情综合| 精品欧美日韩一区二区三区| 日韩精品亚洲精品国产精品| 欧美日韩在线第一页日韩| 日韩高清中文字幕亚洲| 国产免费一区二区三区不卡| 亚洲综合日韩精品欧美综合区| 亚洲精品福利入口在线| 在线观看欧美视频一区| 狠狠干狠狠操在线播放| 91亚洲国产—区=区a| 91欧美日韩中在线视频| 欧洲精品一区二区三区四区| 中文字幕高清免费日韩视频| 日本午夜乱色视频在线观看| 福利视频一区二区三区| 亚洲夫妻性生活免费视频| 天堂网中文字幕在线观看| 国内精品伊人久久久av高清 | 国产国产精品精品在线| 亚洲一区二区三区福利视频| 日本高清一区免费不卡| 欧美整片精品日韩综合| 男女激情视频在线免费观看| 亚洲欧美日韩网友自拍| 九九热精彩视频在线播放| 国产毛片不卡视频在线| 日本加勒比中文在线观看| 国产伦精品一区二区三区精品视频|