×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

using api function FlatPatternFeatureData.SimplifyBends

using api function FlatPatternFeatureData.SimplifyBends

using api function FlatPatternFeatureData.SimplifyBends

(OP)
I want to change the flatpattern option "simplified bends" from a sheet metal part by means of a visual basic program.
This does not work.

Sample of the code used:

CODE

Option Explicit
Public SwApp                    As SldWorks.SldWorks
Public swDoc                    As ModelDoc2
Public SettingsStored           As Boolean



Private Sub Form_Load()
  Dim DocType                 As Integer
  Dim strDXFLocation          As String
  Dim CompPathName            As String
  Dim ConfigName              As String
  Dim strOrigFile             As String
  Dim strFileToDxf              As String
  Dim blConvertedAllFeatures  As Boolean
  Dim featureCount    As Long
  Dim Feature         As Feature
  Dim featureName     As String
  Dim FeatureType     As String
  Dim swFlatPattern   As FlatPatternFeatureData
  
  '--check if document open
  CheckForSWDocument
  
  ProgressInfo ("Connecting to SolidWorks")
  If InitSolidWorks(SwApp) Then
            
    '## Retieving active Document ##
    ProgressInfo ("Retrieving active document")
    Set swDoc = SwApp.ActiveDoc
        
    If Not swDoc Is Nothing Then
      DocType = swDoc.GetType
            
      '## Auto Converter works only on Parts ##
      ProgressInfo ("Checking open document type")
      If (DocType = swDocPART) Then
            
        '## Resolve lightweight components ##
        CheckForLightWeightComponents
        '## Retrieving information from active document ##
        ProgressInfo "  Document naam = " & GetDocName(swDoc.GetPathName) & "    Configuratie = " & swDoc.GetActiveConfiguration.Name
      Else
        ProgressInfo "AutoDXFConverter works only on Parts."
        Exit Sub
      End If
    End If
  Else
    ProgressInfo ("Could not connect to SolidWorks")
  End If
  
  '--check if it is a sheet metal part
  Dim swBendState As Integer
  swBendState = swDoc.GetBendState
  If swBendState = swSMBendStateNone Then
    EndProgram
    ProgressInfo ("This is NO sheetmetal part.")
    Exit Sub
  End If
  blConvertedAllFeatures = True
  featureCount = swDoc.GetFeatureCount
  ProgressInfo ("Nr. of features in part: " & featureCount)

  Set Feature = swDoc.FirstFeature
  featureCount = 1
  While Not Feature Is Nothing
    featureName = Feature.Name
    FeatureType = Feature.GetTypeName
    ProgressInfo featureName

'--turn off simplified bends in flat pattern feature
    If UCase(FeatureType) = UCase("flatpattern") Then
      Set swFlatPattern = Feature.GetDefinition
      ProgressInfo "status = " & Feature.GetDefinition.SimplifyBends
      Feature.GetDefinition.SimplifyBends = False
  End If
          

'-- after the previous lines the flatpattern option should be changed. Only it isn't.

    Set Feature = Feature.GetNextFeature
    featureCount = featureCount + 1
  Wend
  ProgressInfo "Done!"
      'Unload Me

Exit Sub
ErrExit:
    MsgBox Err.Description
    EndProgram
End Sub

RE: using api function FlatPatternFeatureData.SimplifyBends

It doesn't work because you are missing a couple of calls.  To change this option your routine needs to
  • get access to the feature selections
  • change the option
  • modify the definition to update the feature with the new option
You are missing the first and last items in the list.  I think your if statement should be:

CODE

'--turn off simplified bends in flat pattern feature
    If UCase(FeatureType) = UCase("flatpattern") Then
      Set swFlatPattern = Feature.GetDefinition
      ProgressInfo "status = " & Feature.GetDefinition.SimplifyBends
      bRet = swFlatPattern.AccessSelections(swDoc, Nothing)
      swFlatPattern.SimplifyBends = False
      bRet = Feature.ModifyDefinition(swFlatPattern, swDoc, Nothing)
  End If

RE: using api function FlatPatternFeatureData.SimplifyBends

(OP)
Thanks for your reply.
I changed the code as You stated and it works fine now.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources