Dear All --
I wrote a snippet for this, but it failed to get any results. It was showing "Out of stack error". Below is the code that I have written
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 swcoll As Collection
Sub main()
Set swapp = Application.SldWorks
Set swmodel = swapp.ActiveDoc
Set swcoll = New Collection
Set swfeat = swmodel.FirstFeature
While Not swfeat Is Nothing
MsgBox swfeat.Name
Set swdispdim = swfeat.GetFirstDisplayDimension
While Not swdispdim Is Nothing
Set swdim = swdispdim.GetDimension2(0)
swcoll.Add swdim
Set swdispdim = swdispdim.GetNext5
Wend
swsubfeats swfeat
Set swfeat = swfeat.GetNextFeature
Wend
For i = 1 To swcoll.Count
swdim = swcoll(i)
MsgBox swdim.FullName
MsgBox swdim.Value
Next i
End Sub
Sub swsubfeats(myfeat As SldWorks.Feature)
Dim swsubfeat As SldWorks.Feature
Dim swdispdim As SldWorks.DisplayDimension
Dim swdim As SldWorks.Dimension
Set swsubfeat = swfeat.GetFirstSubFeature
While Not swsubfeat Is Nothing
MsgBox swsubfeat.Name
Set swdispdim = swsubfeat.GetFirstDisplayDimension
While Not swdispdim Is Nothing
Set swdim = swdispdim.GetDimension2(0)
swcoll.Add swdim
Set swdispdim = swdispdim.GetNext5
Wend
swsubfeats swfeat
Set swsubfeat = swsubfeat.GetNextSubFeature
Wend
End Sub
Can you tell me where I am going wrong & why and what should I do to overcome it ...
While I was browsing through the forum with the similar search, I found a code written by Josh Brady. I ran it, the results came successfully
But I didnt understand quite a few lines. Can anyone please explain these lines to me
bMatch = False ' Here bMatch is made False
' How are the below lines functioning ?
For i = 1 To CollDims.Count
If swDim Is CollDims(i) Then
bMatch = True
i = CollDims.Count
End If
Next i
If Not bMatch Then CollDims.Add swDim ' First bmatch = false . So this line means If not False (means If True ) then swDim should get added to the collection,... i am getting confused. Can anyone explain this.
Thanks and Regards,
Thomas.
SolidworksApi macros