7 Replies Latest reply on Jun 29, 2016 7:43 AM by Viktor Bovzdarenko

    Wicked thickening challenge

    Matthew Spencer

      Hi all,

      First time poster here (if I recall).

       

      We have a model of a glass sculpture in zero-thickness surfaces. The final sculpture will have a uniform pane thickness of 6mm. We must thicken every face of the sculpture, then place every thickened body flat on the same plane and send this file to the waterjet. After cutting them out we will assemble them by hand.

       

      There are some issues here. First is that we need sidewalls for each thickened face. Secondly, we'd like to avoid manually creating every single body if possible, so a semi-automated solution would be best (first time I've ever wanted a command like "Thicken with internal sidewalls"...)

       

      Does anyone have any ideas for executing this? Thank you in advance.

      Here's a somewhat unhelpful image.

      THICKEN PROBLEM.jpg

        • Re: Wicked thickening challenge
          Alin Vargatu

          A macro would accomplish this nicely.

            • Re: Wicked thickening challenge
              Matthew Spencer

              A macro of what procedures?

                • Re: Wicked thickening challenge
                  Adam Bridgman

                  Here is a macro I whipped up.  It should work with a multiface surface, or multiple single face surfaces, or even multiple multi-face surfaces. To use this macro just click tools, macro new, and paste the following in, then run.

                   

                  Option Explicit

                  Sub main()
                      On Error Resume Next
                      Const Thickness As Double = 0.001
                     
                      Dim swApp               As SldWorks.SldWorks
                      Dim swModel             As SldWorks.ModelDoc2
                      Dim swSelMgr            As SldWorks.SelectionMgr
                      Dim swSelData           As SldWorks.SelectData
                      Dim swPart              As SldWorks.PartDoc
                      Dim swBody              As SldWorks.Body2
                      Dim swFace              As SldWorks.Face
                      Dim swEnt               As SldWorks.Entity
                      Dim vBodies             As Variant
                     
                      Dim i                   As Integer
                      Dim j                   As Integer

                      Set swApp = CreateObject("SldWorks.Application")
                      Set swModel = swApp.ActiveDoc
                      Set swPart = swModel
                      Set swSelMgr = swModel.SelectionManager
                      Set swSelData = swSelMgr.CreateSelectData
                      vBodies = swPart.GetBodies2(swAllBodies, True)
                     
                      'Loop through surface bodies and create offset faces
                      For i = LBound(vBodies) To UBound(vBodies)
                          Set swBody = vBodies(i)
                          Set swFace = swBody.GetFirstFace
                          Do Until swFace Is Nothing
                              Set swEnt = swFace
                              bRet = swFace.Select4(False, swSelData)
                              swModel.InsertOffsetSurface Thickness, True
                              Set swFace = swFace.GetNextFace
                          Loop
                         
                          'Delete original surface body
                          swBody.Select2 False, swSelData
                          swModel.FeatureManager.InsertDeleteBody
                      Next

                      'Loop through offset faces and thicken
                      vBodies = swPart.GetBodies2(swAllBodies, True)
                      For i = LBound(vBodies) To UBound(vBodies)
                          Set swBody = vBodies(i)
                          Set swFace = swBody.GetFirstFace
                          Set swEnt = swFace
                          bRet = swFace.Select4(False, swSelData)
                          swSelData.Mark = 1
                          bRet = swFace.Select4(False, swSelData)
                          swModel.FeatureManager.FeatureBossThicken Thickness, 0, 96, False, False, False, False
                      Next

                  End Sub

                    • Re: Wicked thickening challenge
                      Matthew Spencer

                      Wow Adam, thanks for putting in this work, I appreciate it.

                       

                      Unfortunately this script doesn't consider the intersections of pieces, which is one major hurdle to this problem:

                           1. All pieces must thicken individually, BUT

                           2. Their intersections must also be considered and appropriately trimmed

                      • Re: Wicked thickening challenge
                        Alin Vargatu

                        Hmm. The macro does not seem to work in SW2016.

                          • Re: Wicked thickening challenge
                            Viktor Bovzdarenko

                            Hi Alin

                            It works in SW16. The only issue was that one variable was not declared
                            try updated macro with 2016 part which was used as a test model:

                             

                            Option Explicit

                            Sub main()

                                On Error Resume Next

                                Const Thickness As Double = -0.001

                              

                                Dim swApp              As SldWorks.SldWorks: Set swApp = CreateObject("SldWorks.Application")

                                Dim swModel            As SldWorks.ModelDoc2: Set swModel = swApp.ActiveDoc

                                Dim swSelMgr            As SldWorks.SelectionMgr: Set swSelMgr = swModel.SelectionManager

                                Dim swSelData          As SldWorks.SelectData: Set swSelData = swSelMgr.CreateSelectData

                                Dim swPart              As SldWorks.PartDoc: Set swPart = swModel

                                Dim swBody              As SldWorks.Body2

                                Dim swFace              As SldWorks.Face

                                Dim swEnt              As SldWorks.Entity

                                Dim i                  As Long

                              

                                Dim vBodies As Variant: vBodies = swPart.GetBodies2(swAllBodies, True)

                                For i = LBound(vBodies) To UBound(vBodies)

                                    Set swBody = vBodies(i)

                                    Set swFace = swBody.GetFirstFace

                                    Do Until swFace Is Nothing

                                        Set swEnt = swFace

                                        swFace.Select4 False, swSelData

                                        swModel.InsertOffsetSurface Thickness, True

                                        Set swFace = swFace.GetNextFace

                                    Loop

                                    swBody.Select2 False, swSelData

                                    swModel.FeatureManager.InsertDeleteBody

                                Next

                                vBodies = swPart.GetBodies2(swAllBodies, True)

                                For i = LBound(vBodies) To UBound(vBodies)

                                    Set swBody = vBodies(i)

                                    Set swFace = swBody.GetFirstFace

                                    Set swEnt = swFace

                                    swFace.Select4 False, swSelData

                                    swSelData.Mark = 1

                                    swFace.Select4 False, swSelData

                                    swModel.FeatureManager.FeatureBossThicken Thickness, 0, 96, False, False, False, False

                                Next

                            End Sub

                    • Re: Wicked thickening challenge
                      Jerry Steiger

                      Matthew,

                       

                      I suspect that Adam's macro will do what you need. If you need to do work like this in the future, think about what you need up front and make each of your panes as a separate surface. Then you can just thicken them.

                       

                      Having said that, it seems like you will run into some issues with your side walls interfering with one another in some cases. It seems like you would need to allow for the thickness up front by spacing the outside edges slightly apart.

                       

                      Jerry S.