|
||||||||||||||||||||
![]() |
||||||||||||||||||||
|
|
||||||||||||||||||||
| Send to a friend Print this article |
||||||||||||||||||||
|
How
to list configuration specific dimensions |
|
||||
|
Ever wish you could create text containing a list of the configuration-specific dimensions within a part? This can be useful when reviewing a part that has multiple configurations. Using SolidWorks® software, it's possible to change a dimension for one or more configurations. And if dimensions need to be changed per configuration, a design table can be created and the dimension changes documented. This example walks through (traverses) a part feature-by-feature, dimension-by-dimension to determine which sketch dimensions are configuration-specific. This application will not list reference dimensions and is limited to sketch dimensions. It will not list suppressed features.
Key:
' ************************************************************* ' Name: configdims.swp ' Date: 07-03-02 ' SolidWorks Ver: 2001 Plus ' Description: This application will list all the configuration specific ' sketch dimensions for a part. The results will be written ' to a text file. ' ' This application only works for dimensions that are driven by ' or drive geometry, not for reference dimensions. Note: The ' reference object "SolidWorks 2001Plus type library" must be ' included to make this macro run. (See Tools/References) ' ************************************************************* Option Explicit Sub main() Dim swApp As SldWorks.SldWorks Dim swModel As SldWorks.ModelDoc2 Dim swFeat As SldWorks.Feature Dim swSubFeat As SldWorks.Feature Dim swDispDim As SldWorks.DisplayDimension Dim swDim As SldWorks.Dimension Dim swAnn As SldWorks.Annotation Dim fileExists As Boolean Dim toDay As Date Dim fileNum As Integer Dim numConfigs As Integer Dim i As Integer Dim confNames As Variant Dim blnFeatFound As Boolean Set swApp = CreateObject("SldWorks.Application") Set swModel = swApp.ActiveDoc Set swFeat = swModel.FirstFeature 'Set date toDay = Now 'Define and set the output filename. The filename will be incremented ( ' Dim fnameLength Dim fileName fnameLength = Len(swModel.GetPathName) - 7 'Strip the file extension For fileNum = 1 To 100 fileName = Left(swModel.GetPathName, fnameLength) & "-" & fileNum & ".txt" fileExists = (Dir(fileName) <> "") If fileExists Then 'File was found continue until one is not found Else Exit For End If Next 'Set the output to a text file Open fileName For Output As #1 Print #1, "Configuration specific dimensions - " + fileName Print #1, "Date: " & toDay 'How many configurations do we have? numConfigs = swModel.GetConfigurationCount() 'Store the names of the configurations confNames = swModel.GetConfigurationNames() Print #1, " " Print #1, "************************************************" Print #1, " Configuration Names" Print #1, "************************************************" 'Look through all configs For i = 0 To (numConfigs - 1) Print #1, " " & confNames(i) Next Print #1, " " Print #1, "************************************************" Print #1, " Configuration Specific Dimensions" Print #1, "************************************************" Do While Not swFeat Is Nothing 'Use this flags for printing the feature and sub-feature only once blnFeatFound = False 'Get the first sub-feature Set swSubFeat = swFeat.GetFirstSubFeature Do While Not swSubFeat Is Nothing 'Get the first dimension for the selected feature Set swDispDim = swSubFeat.GetFirstDisplayDimension Do While Not swDispDim Is Nothing Set swDim = swDispDim.GetDimension 'Only print the dims that are config specific If swDim.IsAppliedToAllConfigurations = False Then 'If the feature was not used before, print the feature and sub-feature info If Not blnFeatFound Then Print #1, " " 'Print a blank line between each feature name Print #1, " " + swFeat.Name + " (Dimensions)" Print #1, " " + swSubFeat.Name blnFeatFound = True 'Set to false so it only prints once End If 'Print the sub-feature dims Print #1, " [" & swDim.FullName & "] = " & swDim.GetSystemValue2("") End If 'Get the next dimension Set swDispDim = swSubFeat.GetNextDisplayDimension(swDispDim) Loop 'Get the next sub-feature Set swSubFeat = swSubFeat.GetNextSubFeature Loop 'Get the next feature Set swFeat = swFeat.GetNextFeature Loop Close #1'Closethe text file End Sub
|
|
||||
|
|
||||
|
SolidWorks.com |
SolidWorks
Corporation - 300 Baker Avenue Concord, MA 01742 Phone: 800-693-9000 +978-371-5000 Copyright © 2003 SolidWorks Corporation. |
|||