2 Replies Latest reply on Jan 12, 2017 9:24 AM by Brian Smith

    FlatPattern MergeFace Change Macro

    Brian Smith

      My company has changed how we do flat pattern drawings such that it requires the "mergeface" feature of the flat pattern feature to be turned off.

       

      This is not a problem going forward for new parts and components, but if we want to reuse old components or parts, I want to make a macro so it makes the require changes to be updated to the new standard (merge face change being one of a few).

       

      Where I am getting hung up on is that the API doesn't offer a "SetMergeFace" method for the flat pattern interface.

       

      Being new to VBA and the solidworks API I assume I can change the parts flat pattern public property MergeFace, but it does not seem to make any changes.

       

       

      2015 SOLIDWORKS API Help - IFlatPatternFeatureData Interface Members

       

      Simple code:

       

      Dim swApp As Object

      Dim Part As Object

      Set swApp = _

      Application.SldWorks

      Set Part = swApp.ActiveDoc

      Part.FeatureByName("Flat-Pattern1").GetDefinition.MergeFace = False

       

      This effectively produces no change to the flat pattern feature

       

       

      Breaking it out doesn't do anything:

       

      Set swFeat = Part.FeatureByName("Flat-Pattern1")

      Set swFlatPattern = swFeat.GetDefinition

      swFlatPattern.MergeFace = False

       

       

      Not knowing better, I assumed I am missing something with the access selection. I don't really understand the purpose of the .IAccessSelection2 method of the flat pattern interface. I assume it unlocks editing to the flat pattern feature? But when I have the code below I get "run time error '61836': Unable to read write-only property."

       

      Dim Component As Component2

      boolstatus = swFlatPattern.IAccessSelections(Part, Component)

       

       

      Is there a way to edit the mergeface option of the flat pattern feature in a macro?

       

      Thanks