自定义特性Solidworks VBA宏的显示值
我想创建一个宏,将图形导出为PDF格式,格式为:图形名称+标题+日期 我创建了一个宏,当我为自定义特性Solidworks VBA宏的显示值,vba,solidworks,Vba,Solidworks,我想创建一个宏,将图形导出为PDF格式,格式为:图形名称+标题+日期 我创建了一个宏,当我为title输入一个值时,该宏的功能完全符合我的要求。但是在这个项目中,我希望标题与零件名称相等。因此,我将此代码用于标题值: $PRPSHEET:“软件文件名(文件名)” 图纸显示的标题非常好。但是,宏不起作用。我的宏它不会将此代码转换为零件名称。我不明白为什么。有什么建议吗 我就是这样得到这个头衔的: Dim swCustProp As CustomPropertyManager Function F
title
输入一个值时,该宏的功能完全符合我的要求。但是在这个项目中,我希望标题
与零件名称相等。因此,我将此代码用于标题
值:
$PRPSHEET:“软件文件名(文件名)”
图纸显示的标题
非常好。但是,宏不起作用。我的宏它不会将此代码转换为零件名称。我不明白为什么。有什么建议吗
我就是这样得到这个头衔的:
Dim swCustProp As CustomPropertyManager
Function FormatFileLocation() As String
Dim Title As String
Dim bool As Boolean
Dim val As String
bool = swCustProp.Get4("title", True, val, Title) 'title is the name of the
'property and has the value: $PRPSHEET:"SW-File Name(File Name)"
end function
编辑:
我尝试同时使用
Title
和val
,但都给出了相同的错误结果。如果您使用的是SOLIDWORKS 2014或更高版本,则应使用swCustProp.Get5()。Get4()已过时
这个代码对我有用:
Dim swApp As Object
Dim swCustProp As CustomPropertyManager
Dim mde As ModelDocExtension
Dim swModel As ModelDoc2
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set mde = swModel.Extension
Set swCustProp = mde.CustomPropertyManager("")
Call FormatFileLocation
End Sub
Function FormatFileLocation()
Dim Title As String
Dim bool As Boolean
Dim val As String
Dim resolved As Boolean
bool = swCustProp.Get5("title", True, val, Title, resolved) 'title is the name of the
'property and has the value: $PRPSHEET:"SW-File Name(File Name)"
End Function
以下是我的图形自定义特性:
如果您使用的是SOLIDWORKS 2014或更高版本,则应使用swCustProp.Get5()。Get4()已过时 这个代码对我有用:
Dim swApp As Object
Dim swCustProp As CustomPropertyManager
Dim mde As ModelDocExtension
Dim swModel As ModelDoc2
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set mde = swModel.Extension
Set swCustProp = mde.CustomPropertyManager("")
Call FormatFileLocation
End Sub
Function FormatFileLocation()
Dim Title As String
Dim bool As Boolean
Dim val As String
Dim resolved As Boolean
bool = swCustProp.Get5("title", True, val, Title, resolved) 'title is the name of the
'property and has the value: $PRPSHEET:"SW-File Name(File Name)"
End Function
以下是我的图形自定义特性:
而不是从自定义属性中读取。可以从激活的工程视图中读取它
Dim swApp As Object
Dim swModel As ModelDoc2
Dim swDraw As DrawingDoc
Sub main()
Set swApp = Application.SldWorks
Set swDraw = swApp.ActiveDoc
Call FormatFileLocation
End Sub
Function FormatFileLocation()
Dim Title As String
Dim v As View
Set v = swDraw.ActiveDrawingView
Set swModel = v.ReferencedDocument
Title = swModel.GetTitle()
End Function
而不是从自定义属性中读取。可以从激活的工程视图中读取它
Dim swApp As Object
Dim swModel As ModelDoc2
Dim swDraw As DrawingDoc
Sub main()
Set swApp = Application.SldWorks
Set swDraw = swApp.ActiveDoc
Call FormatFileLocation
End Sub
Function FormatFileLocation()
Dim Title As String
Dim v As View
Set v = swDraw.ActiveDrawingView
Set swModel = v.ReferencedDocument
Title = swModel.GetTitle()
End Function
请将此字符串添加为值
$PRPSHEET:“SW文件名(文件名)”
您将无法获取链接到此属性的批注上显示的值。。。这正是问题所在。@2pietjuh2是否在“自定义属性求值”列中求值?这不适合我。这与您可以在图形中引用多个零件或部件有关,因此,如果图形中有多个零件或部件,它如何知道使用哪个文件名?请将此字符串添加为value$PRPSHEET:“SW文件名(文件名)”
您将无法获取链接到此属性的批注上显示的值。。。这正是问题所在。@2pietjuh2是否在“自定义属性求值”列中求值?这不适合我。这与可以在图形中引用多个零件或部件有关,因此,如果图形中有多个零件或部件,它如何知道使用哪个文件名?