Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro tips for me.

Status
Not open for further replies.

CycloneWade

Automotive
Apr 1, 2005
76
I created a macro that searches the tree for a particular item and suppresses it. What I would like to do in my macro is query whether the feature is suppressed or not, then suppress or unsuppress the flat pattern based on the state of the previous feature.

I should mention I would like the same macro to reverse the process.

Regards,

Code for Reference:

' ******************************************************************************
' C:\Users\WANDER~1.TRI\AppData\Local\Temp\swx5752\Macro1.swb - macro recorded on 06/04/08 by wanderson
' ******************************************************************************
Dim swApp As Object
Dim Part As Object
Dim SelMgr As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Dim Feature As Object
Dim swFeature As SldWorks.Feature
Dim FeatName As String
Dim FeatType As String
Dim nBendState As Long
Dim nRetVal As Long
Dim bRet As Boolean

Sub main()

Set swApp = Application.SldWorks
If Not swApp Is Nothing Then
Set Part = swApp.ActiveDoc

If Not Part Is Nothing Then
Set swFeature = Part.FirstFeature
While Not swFeature Is Nothing
FeatType = swFeature.GetTypeName
' MsgBox "" & FeatType
If FeatType = "Bending" Then
' Select the feature
Dim suppressSet As Boolean
Dim suppressState As Long
' Need to determine if Flex "Bending" feature is suppressed 'or not suppressed theneither suppress or unsuppress flat 'pattern depending on current state.
' This command suppresses feature if the feature is called 'Bending
suppressSet = swFeature.SetSuppression(swSuppressFeature)
' Select the feature
End If
Set swFeature = swFeature.GetNextFeature
Wend
End If
End If

End Sub
 
Replies continue below

Recommended for you

You may want to try grouping features in a folder instead of creating a feature.

Just store the suppressed/unsuppressed of your previous "trigger" feature in a variable (perhaps a Boolean) and keep traversing. When you reach the flat pattern, suppress/unsuppress accordingly.

[bat]Honesty may be the best policy, but insanity is a better defense.[bat]
-SolidWorks API VB programming help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor