3 Replies Latest reply on Aug 8, 2017 8:49 AM by Nadav Gover

    Determine if a body is spherical\conical

    Nadav Gover

      Hi,

      Does anyone have an idea how to determine if a body is spherical\conical.

      Thanks

        • Re: Determine if a body is spherical\conical
          Ivana Kolin
          Option Explicit
          Sub main()
              Dim swApp As SldWorks.SldWorks
              Dim swModel As SldWorks.ModelDoc2
              Dim swSelMgr As SldWorks.SelectionMgr
              Dim swPart As SldWorks.PartDoc
              Dim swComp As SldWorks.Component2
              Dim swBody As SldWorks.Body2
              Dim swFace As SldWorks.Face2
              Dim swSurface As SldWorks.Surface
                 
              Set swApp = Application.SldWorks
              Set swModel = swApp.ActiveDoc
              Set swSelMgr = swModel.SelectionManager
              If swModel.GetType = swDocPART Then
                  Set swPart = swModel
                  Set swBody = swPart.Body
              Else
                  Set swComp = swSelMgr.GetSelectedObjectsComponent2(1)
                  Set swBody = swComp.GetBody
              End If
              Set swFace = swBody.GetFirstFace
              While Not swFace Is Nothing
                  Set swSurface = swFace.GetSurface
                  If swSurface.IsSphere Then
                      MsgBox "Sphere"
                      Exit Sub
                  End If
                  If swSurface.IsCone Then
                      MsgBox "Cone"
                      Exit Sub
                  End If
                  Set swFace = swFace.GetNextFace
              Wend
          End Sub
          
          • Re: Determine if a body is spherical\conical
            Amen Allah Jlili

            @Nadav_Gover: Better check if the surface is conic or spheric. You'll run into trouble with you have complicated bodies.