37 Replies Latest reply on Jun 20, 2018 5:58 PM by Alin Vargatu

    The 16th SOLIDWORKS Power-User Challenge - Unknit a surface

    Alin Vargatu

      Hello SOLIDWORKS Power-Users and welcome to the 16th SWPUC.

       

      For 5,000 points and eternal glory proposed the best, most elegant technique for unknitting a surface body in its individual faces.

       

      Conditions:

       

      1. Download the attached file
      2. Use these options for importing the file in SOLIDWORKS. We need a surface body as the result.

       

           3. Resolve any topological errors at face level. Gaps are acceptable.

           4. Using only SOLIDWORKS features (exporting out as a neutral format (or other type of format), and importing it back, with the option to not knit faces is not acceptable) "unknit" the existing surface body in such a way that would generate individual bodies.

       

      You get an extra 1000 points if you explain in detail your method.

      Other 1000 prizes and certificates of SOLIDWORKS Power-User can be won, if your method stands out.

       

      In case you are a programmer, and would like to submit a macro for performing the unknitting, we should have a separate award. The user submitting the fastest macro that will get the job done, will get 5000 points. The only conditions are:

      1. You wrote the macro.
      2. You gift the macro to the SOLIDWORKS Community
      3. Ideally the macro should prompt the user to select a face belonging to a surface body, or multiple faces belonging to multiple surface bodies, and unknit the bodies in individual faces. If those faces are pre-selected, the macro will go ahead and unknit the surface bodies that contain the selected faces.

       

      Please submit your entries before 5 pm EDT on Thursday, the 10th of May, 2018.

        • Re: The 16th SOLIDWORKS Power-User Challenge - Unknit a surface
          Josh Brady

          Probably not so elegant, and it don't run so fast, but it wrote fast.  Should work on any part file, surfaces, solids, etc.  It will process all the bodies in the document.

          Edit:  Forgot one small detail to drastically improve run time.  Also added intelligent naming of the features created.

          Dim swApp As SldWorks.SldWorks
          Dim swDoc As SldWorks.ModelDoc2
          Dim swModeler As SldWorks.Modeler
          Dim swPart As SldWorks.PartDoc
          Dim aOrigBods As Variant
          Dim oBod As SldWorks.Body2
          Dim NuBod As SldWorks.Body2
          Dim swFace As SldWorks.Face2
          Dim aFaces(0) As SldWorks.Face2
          Dim aFeats As Variant
          Dim i As Long
          Dim Count As Long
          Dim SubCount
          Dim StopWatch As Double
          Sub main()
          
          
          Set swApp = Application.SldWorks
          Set swDoc = swApp.ActiveDoc
          Set swPart = swDoc
          Set swModeler = swApp.GetModeler
          aOrigBods = swPart.GetBodies2(-1, True)
          Count = 1
          StopWatch = Timer
          swDoc.FeatureManager.EnableFeatureTree = False
          For i = 0 To UBound(aOrigBods)
              Set oBod = aOrigBods(i)
              Debug.Print "Processing body " & oBod.Name
              Set swFace = oBod.GetFirstFace
              SubCount = 1
              While Not swFace Is Nothing
                  Set aFaces(0) = swFace
                  Set NuBod = swModeler.CreateSheetFromFaces(aFaces)
                  aFeats = swPart.CreateSurfaceFeatureFromBody(NuBod, 0)
                  aFeats(0).Name = oBod.Name & "-Face" & SubCount
                  Debug.Print , "Processed surface " & SubCount & " of current body (" & Count & " overall)"
                  Set swFace = swFace.GetNextFace
                  Count = Count + 1
                  SubCount = SubCount + 1
              Wend
          Next i
          swDoc.FeatureManager.EnableFeatureTree = True
          MsgBox "Completed in " & Round(Timer - StopWatch, 2) & "s"
          End Sub
          
            • Re: The 16th SOLIDWORKS Power-User Challenge - Unknit a surface
              Josh Brady

              OK, here's my final submission... It's actually 2 different approaches, depending on how the required result is defined.

               

              For both versions I commented out the useful naming of the surface features in the tree because it adds some time - around a second.  If I were using this macro for myself, the extra second would be worth it, especially if the part were a multibody to start with, but for speed I commented it out.

               

              Method_One reports a time of 0.59s on my machine, and displays an updated graphics view and feature tree.

               

              Method_Two reports a blistering 0.14s.  The features and surfaces are all there, but don't actually appear in the graphics area or feature tree until you do a rebuild.  Adding a rebuild statement to the end of this one makes it slower than the first.  Just for funsies, I ran this on a multibody part with 147 solid bodies.  It ran in 0.98s and created 1456 surface body features.

               

              I'm sure someone will probably beat my time, but I would hope that it's by doing it more cleverly/efficiently rather than putting this same approach into an execution environment that's faster like an add-in or .Net something-or-other...

               

              Dim swApp As SldWorks.SldWorks
              Dim swDoc As SldWorks.ModelDoc2
              Dim swModeler As SldWorks.Modeler
              Dim swPart As SldWorks.PartDoc
              Dim aOrigBods As Variant
              Dim oBod As SldWorks.Body2
              Dim NuBod As SldWorks.Body2
              Dim swFace As SldWorks.Face2
              
              
              Dim aFeats As Variant
              Dim i As Long
              Dim Count As Long
              Dim SubCount
              Dim StopWatch As Double
              Sub Method_One()
              Dim aFaces(0) As SldWorks.Face2
              Set swApp = Application.SldWorks
              Set swDoc = swApp.ActiveDoc
              Set swPart = swDoc
              Set swModeler = swApp.GetModeler
              aOrigBods = swPart.GetBodies2(-1, True)
              Count = 1
              StopWatch = Timer
              swDoc.FeatureManager.EnableFeatureTree = False
              For i = 0 To UBound(aOrigBods)
                  Set oBod = aOrigBods(i)
                  Debug.Print "Processing body " & oBod.Name
                  Set swFace = oBod.GetFirstFace
                  SubCount = 1
                  While Not swFace Is Nothing
                      Set aFaces(0) = swFace
                      Set NuBod = swModeler.CreateSheetFromFaces(aFaces)
                      aFeats = swPart.CreateSurfaceFeatureFromBody(NuBod, 0)
                      'aFeats(0).Name = oBod.Name & "-Face" & SubCount
                      'Debug.Print , "Processed surface " & SubCount & " of current body (" & Count & " overall)"
                      Set swFace = swFace.GetNextFace
                      Count = Count + 1
                      SubCount = SubCount + 1
                  Wend
              Next i
              swDoc.FeatureManager.EnableFeatureTree = True
              MsgBox "Completed in " & Round(Timer - StopWatch, 2) & "s"
              End Sub
              
              
              Sub Method_Two()
              Dim swFeat As SldWorks.Feature
              Dim swExt As SldWorks.ModelDocExtension
              Set swApp = Application.SldWorks
              Set swDoc = swApp.ActiveDoc
              Set swPart = swDoc
              Set swExt = swDoc.Extension
              
              
              
              
              
              
              Set swModeler = swApp.GetModeler
              aOrigBods = swPart.GetBodies2(-1, True)
              Dim aFaces(0) As SldWorks.Face2
              Count = 1
              StopWatch = Timer
              swDoc.FeatureManager.EnableFeatureTree = False
              For i = 0 To UBound(aOrigBods)
                  Set oBod = aOrigBods(i)
                  'Debug.Print "Processing body " & oBod.Name
                  Set swFace = oBod.GetFirstFace
                  SubCount = 1
                  While Not swFace Is Nothing
                      Set aFaces(0) = swFace
                      Set NuBod = swModeler.CreateSheetFromFaces(aFaces)
                      NuBod.CreateBaseFeature NuBod
                      'Set swFeat = swExt.GetLastFeatureAdded
                      'swFeat.Name = oBod.Name & "-Face" & SubCount
                      'Debug.Print , "Processed surface " & SubCount & " of current body (" & Count & " overall)"
                      Set swFace = swFace.GetNextFace
                      Count = Count + 1
                      SubCount = SubCount + 1
                  Wend
              Next i
              'swDoc.EditRebuild3
              swDoc.FeatureManager.EnableFeatureTree = True
              MsgBox "Completed in " & Round(Timer - StopWatch, 2) & "s"
              End Sub
              
              • Re: The 16th SOLIDWORKS Power-User Challenge - Unknit a surface
                Alin Vargatu

                Josh Brady wrote:

                 

                Probably not so elegant, and it don't run so fast, but it wrote fast. Should work on any part file, surfaces, solids, etc. It will process all the bodies in the document.

                Edit: Forgot one small detail to drastically improve run time. Also added intelligent naming of the features created.

                1. DimswAppAsSldWorks.SldWorks
                2. DimswDocAsSldWorks.ModelDoc2
                3. DimswModelerAsSldWorks.Modeler
                4. DimswPartAsSldWorks.PartDoc
                5. DimaOrigBodsAsVariant
                6. DimoBodAsSldWorks.Body2
                7. DimNuBodAsSldWorks.Body2
                8. DimswFaceAsSldWorks.Face2
                9. DimaFaces(0)AsSldWorks.Face2
                10. DimaFeatsAsVariant
                11. DimiAsLong
                12. DimCountAsLong
                13. DimSubCount
                14. DimStopWatchAsDouble
                15. Submain()
                16. SetswApp=Application.SldWorks
                17. SetswDoc=swApp.ActiveDoc
                18. SetswPart=swDoc
                19. SetswModeler=swApp.GetModeler
                20. aOrigBods=swPart.GetBodies2(-1,True)
                21. Count=1
                22. StopWatch=Timer
                23. swDoc.FeatureManager.EnableFeatureTree=False
                24. Fori=0ToUBound(aOrigBods)
                25. SetoBod=aOrigBods(i)
                26. Debug.Print"Processingbody"&oBod.Name
                27. SetswFace=oBod.GetFirstFace
                28. SubCount=1
                29. WhileNotswFaceIsNothing
                30. SetaFaces(0)=swFace
                31. SetNuBod=swModeler.CreateSheetFromFaces(aFaces)
                32. aFeats=swPart.CreateSurfaceFeatureFromBody(NuBod,0)
                33. aFeats(0).Name=oBod.Name&"-Face"&SubCount
                34. Debug.Print,"Processedsurface"&SubCount&"ofcurrentbody("&Count&"overall)"
                35. SetswFace=swFace.GetNextFace
                36. Count=Count+1
                37. SubCount=SubCount+1
                38. Wend
                39. Nexti
                40. swDoc.FeatureManager.EnableFeatureTree=True
                41. MsgBox"Completedin"&Round(Timer-StopWatch,2)&"s"
                42. EndSub

                Really fast. Works like a charm!

              • Re: The 16th SOLIDWORKS Power-User Challenge - Unknit a surface
                Kameron Smith

                My first attempt is a rather inelegant solution...

                 

                I used 5 Offset Surface features (0.0 offset) and a whole lot of time consuming face selections.  The "trick" is to make sure you don't select any faces that are adjacent to each other in one feature, as they will combine into a single surface body, and give you an inaccurate surface body count.  If I spent a little more time on my selection strategy, I think I could probably reduce it to 4 features.

                 

                ~Kam

                • Re: The 16th SOLIDWORKS Power-User Challenge - Unknit a surface
                  Paul Salvador

                  Alin,.. the fast/simple way,.. export as a STEP, SAT, Pro/e and turn off knitting for import...

                  x2.png

                  ...NEVER MIND... I don't get what the challenge is??   Why would you do this anyway?

                    • Re: The 16th SOLIDWORKS Power-User Challenge - Unknit a surface
                      Alin Vargatu

                      Thanks Paul. I stated in the conditions that the import with do not knit setting is not acceptable for this challenge.

                        • Re: The 16th SOLIDWORKS Power-User Challenge - Unknit a surface
                          Paul Salvador

                          Hello Alin,... my point is, I did KNIT... and import and get a correct/knitted result and I Export and Import (w/o  knitting).. that is the FASTEST way to do this, imho.

                            • Re: The 16th SOLIDWORKS Power-User Challenge - Unknit a surface
                              Alin Vargatu

                              Paul Salvador wrote:

                               

                              Hello Alin,... my point is, I did KNIT... and import and get a correct/knitted result and I Export and Import (w/o knitting).. that is the FASTEST way to do this, imho.

                              Let’s find out the best way to explode, or unknit a given surface body. Sometimes, a user might want to do that for one body only, not the whole part.

                              • Re: The 16th SOLIDWORKS Power-User Challenge - Unknit a surface
                                Josh Brady

                                Actually, I have already demonstrated that the FASTEST way takes only 0.14s.  It's much faster than export and import... 

                                  • Re: The 16th SOLIDWORKS Power-User Challenge - Unknit a surface
                                    Paul Salvador

                                    Hey Josh,..  that is great.. and I appreciate your macro work!... but.. honestly.. we're talking no more than a few seconds difference.. and what do you do with the data then?    I'm just trying to understand.. the need/want...  and maybe there will be some revelation as to how this can be helpful... or maybe,.. just for fun?  (ok,.. I'm over thinking this.. so, I get that part!) 

                                    • Re: The 16th SOLIDWORKS Power-User Challenge - Unknit a surface
                                      Rob Edwards

                                      Josh Brady wrote:

                                       

                                      Actually, I have already demonstrated that the FASTEST way takes only 0.14s. It's much faster than export and import...

                                      WOW..That's incredible

                                      my attempt was so slow I had to implement a progress bar for some minor entertainment

                                      wanting to do something different I used InsertOffsetSurface, which does mean I can do this

                                      but I can't imagine why.

                                       

                                      I didn't do anything for pre selection, the macro just works on 'showing' surfaces.

                                       

                                      Great Fun, thanks Alin

                                       

                                      macro attached

                                       

                                       

                                      Option Explicit
                                      
                                      Dim swApp            As SldWorks.SldWorks
                                      Dim swModel          As SldWorks.ModelDoc2
                                      Dim swPart           As SldWorks.PartDoc
                                      Dim bodycount        As Integer
                                      Dim totalfacecount   As Integer
                                      Dim swProgBar        As SldWorks.UserProgressBar
                                      
                                      Sub main()
                                      
                                          Set swApp = Application.SldWorks
                                          Set swModel = swApp.ActiveDoc
                                      
                                          Select Case True
                                                 Case swModel Is Nothing _
                                                    , swModel.GetType <> swDocPART
                                                    ' invalid or No document
                                                 Case Else
                                                      Set swPart = swModel
                                                      Dim stopwatch As Double: stopwatch = Timer
                                                      Call ProcessBodies
                                                      Call swApp.SendMsgToUser2( _
                                                           "Offset " & totalfacecount & " faces in " _
                                                         & bodycount & " bodies." & vbCr _
                                                         & "Time elapsed: " _
                                                         & Round(Timer - stopwatch, 2) & " seconds." _
                                                         , swMbInformation, swMbOk)
                                          End Select
                                      End Sub
                                      
                                      Private Sub _
                                          ProcessBodies()
                                          Updates False
                                         
                                              Dim vBodies As Variant
                                              vBodies = swPart.GetBodies2(bodytype:=swSheetBody, bVisibleOnly:=True)
                                             
                                              For bodycount = 0 To UBound(vBodies)
                                                  totalfacecount = totalfacecount + vBodies(bodycount).GetFaceCount
                                              Next bodycount
                                             
                                              swApp.GetUserProgressBar swProgBar
                                              Call swProgBar.start(0, totalfacecount, quote.random)
                                             
                                              totalfacecount = 0
                                              For bodycount = 0 To UBound(vBodies)
                                                  totalfacecount = totalfacecount + OffsetAllFaces(vBodies(bodycount))
                                             Next bodycount
                                             
                                              swProgBar.End
                                             
                                          Updates True
                                      End Sub
                                      
                                      Private Function _
                                          OffsetAllFaces(ByVal swBody As SldWorks.Body2) As Integer
                                         
                                          Dim facecount As Integer
                                          Dim swEntity As SldWorks.Entity
                                      
                                          Dim swFace As SldWorks.Face2
                                          Set swFace = swBody.GetFirstFace
                                             
                                           Do While Not swFace Is Nothing
                                              Set swEntity = swFace
                                              swEntity.Select4 False, Nothing
                                              swModel.InsertOffsetSurface 0#, False
                                              swModel.Extension.GetLastFeatureAdded.Name = swBody.Name & "-Offset" & facecount
                                              Set swFace = swFace.GetNextFace
                                              facecount = facecount + 1
                                              swProgBar.UpdateProgress totalfacecount + facecount
                                              If quote.again Then swProgBar.UpdateTitle (quote.random)
                                          Loop
                                          OffsetAllFaces = facecount
                                      End Function
                                      
                                      Private Function _
                                          Updates(update As Boolean)
                                          With swModel
                                              .FeatureManager.EnableFeatureTree = update
                                              .ActiveView.EnableGraphicsUpdate = update
                                          End With
                                      End Function
                                      
                                        • Re: The 16th SOLIDWORKS Power-User Challenge - Unknit a surface
                                          Alin Vargatu

                                          Rob Edwards wrote:

                                           

                                           

                                          Great Fun, thanks Alin

                                           

                                          macro attached

                                           

                                           

                                          1. OptionExplicit
                                          2. DimswAppAsSldWorks.SldWorks
                                          3. DimswModelAsSldWorks.ModelDoc2
                                          4. DimswPartAsSldWorks.PartDoc
                                          5. DimbodycountAsInteger
                                          6. DimtotalfacecountAsInteger
                                          7. DimswProgBarAsSldWorks.UserProgressBar
                                          8. Submain()
                                          9. SetswApp=Application.SldWorks
                                          10. SetswModel=swApp.ActiveDoc
                                          11. SelectCaseTrue
                                          12. CaseswModelIsNothing_
                                          13. ,swModel.GetType<>swDocPART
                                          14. 'invalidorNodocument
                                          15. CaseElse
                                          16. SetswPart=swModel
                                          17. DimstopwatchAsDouble:stopwatch=Timer
                                          18. CallProcessBodies
                                          19. CallswApp.SendMsgToUser2(_
                                          20. "Offset"&totalfacecount&"facesin"_
                                          21. &bodycount&"bodies."&vbCr_
                                          22. &"Timeelapsed:"_
                                          23. &Round(Timer-stopwatch,2)&"seconds."_
                                          24. ,swMbInformation,swMbOk)
                                          25. EndSelect
                                          26. EndSub
                                          27. PrivateSub_
                                          28. ProcessBodies()
                                          29. UpdatesFalse
                                          30. DimvBodiesAsVariant
                                          31. vBodies=swPart.GetBodies2(bodytype:=swSheetBody,bVisibleOnly:=True)
                                          32. Forbodycount=0ToUBound(vBodies)
                                          33. totalfacecount=totalfacecount+vBodies(bodycount).GetFaceCount
                                          34. Nextbodycount
                                          35. swApp.GetUserProgressBarswProgBar
                                          36. CallswProgBar.start(0,totalfacecount,quote.random)
                                          37. totalfacecount=0
                                          38. Forbodycount=0ToUBound(vBodies)
                                          39. totalfacecount=totalfacecount+OffsetAllFaces(vBodies(bodycount))
                                          40. Nextbodycount
                                          41. swProgBar.End
                                          42. UpdatesTrue
                                          43. EndSub
                                          44. PrivateFunction_
                                          45. OffsetAllFaces(ByValswBodyAsSldWorks.Body2)AsInteger
                                          46. DimfacecountAsInteger
                                          47. DimswEntityAsSldWorks.Entity
                                          48. DimswFaceAsSldWorks.Face2
                                          49. SetswFace=swBody.GetFirstFace
                                          50. DoWhileNotswFaceIsNothing
                                          51. SetswEntity=swFace
                                          52. swEntity.Select4False,Nothing
                                          53. swModel.InsertOffsetSurface0#,False
                                          54. swModel.Extension.GetLastFeatureAdded.Name=swBody.Name&"-Offset"&facecount
                                          55. SetswFace=swFace.GetNextFace
                                          56. facecount=facecount+1
                                          57. swProgBar.UpdateProgresstotalfacecount+facecount
                                          58. Ifquote.againThenswProgBar.UpdateTitle(quote.random)
                                          59. Loop
                                          60. OffsetAllFaces=facecount
                                          61. EndFunction
                                          62. PrivateFunction_
                                          63. Updates(updateAsBoolean)
                                          64. WithswModel
                                          65. .FeatureManager.EnableFeatureTree=update
                                          66. .ActiveView.EnableGraphicsUpdate=update
                                          67. EndWith
                                          68. EndFunction

                                           

                                          Thanks, Rob. For some reasons I am getting this error when I run your macro:

                                           

                                • Re: The 16th SOLIDWORKS Power-User Challenge - Unknit a surface
                                  Alin Vargatu

                                  Just a few hours left and we have just an entry on the manual competition and a few on the macro one.

                                   

                                  If you want to win easy points, submit your solution soon.

                                  • Re: The 16th SOLIDWORKS Power-User Challenge - Unknit a surface
                                    Roland Schwarz

                                    Meh. What's on tap for #17?

                                     

                                    If a body of this size were completely corrupt, there'd be no point. If it's just localized, then there's no need to do the whole body.

                                    • Re: The 16th SOLIDWORKS Power-User Challenge - Unknit a surface
                                      Roland Schwarz

                                      So lately I've been back in NX Land, facing a new set of challenges. It's still the biggest horse in the barn, but it's got a 20-year-old saddle.

                                       

                                      Lots of non-parametric modelling. It would be interesting to see more direct-modelling challenges. I think a lot of users could benefit from getting jolted out of the feature tree mindset.

                                      • Re: The 16th SOLIDWORKS Power-User Challenge - Unknit a surface
                                        Alin Vargatu

                                        Sorry for the delay in announcing the winners.

                                         

                                        As Paul Salvador said, what's the point in doing a face-by-face split? Let me give you only 2 reasons:

                                         

                                        1. You want to solve a topological import error. Separating the faces and re-knitting them works in extreme situations

                                        2. You want to offset all faces of a surface that could offset. The ones that could not, you want removed.

                                         

                                        Watch this video and read this article for more information.

                                         

                                        For the first section of the challenge we received one entry from Kameron Smith.

                                        Kameron applied common sense in defining the criteria for manually selecting faces with no common edges and using the Offset Surface command. Unfortunately, he still got a few multi-face bodies in his part.

                                         

                                        Quick tip: There are several ways to find the number of faces in the part. One of them is to turn on the Face selection filter, press CTRL+A and save the result of the selection as a selection set.

                                         

                                        As you could see below, there are 254 unique faces after the imported feature and 241 surface bodies created by Kameron.

                                         

                                         

                                        For his effort, Kameron is awarded 1000 points.

                                         

                                        For the macro competition, as per our judge Ms. Samony Riyaz, the winner is Josh Brady. As you would notice, the winning criteria have been enriched considerably (well, please allow me to do that).

                                         

                                        Read here comments, they are very interesting.

                                         

                                        Josh Brady will receive the Power-User Certificate and 5000 points.

                                         

                                        His Exalted Worship, the one and only SOLIDWORKS Demigod, Rob Edwards wins the Originality Award and 1000 points.

                                         

                                        These are Samony's comments:

                                         

                                         

                                        (Method 2)

                                        Rubric

                                        Josh

                                        Rob

                                        Total

                                        Speed Of Execution

                                        600

                                        500

                                        600

                                        Elegance/Cleanliness of Code

                                        200

                                        200

                                        200

                                        Efficiency

                                        200

                                        200

                                        200

                                        Lines of Code

                                        500

                                        450

                                        500

                                        Originality/Creativity

                                        900

                                        1000

                                        1000

                                        Unknits Surface Bodies from Selected Faces

                                        0

                                        0

                                        1500

                                        Unknits Surface Bodies from all Faces

                                        1000

                                        1000

                                        1000

                                         

                                        3400

                                        3350

                                        5000

                                        Comments:

                                        Josh:

                                        • Very Clean and Quick code, Overall, only 2 for loops present, Nice and easy to obtain the end-result.
                                        • The Rebuild at the end does allow the user from avoiding one click, but regardless, the macro does its job.
                                        • If you're not adding the Rebuild, I think it would've been nice to let the user know that a rebuild is required to see the end-result.

                                        Rob:

                                        • Very, very clean code, I like how it's separated into different procedures, really demonstrates the understanding of the functions used.
                                        • You could however, combine many of those procedures to decrease the wait time for the user. The way you do it is clean, but there are definitely some things you could do to improve the speed of your execution. (one would be to decrease the number of loops used.... with loops, the less we have, the better our program is ).
                                        • You have got a great sense of Humor, I love what you did with the update bar and the different quotes, I definitely got a good laugh out of that!

                                        General Comments:

                                        Overall, I think this was a great Challenge; thank you Alin for putting this out and having everyone involved. Just a few general comments that I think we should all remember while coding (myself included) to avoid any hiccups that we come across.

                                        • It's good to declare variables within the procedures and functions that they're used, unless you have some variables that are used globally, that way you limit any errors that you may encounter
                                        • After using these said variables however, the ones that are object type…ie. swModel for sldworks.ModelDoc2, should be cleared at the end of the procedure, mainly to avoid any memory leakage. This way, the macro doesn't interfere with any of the other background SolidWorks functionality going on

                                        Those are just a couple things that popped in my head while I was going through this, but this is great!

                                        • Re: The 16th SOLIDWORKS Power-User Challenge - Unknit a surface
                                          Alin Vargatu

                                          Sorry for the delay in announcing the winner in the macro section. Will be done soon.

                                          • Re: The 16th SOLIDWORKS Power-User Challenge - Unknit a surface
                                            Alex Lachance

                                            Hey Alin,

                                             

                                            Suggestion for a Weekly challenge, perhaps a weekly challenge about correcting complex imported bodies? I often have a hard time correcting them and find the diagnostic tool to be very limited in it's functionality. Perhaps it would help boost the diagnostic tool's performance?

                                             

                                            Edit: Errrr, I think I misinterpreted this, I think this Weekly challenge was exactly this lol

                                            • Re: The 16th SOLIDWORKS Power-User Challenge - Unknit a surface
                                              Alin Vargatu

                                              Good news. One of the best SOLIDWORKS macro programmers, Ms. Samony Riyaz, has agreed to judge the macro competition.

                                               

                                              Will be back soon.

                                              • Re: The 16th SOLIDWORKS Power-User Challenge - Unknit a surface
                                                Alin Vargatu

                                                Thank you for your patience. I have received not only the results, but also rich comments from our judge, Ms. Samony Riyaz.

                                                 

                                                So in short, Josh Brady is the SWPUC winner by a whisker. Rob Edwards wins the Originality Award.

                                                 

                                                Congratulations to both of you!

                                                 

                                                These are her comments:

                                                 

                                                 

                                                (Method 2)

                                                Rubric

                                                Josh

                                                Rob

                                                Total

                                                Speed Of Execution

                                                600

                                                500

                                                600

                                                Elegance/Cleanliness of Code

                                                200

                                                200

                                                200

                                                Efficiency

                                                200

                                                200

                                                200

                                                Lines of Code

                                                500

                                                450

                                                500

                                                Originality/Creativity

                                                900

                                                1000

                                                1000

                                                Unknits Surface Bodies from Selected Faces

                                                0

                                                0

                                                1500

                                                Unknits Surface Bodies from all Faces

                                                1000

                                                1000

                                                1000

                                                 

                                                3400

                                                3350

                                                5000

                                                Comments:

                                                Josh:

                                                • Very Clean and Quick code, Overall, only 2 for loops present, Nice and easy to obtain the end-result.
                                                • The Rebuild at the end does allow the user from avoiding one click, but regardless, the macro does its job.
                                                • If you're not adding the Rebuild, I think it would've been nice to let the user know that a rebuild is required to see the end-result.

                                                Rob:

                                                • Very, very clean code, I like how it's separated into different procedures, really demonstrates the understanding of the functions used.
                                                • You could however, combine many of those procedures to decrease the wait time for the user. The way you do it is clean, but there are definitely some things you could do to improve the speed of your execution. (one would be to decrease the number of loops used.... with loops, the less we have, the better our program is ).
                                                • You have got a great sense of Humor, I love what you did with the update bar and the different quotes, I definitely got a good laugh out of that!

                                                General Comments:

                                                Overall, I think this was a great Challenge, thank you Alin for putting this out and having everyone involved. Just a few general comments that I think we should all remember while coding (myself included) to avoid any hiccups that we come across.

                                                • It's good to declare variables within the procedures and functions that they're used, unless you have some variables that are used globally, that way you limit any errors that you may encounter
                                                • After using these said variables however, the ones that are object type…ie. swModel for sldworks.ModelDoc2, should be cleared at the end of the procedure, mainly to avoid any memory leakage. This way, the macro doesn't interfere with any of the other background SolidWorks functionality going on

                                                Those are just a couple things that popped in my head while I was going through this, but this is great!