cool44
发表于 2022-6-4 11:57:32
我用的是自己写的宏,一个在sw里用,可以单个文件改名。另一个宏是配合excel用,可以批量改名。
阿帕奇2022
发表于 2022-6-4 22:01:57
笑对人生123 发表于 2021-9-13 23:33
以前用这个宏超级快,可以节约很多时间
大神,能分享一下这个宏吗。。。感谢!~!
youjinlong64
发表于 2022-9-12 14:42:17
咋用宏命令改名后工程图还能链接上?
八哥BJ
发表于 2022-9-12 17:14:42
凯元可以
zou272294738
发表于 2023-1-19 15:02:49
醉生梦 发表于 2021-9-13 15:18
这个是在“常跓宏”的基础上改的,有改名动作时,检测文件同文件夹下是否有同名的工种图文件,如果有,更改 ...
您好,请问能分享一下您这个宏吗?谢谢
阿帕奇2022
发表于 2023-6-12 16:31:38
醉生梦 发表于 2021-9-13 15:18
这个是在“常跓宏”的基础上改的,有改名动作时,检测文件同文件夹下是否有同名的工种图文件,如果有,更改 ...
能分享一下吗?
阿帕奇2022
发表于 2023-7-27 08:02:52
醉生梦 发表于 2021-9-13 15:18
这个是在“常跓宏”的基础上改的,有改名动作时,检测文件同文件夹下是否有同名的工种图文件,如果有,更改 ...
求分享!!!
非资深但不高级
发表于 2023-7-27 11:45:56
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASQAAACpCAYAAACCoEBeAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAABQtSURBVHhe7Z1dbB7FesfHNo4Th8QOxPkgCQSdhDQFGhUpARHgptEpEqhtQEWHAzdVJW4KqEgcCRQd6Ui9IKhIVIBaFannplAkKkC9QKQlNwXxFQQVkBwShQOGfJ0QB5uQmMSxk/Kb7OOMx/u+fr3v17z2/yeNdnd2dnd23n3++zyzu/O2nTp16rwTQogEaM+mQgjRdCRIQohkkCAJIZJBgiSESAYJkhAiGSRIQohkkCAJIZKh6e8hDQ8PuxMnTrixsbEsp/l0dHS4hQsXuu7u7ixHCNEImu4hpSZGQH2olxCisTRdkFITIyPVegkxk1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AiGSRIQohkkCAJIZJBgiSESAYJkhAiGSRIQohkkCAJIZJBgiSESATn/h+uNoGD+oJ7EAAAAABJRU5ErkJggg==我想分享一下,但是上传不了怎么办.....
FKUEDEJXSQ2
发表于 2023-8-10 16:09:31
宏文件
steve_suich
发表于 2023-8-10 16:20:47
Dim swApp As Object
Dim swAssy As SldWorks.AssemblyDoc
Dim swAssyEvents As Class1
Dim swprt As SldWorks.PartDoc
Dim swprtEvents As Class2
Sub main()
Set swApp = Application.SldWorks
Set prt = swApp.GetFirstDocument
If Not prt Is Nothing Then
Set prt = swApp.ActiveDoc
If prt.GetType = 2 Then
Set swAssy = prt
Set swAssyEvents = New Class1
Set swAssyEvents.swAssy = swApp.ActiveDoc
ElseIf prt.GetType = 1 Then
Set swprt = prt
Set swprtEvents = New Class2
Set swprtEvents.swprt = swApp.ActiveDoc
End If
End If
End Sub
//////////////////////////////////
Class1
//////////////////////////////////
Public WithEvents swAssy As SldWorks.AssemblyDoc
Public Function swAssy_RenameItemNotify(ByVal entType As Long, ByVal oldName As String, ByVal NewName As String) As Long
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
If InStrRev(oldName, "\") <> 0 Then
Path = Left(oldName, InStrRev(oldName, "\"))
nfi = Left(NewName, InStrRev(NewName, ".") - 1)
tmpfi = Dir(Path & "*.SLDDRW")
Do Until tmpfi = ""
vDepend = swApp.GetDocumentDependencies(Path & tmpfi, False, False)
If Mid(vDepend(1), InStrRev(vDepend(1), "\") + 1) = Right(oldName, Len(oldName) - InStrRev(oldName, "\")) Then
Name Path & tmpfi As nfi & ".SLDDRW"
bl = swApp.ReplaceReferencedDocument(nfi & ".SLDDRW", vDepend(1), NewName)
Exit Do
End If
tmpfi = Dir
Loop
Part.Save
Else
Set swSelMgr = Part.SelectionManager
Set swComp = swSelMgr.GetSelectedObject(1)
mip = swComp.GetPathName
oldn = Left(oldName, InStrRev(oldName, "-") - 1)
Path = Left(mip, InStrRev(mip, "\"))
ntype = Mid(mip, InStrRev(mip, "."))
If mip <> "" Then
tmpfi = Dir(Path & "*.SLDDRW")
Do Until tmpfi = ""
vDepend = swApp.GetDocumentDependencies(Path & tmpfi, False, False)
If Mid(vDepend(1), InStrRev(vDepend(1), "\") + 1) = (oldn & ntype) Then
Name Path & tmpfi As Left(mip, InStrRev(mip, ".") - 1) & ".SLDDRW"
bln = swApp.ReplaceReferencedDocument(Left(mip, InStrRev(mip, ".") - 1) & ".SLDDRW", vDepend(1), mip)
Exit Do
End If
tmpfi = Dir
Loop
End If
End If
Set Part = Nothing
End Function
//////////////////////////////////
Class2
//////////////////////////////////
Public WithEvents swprt As SldWorks.PartDoc
Public Function swprt_RenameItemNotify(ByVal entType As Long, ByVal oldName As String, ByVal NewName As String) As Long
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Path = Left(oldName, InStrRev(oldName, "\"))
nfi = Left(NewName, InStrRev(NewName, ".") - 1)
tmpfi = Dir(Path & "*.SLDDRW")
Do Until tmpfi = ""
vDepend = swApp.GetDocumentDependencies(Path & tmpfi, False, False)
If Mid(vDepend(1), InStrRev(vDepend(1), "\") + 1) = Right(oldName, Len(oldName) - InStrRev(oldName, "\")) Then
Name Path & tmpfi As nfi & ".SLDDRW"
bl = swApp.ReplaceReferencedDocument(nfi & ".SLDDRW", vDepend(1), NewName)
Exit Do
End If
tmpfi = Dir
Loop
Part.Save
End Function