searching for a configuration specific custom properties in SolidWorks
searching for a configuration specific custom properties in SolidWorks
(OP)
Good day everyone..
Is it possible to search for a configuration specific custom property in SolidWorks 2007?
We did some tests using SolidWorks Explorer 2007 to search for a configuration specific custom property, but it did not work. It was able to search for "regular" custom properties, but not configuration specific custom properties. Is this is a limitation?
If this is a limitation, has anyone found a work around ? For example a possible work around would be to be able to search inside a Design table for the Configuration Specific Custom Property (e.g. $prp@description).
Best regards,
Joseph
Is it possible to search for a configuration specific custom property in SolidWorks 2007?
We did some tests using SolidWorks Explorer 2007 to search for a configuration specific custom property, but it did not work. It was able to search for "regular" custom properties, but not configuration specific custom properties. Is this is a limitation?
If this is a limitation, has anyone found a work around ? For example a possible work around would be to be able to search inside a Design table for the Configuration Specific Custom Property (e.g. $prp@description).
Best regards,
Joseph






RE: searching for a configuration specific custom properties in SolidWorks
Just heard back from the reseller, and this is a limitation.
If anyone knows a good work around, please let us know.
Have a great day,
Joseph
RE: searching for a configuration specific custom properties in SolidWorks
You can use a macro to list the custom properties for a configuration. File custom information is stored in the document file. It can be:
General to the file, in which case there is a single value whatever the model's configuration
- or -
Configuration-specific, in which case a different value may be set for each configuration in the model
This is documented in Solidworks Help under Help/Solidworks and Add-Ins API Help Topics.
Here's an example from the Help file:
CODE
LIST CUSTOM PROPERTIES EXAMPLE (VB)
'-------------------------------------
'
' Preconditions: SolidWorks document is open to which custom properties have been assigned.
'
' Postconditions: None
'-------------------------------------
Option Explicit
Public Enum swCustomInfoType_e
swCustomInfoUnknown = 0
swCustomInfoText = 30 ' VT_LPSTR
swCustomInfoDate = 64 ' VT_FILETIME
swCustomInfoNumber = 3 ' VT_I4
swCustomInfoYesOrNo = 11 ' VT_BOOL
End Enum
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim vConfigNameArr As Variant
Dim vConfigName As Variant
Dim vCustInfoNameArr As Variant
Dim vCustInfoName As Variant
Dim bRet As Boolean
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Debug.Print "File = " & swModel.GetPathName
vConfigNameArr = swModel.GetConfigurationNames
' Is empty if a drawing becasue configurations not supported on drawings
If IsEmpty(vConfigNameArr) Then
ReDim vConfigNameArr(0)
vConfigNameArr(0) = ""
Else
' Add a blank string for the nonconfiguration-specific custom properties
ReDim Preserve vConfigNameArr(UBound(vConfigNameArr) + 1)
End If
For Each vConfigName In vConfigNameArr
Debug.Print " " & vConfigName
vCustInfoNameArr = swModel.GetCustomInfoNames2(vConfigName)
If Not IsEmpty(vCustInfoNameArr) Then
For Each vCustInfoName In vCustInfoNameArr
Debug.Print " " & vCustInfoName
Debug.Print " Type = " & swModel.GetCustomInfoType3(vConfigName, vCustInfoName)
Debug.Print " Value = " & swModel.GetCustomInfoValue(vConfigName, vCustInfoName)
Debug.Print " Text = " & swModel.CustomInfo2(vConfigName, vCustInfoName)
Next
End If
Debug.Print " ---------------------------"
Next
End Sub
Hope that helps!
Shawn Oelschlager
Production Control Ass't
Transco Products Inc.
http://www.transcoproducts.com
SolidWorks Office Premium 2006 - SP4.1
Pentium 4 (2.8 GHz) - 2GB RAM
RE: searching for a configuration specific custom properties in SolidWorks
These .dll functions can be called from any program (Excel, etc) that uses OLE automation. Below is sample SolidWorks macro that will list all the custom properties for each configuration of the active document. Note that these will be read from the stored file on disk rather than the current version in memory, so if you add a new custom property you will have to save the document before the macro will find it. For this macro to work you will need to go to Tools->References in the VBA editor and check the box for SwDocumentMgr 200(x) Type Library. You may have to browse or search for it. Mine is located at C:\Program Files\Common Files\SolidWorks Shared. If you are using SW2006 or earlier you will have to get a license key string and change the value of the constant "DOCMGRLICENSEKEYSTRING" to whatever key you receive from API support.
CODE
Dim swApp As SldWorks.SldWorks
Dim swDocMgr As SwDocumentMgr.SwDMApplication
Dim swDoc As SldWorks.ModelDoc2
Dim myTestConfig As SwDocumentMgr.SwDMConfiguration5
Dim CfgMgr As SwDocumentMgr.SwDMConfigurationMgr
Dim myCfgNames As Variant
Dim myCustPropNames As Variant
Dim myCustPropVals As Variant
Dim myDocMgrClassFactory As SwDocumentMgr.SwDMClassFactory
Dim myDocMgr As SwDocumentMgr.SwDMApplication
Dim mySwDoc As SwDocumentMgr.SwDMDocument7
Dim i As Long
Dim j As Long
Dim msg As String
Sub main()
Set swApp = Application.SldWorks
Set swDoc = swApp.ActiveDoc
Set myDocMgrClassFactory = CreateObject("SwDocumentMgr.SwDMClassFactory")
Set myDocMgr = myDocMgrClassFactory.GetApplication(DOCMGRLICENSEKEYSTRING)
Set mySwDoc = myDocMgr.GetDocument(swDoc.GetPathName, swDmDocumentUnknown, True, Empty)
Set CfgMgr = mySwDoc.ConfigurationManager
myCfgNames = CfgMgr.GetConfigurationNames
msg = "There are " & CfgMgr.GetConfigurationCount & " configurations of " & swDoc.GetTitle
For i = 0 To UBound(myCfgNames)
Set myTestConfig = CfgMgr.GetConfigurationByName(myCfgNames(i))
msg = msg & vbCrLf & vbCrLf & myCfgNames(i)
myCustPropNames = myTestConfig.GetCustomPropertyNames
For j = 0 To UBound(myCustPropNames)
msg = msg & vbCrLf & " " & myCustPropNames(j) & " : "
msg = msg & myTestConfig.GetCustomPropertyValues(myCustPropNames(j), swDmCustomInfoUnknown, "")
Next
Next
MsgBox msg
End Sub
RE: searching for a configuration specific custom properties in SolidWorks
Thank you Shawn and Handleman, we are looking for SolidWorks Explorer "enhanced" functionality.
We could use the API, but would like to propose a less time consuming solution. So we might just create a database or spreadsheet instead and use it to store and search for information.
Regards,
Joseph