Adding Custom Properties
Adding Custom Properties
(OP)
I need to Add and Modify custom properties in Solidworks. I am new to Solidworks, but experienced with VB and VBA. Can anyone point me in the correct direction?
When was the last time you drove down the highway without seeing a commercial truck hauling goods?
Download nowINTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS Come Join Us!Are you an
Engineering professional? Join Eng-Tips Forums!
*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail. Posting GuidelinesJobs |
|
RE: Adding Custom Properties
Option Explicit
Const swCustomInfoText = 30
Const swCustomInfoNumber = 3
Sub CodeSamples()
Dim swApp As Object
Dim Part As Object
Dim sConfig As String
Dim s1 As String, s2 As String
Set swApp = GetObject(, "SldWorks.Application")
Set Part = swApp.ActiveDoc
'Define the Configuration
' -Use the name of the config if not default
' -You can get a list of all configs using:
' Part.GetConfigurationCount
' Part.GetConfigurationNames
sConfig = "" 'Default Config
'Get Current Value of Property
s1 = Part.CustomInfo2(sConfig, "RevNo")
If Len(s1) = 0 Then
MsgBox "RevNo is Not Set or Not Defined"
Else
MsgBox "RevNo: " & s1
End If
'Store the Custom Property
' AddCustomInfo3 returns True if Added
' if False, the property already exists
' In that case, just update the value
s2 = "2" 'Define RevNo
If Part.AddCustomInfo3(sConfig, "RevNo", swCustomInfoText, s2) = False Then
Part.CustomInfo2(sConfig, "RevNo") = s2
End If
Set Part = Nothing
Set swApp = Nothing
End Sub
Hope this helps...
DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
RE: Adding Custom Properties
Setting sConfig = "" in the above code will set the Custom Properties, not the Configuration Specific Properties. You'll note that there are two separate tabs on the File>Properties menu. If properties are defined in both windows, the Configuration Specific will be used.
DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
RE: Adding Custom Properties