Please let me know if there is a way to get a total feature properties listing of a part in one go. I do know that per feature this is possible, but now for all together?
Maybe you can elaborate a little better? It is possible for a macro to parse down the feature manager tree, and recurse subfeatures. But Im noit sure what is meant by "Total Feature Properties" ...
When you use your right mouse when pointing to a feature in the feature tree, one can get a window on the feature properties.
What I want is a feature property listing of the whole part in one list without having to do this with every feature manually.
We use this when we recieve parts made by other engineers or firms and there are major problems with the file. This way we get a good overview when what was made and by whom.
We intend to develop AssyGator in the direction you mention. We currently work on "cadml", an XML format that would allow to completely describe cad models as features. Below is a part of a cadml file. As you can see, all dimensions of features are listed in it, so it would be "easy" to extract them with XSLT to generate an HTML list of the features with dimensions. We're looking for sponsors to continue this project. Tell me how much you're ready to pay ;-)
Well, the XML output is the way to go. But if you are as cheap as I am, (or maybe your boss is), this macro will dump a text-only version to a temp file and pop it up onscreen.
Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" _ (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long Declare Function GetTempFileName Lib "kernel32" Alias "GetTempFileNameA" _ (ByVal lpszPath As String, ByVal lpPrefixString As String, ByVal wUnique As Long, _ ByVal lpTempFileName As String) As Long
Sub main() Dim swApp As SldWorks.SldWorks Dim Part As SldWorks.ModelDoc2 Dim boolstatus As Boolean Dim longstatus As Long Dim Feature As SldWorks.Feature Dim subFeat As SldWorks.Feature Dim Config As SldWorks.configuration Dim SupprState As Boolean Dim OutPutStr As String Dim dirTemp As String, fileTemp As String
Const swDocPART = 1 ' Used to be TYPE_PART Set swApp = Application.SldWorks If swApp Is Nothing Then MsgBox "Please start Solidworks before running this macro" Exit Sub End If Set Part = swApp.ActiveDoc If Part Is Nothing Then MsgBox "Please have a part loaded" Exit Sub End If
Set Feature = Part.FirstFeature 'Get the 1st feature in part While Not Feature Is Nothing ' While we have a valid feature featureName = Feature.Name ' Get the name of the feature Creator$ = Feature.CreatedBy CreateDate$ = Feature.DateCreated Moddate$ = Feature.DateModified SupprState = Feature.IsSuppressed OutPutStr = OutPutStr & vbCrLf & featureName & " Created By: " & _ Creator$ & " on " & CreateDate$ & vbCrLf OutPutStr = OutPutStr & Chr$(9) & "Modified on " & Moddate$ & Chr$(9) & _ " Suppressed: " & SupprState & vbCrLf SubFeatMsg$ = Chr$(9) & featureName & " SubFeatures:" Set subFeat = Feature.GetFirstSubFeature If Not (subFeat Is Nothing) Then OutPutStr = OutPutStr _ & SubFeatMsg$ & vbCrLf
While Not subFeat Is Nothing ' While we have a valid _ Sub-feature ' Get the name of the Sub-feature subFeatureName$ = subFeat.Name Creator$ = subFeat.CreatedBy CreateDate$ = subFeat.DateCreated Moddate$ = subFeat.DateModified SupprState = subFeat.IsSuppressed OutPutStr = OutPutStr & Chr$(9) & Chr$(9) & _ subFeatureName$ & " Created By: " _ & Creator$ & " on " & CreateDate$ & vbCrLf OutPutStr = OutPutStr & Chr$(9) & Chr$(9) & _ "Modified on " & Moddate$ & _ " Suppressed: " & SupprState & vbCrLf Set subFeat = subFeat.GetNextSubFeature Wend ' Continue until the last Sub-feature is done Set Feature = Feature.GetNextFeature() Wend ' Continue until the last feature is done ' dump to temp file: first, get the path of the TEMP dir dirTemp = String(100, Chr$(0)): GetTempPath 100, dirTemp 'strip off the ascii zeroes dirTemp = Left$(dirTemp, InStr(dirTemp, Chr$(0)) - 1) ' add a trailing slash, if needed If Right(dirTemp, 1) "\" Then dirTemp = dirTemp & "\" ' get temp filename fileTemp = String(260, 0) ' Create a buffer GetTempFileName dirTemp, "SWX", 0, fileTemp 'Get tempname 'Remove all the unnecessary chr$(0)'s fileTemp = Left$(fileTemp, InStr(1, fileTemp, Chr$(0)) - 1) 'above returns the full filename and pathspec ' dump the contents to the temp file name/path we just generated tmpFile% = FreeFile Open fileTemp For Output As #tmpFile% Print #tmpFile%, OutPutStr Close #tmpFile ' Now pop the doc up in notepad RetCode = Shell("Notepad " & fileTemp, vbNormalFocus)
I have a small program, that will traverse all the features and provide the data in a text box, this can then be copied and used elsewhere. Unfortunately, while I pull my hair out trying to get my new 120GB drive installed, I have unloaded VB and SWX, so I cannot check if it my latest version. If you would like a copy, please email me.
PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here.
All logos and trade names are the property of their respective owners.