标题: 跪求SOLEDWORKS转DWG的宏文件 [打印本页] 作者: huchangxing 时间: 2009-11-25 22:46 标题: 跪求SOLEDWORKS转DWG的宏文件 我复制的宏代码运行错误!!!跪求个SOLEDWORKS转DWG的宏文件,
错误的地方在下面红色地方,所以我求个SOLEDWORKS转DWG的宏文件,不要代码了,呵呵。有的传个给我,谢谢!
Dim swApp As Object
Dim Part As Object
Dim Filename As String
Dim No As Integer
Dim Title As String
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Filename = Part.GetPathName()
No = Len(Filename)
Filename = Left(Filename, No - 7)
Part.SaveAs2 Filename & ".DWG", 0, True, False
Title = Part.GetTitle
Set Part = Nothing
swApp.CloseDoc Title
X = MsgBox(" 已保存为 DWG 文件 ", 0)
End Sub
红色的地方在SW中错误,????作者: huchangxing 时间: 2009-11-25 23:22
我是在SW2010中调用的这段宏,大伙传个有用的上来,不要上传个跟这个一样的,拜托了,谢谢!作者: huchangxing 时间: 2009-11-26 08:29
这个坛子里面有没有研究宏的吗?怎么没有来帮我看看啊作者: huchangxing 时间: 2009-11-26 12:04
好了,我已经解决了这个问题,原来要先保存工程图,才可以调用这个宏的呀。
看来宏命令有点难度的哦作者: huchangxing 时间: 2009-11-26 12:05
请高手帮忙下,我现在不想保存工程图,而是直接保存为DWG文件,应该怎么样修改这段宏命令呀。作者: 寻路人 时间: 2009-11-28 18:34
Dim swApp As Object
Dim Part As Object
Dim Filename As String
Dim No As Integer
Dim Title As String
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Part.SaveAs2 "C:\Documents and Settings\Administrator\桌面\工程图1" & ".DWG", 0, True, False
Title = Part.GetTitle
Set Part = Nothing
swApp.CloseDoc Title
MsgBox " 已保存为 DWG 文件 ", 0
End Sub作者: 寻路人 时间: 2009-11-28 18:37
Dim swApp As Object
Dim Part As Object
Dim Filename As String
Dim No As Integer
Dim Title As String
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Filename = Part.GetPathName() 你这行获得的事全文件保存的全路径
No = Len(Filename) 这里你计算全路径的字符没有意义
Filename = Left(Filename, No - 7) no-7 更是不能达到你想要的文件名
Part.SaveAs2 Filename & ".DWG", 0, True, False 保存需要有全路径,而不是文件名
Title = Part.GetTitle
Set Part = Nothing
swApp.CloseDoc Title
X = MsgBox(" 已保存为 DWG 文件 ", 0)
End Sub