Attribute VB_Name = "FramedBoxPMP"
'********************************************************************'
'
' This macro has been modified to accommodate "FramedBox" macro in a
' PropertyManagerPage.  This example is tightly based on example
' supplied by SolidWorks Corp.
'
'********************************************************************'
'  This Macro shows how to create a simple PropertyManagerPage for
'  SolidWorks.  It includes an example of every control that can
'  be placed on a PropertyManagerPage.
'********************************************************************'

  Global swApp        As Object
  Global Part         As Object
  Global ModelDocExt  As Object
  Global MassValue    As Variant
  Global MassStatus   As Long

' The controls on the page
  Global fb_BoxHeight           As SldWorks.PropertyManagerPageNumberbox
  Global fb_BoxWidth            As SldWorks.PropertyManagerPageNumberbox
  Global fb_BoxDepth            As SldWorks.PropertyManagerPageNumberbox
  Global fb_FrameWidth          As SldWorks.PropertyManagerPageNumberbox

' The application's PropertyManagerPage
  Global swPage                  As fbPropMgr
  
  Global UpdateModel As Boolean

Sub BuildModel()
  swApp.SetUserPreferenceToggle swInputDimValOnCreate, False
  Set SelMgr = Part.SelectionManager
  boolstatus = Part.Extension.SelectByID2("Front", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
  Part.InsertSketch2 True
  Part.SketchRectangle -0.05472935586061, -0.05222154171067, 0, 0.07803727560718, 0.06166272439282, 0, 1
  Part.CreateLine2(-0.05472935586061, -0.05222154171067, 0, 0.07803727560718, 0.06166272439282, 0).ConstructionGeometry = True
  Part.SetPickMode
  boolstatus = Part.Extension.SelectByID2("Point1@Origin", "EXTSKETCHPOINT", 0, 0, 0, False, 0, Nothing, 0)
  boolstatus = Part.Extension.SelectByID2("Line5", "SKETCHSEGMENT", 0.001917740232313, -0.00324540654699, 0, True, 0, Nothing, 0)
  Part.SketchAddConstraints "sgATMIDDLE"
  boolstatus = Part.Extension.SelectByID2("Line2", "SKETCHSEGMENT", -0.05826979936642, 0.01032629355861, 0, False, 0, Nothing, 0)
  Set Annotation = Part.AddDimension2(-0.0895437, 0.00973622, 0)
  Part.Parameter("D1@Sketch1").SystemValue = 0.0762
  boolstatus = Part.Extension.SelectByID2("Line3", "SKETCHSEGMENT", -0.000442555438226, 0.03805976768743, 0, False, 0, Nothing, 0)
  Set Annotation = Part.AddDimension2(-0.00103263, 0.055762, 0)
  boolstatus = Part.Extension.SelectByID2("D1@Sketch1@Part3.SLDPRT", "DIMENSION", 0, 0, 0, False, 0, Nothing, 0)
  Part.Parameter("D2@Sketch1").SystemValue = 0.0762
  Part.ShowNamedView2 "*Trimetric", 8
  boolstatus = Part.Extension.SelectByID2("D2@Sketch1@Part3.SLDPRT", "DIMENSION", 0, 0, 0, False, 0, Nothing, 0)
  Part.FeatureManager.FeatureExtrusion2 True, False, False, 6, 0, 0.0762, 0.003175, False, False, False, False, 0.01745329251994, 0.01745329251994, False, False, False, False, 1, 1, 1, 0, 0, False
  Part.SelectionManager.EnableContourSelection = 0
  boolstatus = Part.Extension.SelectByID2("", "FACE", 0.008336452517312, 0.03809999999999, -0.01401791448944, False, 0, Nothing, 0)
  Part.InsertSketch2 True
  boolstatus = Part.SketchOffsetEntities2(-0.00635, False, False)
  Part.FeatureManager.FeatureCut True, False, False, 1, 0, 0.0762, 0.0762, False, False, False, False, 0.01745329251994, 0.01745329251994, False, False, False, False, 0, 1, 1
  Part.SelectionManager.EnableContourSelection = 0
  boolstatus = Part.Extension.SelectByID2("", "FACE", 0.03809999999999, -0.002048770456724, -0.02885018899354, False, 0, Nothing, 0)
  Part.InsertSketch2 True
  boolstatus = Part.SketchOffsetEntities2(-0.00635, False, False)
  Part.FeatureManager.FeatureCut True, False, False, 1, 0, 0.0762, 0.0762, False, False, False, False, 0.01745329251994, 0.01745329251994, False, False, False, False, 0, 1, 1
  Part.SelectionManager.EnableContourSelection = 0
  boolstatus = Part.Extension.SelectByID2("", "FACE", 0.01320544049963, 0.008272618248554, 0.03809999999993, False, 0, Nothing, 0)
  Part.InsertSketch2 True
  boolstatus = Part.SketchOffsetEntities2(-0.00635, False, False)
  Part.FeatureManager.FeatureCut True, False, False, 1, 0, 0.0762, 0.0762, False, False, False, False, 0.01745329251994, 0.01745329251994, False, False, False, False, 0, 1, 1
  Part.SelectionManager.EnableContourSelection = 0
  Part.ShowNamedView2 "*Isometric", 7
End Sub

Sub main()
    Dim nRetVal             As Long

    Set swApp = CreateObject("SldWorks.Application")

    ' Make sure that there is a model to add the
    ' page to.  If there is no model get rid
    ' of references to any previoud pages.
    If swApp.ActiveDoc Is Nothing Then
        Set Part = swApp.NewPart
        Set swPage = Nothing
    Else
        Set Part = swApp.ActiveDoc            ' Get active document
        Set swPage = Nothing
    End If
    
    ' Ensure we have a model
    If Not Part Is Nothing Then
      FileTyp = Part.GetType              ' Get document type
      If FileTyp = swDocPART Then         ' Is it a part model?
        Set ModelDocExt = Part.Extension
        MassValue = ModelDocExt.GetMassProperties(1, MassStatus)
        If MassStatus = 2 Then
          BuildModel
          ' If there is no page create a new one and show it.
          ' If there is a page, then show it.
          If swPage Is Nothing Then
              Set swPage = New fbPropMgr
              swPage.Show 'display it
          Else
              swPage.Show
          End If
       
        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 "Could automatically load part.  Please start with blank part model.", vbExclamation
    End If

End Sub
'-----------------------------------------------------------

