我是做机械设计的,用的软件是SOLIDWORKS,比如我的文件名是: M20125-外壳-20240125
我需要将文件名分成三部分,
代号:M20215
名称:外壳
版本号:20240125
下面是网上找的一些类似的程序,求好人看下,添几句代码
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
Dim a As Integer
Dim b As String
Dim m As String
Dim e As String
Dim k As String
Dim t As String
Dim c As String
Dim j As Integer
Dim strmat As String
Dim tempvalue As String
Sub main()
'link solidworks
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Set SelMgr = Part.SelectionManager
swApp.ActiveDoc.ActiveView.FrameState = 1
'设定变量
c = swApp.ActiveDoc.GetTitle() '零件名
strmat = Chr(34) + Trim("SW-Material" + "@") + c + Chr(34) /这里看下是否需要更改
blnretval = Part.DeleteCustomInfo2("", "代号")
blnretval = Part.DeleteCustomInfo2("", "名称")
blnretval = Part.DeleteCustomInfo2("", "版本号")
a = Split(c, "_") '重点:分隔标识符,这里是一个空格,
If a > 0 Then
补充这一段,
End If
blnretval = Part.AddCustomInfo3("", "代号", swCustomInfoText, k) '代号
blnretval = Part.AddCustomInfo3("", "名称", swCustomInfoText, m) '名称
blnretval = Part.AddCustomInfo3("", "名称", swCustomInfoText, t) '版本号
End Sub
我需要将文件名分成三部分,
代号:M20215
名称:外壳
版本号:20240125
下面是网上找的一些类似的程序,求好人看下,添几句代码
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
Dim a As Integer
Dim b As String
Dim m As String
Dim e As String
Dim k As String
Dim t As String
Dim c As String
Dim j As Integer
Dim strmat As String
Dim tempvalue As String
Sub main()
'link solidworks
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Set SelMgr = Part.SelectionManager
swApp.ActiveDoc.ActiveView.FrameState = 1
'设定变量
c = swApp.ActiveDoc.GetTitle() '零件名
strmat = Chr(34) + Trim("SW-Material" + "@") + c + Chr(34) /这里看下是否需要更改
blnretval = Part.DeleteCustomInfo2("", "代号")
blnretval = Part.DeleteCustomInfo2("", "名称")
blnretval = Part.DeleteCustomInfo2("", "版本号")
a = Split(c, "_") '重点:分隔标识符,这里是一个空格,
If a > 0 Then
补充这一段,
End If
blnretval = Part.AddCustomInfo3("", "代号", swCustomInfoText, k) '代号
blnretval = Part.AddCustomInfo3("", "名称", swCustomInfoText, m) '名称
blnretval = Part.AddCustomInfo3("", "名称", swCustomInfoText, t) '版本号
End Sub