找回密码 注册 QQ登录
开思网工业级高精度在线3D打印服务

iCAx开思网

CAD/CAM/CAE/设计/模具 高清视频【积分说明】如何快速获得积分?快速3D打印 手板模型CNC加工服务在线3D打印服务,上传模型,自动报价
查看: 5181|回复: 4
打印 上一主题 下一主题

[求助] 钣金另存为DWG,文件名增加自定义属性

[复制链接]
跳转到指定楼层
1
发表于 2016-9-27 11:13:36 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多同行朋友,交流,分享,学习。

您需要 登录 才可以下载或查看,没有帐号?注册

x
  1. <span style="line-height: 1.5;">Dim swApp As Object</span>
复制代码
根据论坛上其它大大代码更改,实现导出平板形式文件名增加图号,如还想增加其他自定义属性如材质、料厚等,如何修改代码。
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏1 分享淘帖 赞一下!赞一下!
2
发表于 2016-9-27 11:14:56 | 只看该作者
[code]Dim swApp As Object
Dim Part As Object
Dim longstatus As Long
Dim swModel As Object
Dim swModelDocExt As ModelDocExtension
Dim swCustProp As CustomPropertyManager
Dim val As String
Dim valout As String
Dim swModelName As String
Dim FilePath As String
Dim value As Boolean
Dim sheet_name        As String
Dim boolstatus          As Boolean
Dim swDrawingDoc As SldWorks.DrawingDoc
Dim swSheet As SldWorks.Sheet

Sub main()


Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
On Error Resume Next

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

' 取出零件屬性物料編號之值~~~~~~~~~~
    Dim Path_N As String
    Dim X_Path_Name As String
    Set swSheet = swModel.GetCurrentSheet
    Set swModel = swApp.GetFirstDocument
Path_Name = swModel.GetPathName  '目前零件檔案的路徑及名稱.SLPRT
Set swModelDocExt = swModel.Extension ' Get the custom property data
Set swCustProp = swModelDocExt.CustomPropertyManager("")
bool = swCustProp.Get4("图号", False, val, valout) 'val:图号值

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
swModelName = swModel.GetPathName      '读取当前SW模型文档名(含路径)
FilePath = Left(swModelName, Len(swModelName) - 7) + val + "展开图.dwg" '定义工程图名
'value = swModel.ExportFlatPatternView(FilePath, swExportFlatPatternOption_None)  保留折弯线
value = swModel.ExportFlatPatternView(FilePath, swExportFlatPatternOption_RemoveBends)     '无折弯线
End Sub


重发代码
3
发表于 2016-9-30 11:07:15 | 只看该作者
MARK~~
4
发表于 2020-3-26 14:26:58 | 只看该作者
请问这个问题是否解决了?
命名格式最好能达到的效果:文件名-材料-板厚-单台用量.dwg





Dim swApp As Object
Dim Part As Object
Dim longstatus As Long
Dim swModel As Object
Dim swModelDocExt As ModelDocExtension
Dim swCustProp As CustomPropertyManager
Dim val As String
Dim valout As String
Dim swModelName As String
Dim FilePath As String
Dim value As Boolean
Dim sheet_name        As String
Dim boolstatus          As Boolean
Dim swDrawingDoc As SldWorks.DrawingDoc
Dim swSheet As SldWorks.Sheet

Sub main()


Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
On Error Resume Next

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

' 取出零件屬性物料編號之值~~~~~~~~~~
    Dim Path_N As String
    Dim X_Path_Name As String
    Set swSheet = swModel.GetCurrentSheet
    Set swModel = swApp.GetFirstDocument
Path_Name = swModel.GetPathName  '目前零件檔案的路徑及名稱.SLPRT
Set swModelDocExt = swModel.Extension ' Get the custom property data
Set swCustProp = swModelDocExt.CustomPropertyManager("")
bool = swCustProp.Get4("代号", False, val, valout) 'val:图号值

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
swModelName = swModel.GetPathName      '读取当前SW模型文档名(含路径)
FilePath = Left(swModelName, Len(swModelName) - 7) + val + "展开图.dwg" '定义工程图名
'value = swModel.ExportFlatPatternView(FilePath, swExportFlatPatternOption_None)  保留折弯线
value = swModel.ExportFlatPatternView(FilePath, swExportFlatPatternOption_RemoveBends)     '无折弯线
End Sub




1 上面坛友的代码这个语句bool = swCustProp.Get4("代号", False, val, valout) 'val:图号值。。。读取的是零件自定义属性第三列 数值/文字表达式栏的值(只能是数值,如果是表达式这里就读不出来),并非第四列里 评估的值
请教各位,如何改写能实现读取  评估的值
2 文件命名语句 FilePath = Left(swModelName, Len(swModelName) - 7) + val + "展开图.dwg" '定义工程图名
是否能实现   新文件名 = 文件名-材料-板厚-单台用量.dwg

5
发表于 2021-11-12 01:28:42 | 只看该作者
Debugg 发表于 2016-9-27 11:14
[code]Dim swApp As Object
Dim Part As Object
Dim longstatus As Long

请问下大哥,把图号改成材质要怎么修改,可以生成 板厚+材质+文件名 吗,是只能文件名在最前面吗,小白不会改啊
您需要登录后才可以回帖 登录 | 注册

本版积分规则

3D打印手板模型快速制作服务,在线报价下单!

QQ 咨询|手机版|联系我们|iCAx开思网  

GMT+8, 2024-12-22 09:31 , Processed in 0.024037 second(s), 12 queries , Gzip On, Redis On.

Powered by Discuz! X3.3

© 2002-2024 www.iCAx.org

快速回复 返回顶部 返回列表