Attribute VB_Name = "FramedBox11"
' ******************************************************************************
' FramedBox4.swb - version of FramedBox3.swb macro with enhanced features and
'                  user form
' Sample Macro created by Leonard Kikstra on 03/19/07
' For free SolidWorks Macros,
'     visit http://www.lennyworks.com/solidworks/default.asp?ID=20
' ******************************************************************************
Global swApp As Object
Global Part As Object
Global SelMgr As Object
Global boolstatus As Boolean
Global longstatus As Long, longwarnings As Long
Global Feature As Object
Global ModelDocExt As Object
Global MassValue As Variant
Global MassStatus As Long

Sub main()

Set swApp = Application.SldWorks
  Set Document = swApp.ActiveDoc            ' Get active document
  If Not Document Is Nothing Then           ' Document is valid
    FileTyp = Document.GetType              ' Get document type
    If FileTyp = swDocPART Then             ' Is it a part model?
      Set Part = swApp.ActiveDoc
      Set ModelDocExt = Part.Extension
      MassValue = ModelDocExt.GetMassProperties(1, MassStatus)
      If MassStatus = 2 Then
        UserForm1.Show
      Else
        MsgBox "Part model has mass.  Please start with blank part model.", vbExclamation
      End If
    Else
      MsgBox "Current document is not a part model.  Please start with blank part model.", vbExclamation
    End If
  Else
'   MsgBox "No active part found in SolidWorks.  Please start with blank part model.", vbExclamation
    DefaultPart = swApp.GetUserPreferenceStringValue(swDefaultTemplatePart)
    Set Part = swApp.NewDocument(DefaultPart, 0, 0, 0)
    If Not Part Is Nothing Then             ' Document is valid
        Set ModelDocExt = Part.Extension
        UserForm1.Show
      Else
        MsgBox "Could automatically load part.  Please start with blank part model.", vbExclamation
        MsgBox "File " & DefaultPart & " not found"
      End If
  End If
End Sub
