2 Replies Latest reply on Mar 2, 2017 4:43 PM by Brian Smith

    Macro Feature Not Seeing Body's If Macro Feature is Before Body's Creation Feature

    Brian Smith

      I am having a problem with a small function of a larger macro. The part I am having a problem with is that if the macro feature is before a body's (or bodies') main creation feature it does not recognize that there are bodies is the part. The reason why this is important is because I am trying to fix a problem that if our users apply material to a part then use the weldment tool (or create bodies) then cutlist items are not created in the bodies folder. The reason why I want cutlist items in the bodies folder because we are generating custom properties specific to the cutlist item later in the macro feature.

       

      The only obvious way I know how to create a cutlist item is by applying the material to the bodies or to the part again. The problem with this is that if I have my macro feature before the first feature that creates the body (which is what we want because we want the macro feature in our part template and we don't want to manually move it) it does not recognize that there are any bodies.

       

      So when the macro feature is located here, rebuilding this

      Results in creating a cut list item, or this:

       

       

      Rebuilding the below results in no change to the cutlist folder.

      Is there some other way to add a body to a cutlist item? Is there some other way to get bodies in a macro feature if the macro feature is before the bodies creation? Since rebuilds run through every feature of a part, is there a way to run things out of order of the feature tree, ie rebuilding last?

        • Re: Macro Feature Not Seeing Body's If Macro Feature is Before Body's Creation Feature
          Artem Taturevych

          Try to specify swMacroFeatureAlwaysAtEnd option in FeatureManager::InsertMacroFeature3 method so SOLIDWORKS will move your feature to the end automatically.

            • Re: Macro Feature Not Seeing Body's If Macro Feature is Before Body's Creation Feature
              Brian Smith

              That may work for some, but that really messes up when you are working with a sheet metal part. It seems to try to put the macrofeature after the flatpattern feature, and turns on the lower level flat pattern feature and turns on bounding box sketches.

               

              I didn't realize "automatically update cutlist" was an option for the bodyfolder/cutlistfolder, which always generates cutlist items. So for my problem the best solution is to turn on the automatic update or to force update the cutlist.

               

              Dim SwModel as SldWorks.ModelDoc2

              Dim swCutlist As SldWorks.BodyFolder

              Dim swFeat As SldWorks.Feature

              Set swFeat = SwModel.FirstFeature

               

              While Not swFeat Is Nothing

                   ElseIf swFeat.GetTypeName2 = "BodyFolder" Then

                          Set swCutlist = swFeat.GetDefinition

                          swCutlist.UpdateCutList

                          swCutlist.SetAutomaticUpdate (True)

                   End If

                   Set swFeat = swFeat.GetNextFeature

              Wend