' ' Author: Paul T. Shilton ' Organization: Engineering Geometry Systems ' Date: 6/24/03 ' Copyright (c) 2003, Engineering Geometry Systems ' ' Required FeatureCAM Version: 10.1.0.06 ' ' General Description ' ' FMWindowDemo.bas ' - Test/Demo some of the FMWindow functionality. ' - This code was tested with caliper.fm. ' - Run AddLayersForTest. This will create a "features" layer which contains all the ' features in the part and a "curves" layer which contains all the curves in the part. ' - Run FMWindowDemo to create 4 sub-windows on the part. ' wnd1 shows all the curves using the Show command ' wnd2 shows all the features using the Show command ' wnd3 shows all the curves using the SetLayerVisible command on the "curves" layer ' wnd4 shows all the features using the SetLayerVisible command on the "features" layer ' - Run FMWindowDemo again to close sll of the sub-windows except for the currently active ' window which will be maximized. ' Option Explicit Sub FMWindowDemo Dim doc As FMDocument Dim wnds As FMWindows Dim wnd1 As FMWindow Dim wnd2 As FMWindow Dim wnd3 As FMWindow Dim wnd4 As FMWindow Dim mdi_height As Double, mdi_width As Double, mdi_top As Double, mdi_left As Double Dim model As FMModel Set doc = ActiveDocument ' if the sub windows are visible, delete all but the active window If( doc.Windows.Count > 1) Then ' Windows(1) is always the active window. delete the other windows Do Set wnd1 = doc.Windows(2) wnd1.Close Loop While doc.Windows.Count > 1 ' maximize the remaining window. Set wnd1 = doc.Windows(1) wnd1.WindowState = eWS_Maximized wnd1.Activate wnd1.ResultsWindow.Expanded = True ' create the sub windows Else ' get the size of the MDI client area mdi_height = Application.MDIMaxHeight mdi_width = Application.MDIMaxWidth mdi_top = 0 mdi_left = 0 ' create the 3 new windows Set wnd1 = doc.Windows(1) Set wnd2 = doc.NewWindow Set wnd3 = doc.NewWindow Set wnd4 = doc.NewWindow ' position the first window and show just the curves using the Show command wnd1.WindowState = eWS_Normal wnd1.WindowHeight = mdi_height/2 wnd1.WindowWidth = mdi_width/2 wnd1.WindowLeft = mdi_left wnd1.WindowTop = mdi_top wnd1.ResultsWindow.Expanded = False wnd1.SetLayerVisible( "features", True ) wnd1.SetLayerVisible( "curves", True ) wnd1.Hide eSH_all wnd1.Show eSH_stock wnd1.Show eSH_curves wnd1.SetView eVT_Top ' position the second window and show just the features using the Show command wnd2.WindowState = eWS_Normal wnd2.WindowHeight = mdi_height/2 wnd2.WindowWidth = mdi_width/2 wnd2.WindowLeft = mdi_left + wnd1.WindowWidth wnd2.WindowTop = mdi_top wnd2.ResultsWindow.Expanded = False wnd2.SetLayerVisible( "features", True ) wnd2.SetLayerVisible( "curves", True ) wnd2.Hide eSH_all wnd2.Show eSH_stock wnd2.Show eSH_features wnd2.Select "fc1", True, True wnd2.Select "pb1_batwings", True, False wnd2.SetView eVT_Isometric ' position the third window and show just the curves using layers wnd3.WindowState = eWS_Normal wnd3.WindowHeight = mdi_height/2 wnd3.WindowWidth = mdi_width/2 wnd3.WindowLeft = mdi_left wnd3.WindowTop = mdi_top + wnd1.WindowHeight wnd3.ResultsWindow.Expanded = False wnd3.Show eSH_all wnd3.SetLayerVisible( "features", False ) wnd3.SetLayerVisible( "curves", True ) wnd3.SetView eVT_Top ' position the fourth window and show just the features using layers wnd4.WindowState = eWS_Normal wnd4.WindowHeight = mdi_height/2 wnd4.WindowWidth = mdi_width/2 wnd4.WindowLeft = mdi_left + wnd1.WindowWidth wnd4.WindowTop = mdi_top + wnd1.WindowHeight wnd4.ResultsWindow.Expanded = False wnd4.Show eSH_all wnd4.SetLayerVisible( "features", True ) wnd4.SetLayerVisible( "curves", False ) wnd4.SetView eVT_Isometric ' run toolpaths in the second window and make it active wnd2.SimToolpath wnd2.Activate End If End Sub Public Sub AddLayersForTest Dim doc As FMDocument Dim feature_layer As FMLayer Dim curve_layer As FMLayer Dim list As FMModels Dim model As FMModel Set doc = ActiveDocument Set feature_layer = doc.Layers( "features") Set curve_layer = doc.Layers( "curves") ' add the "features" and "curves" layers if they don't exist If( feature_layer Is Nothing And curve_layer Is Nothing) Then Set feature_layer = doc.AddLayer ( "features") Set list = doc.Features For Each model In list feature_layer.AddModel model Next model Set curve_layer = doc.AddLayer ( "curves") Set list = doc.Curves For Each model In list curve_layer.AddModel model Next model End If End Sub