VERSION 5.00
Object = "{B97871C2-BB9B-49E7-8FD3-C1201922EDD8}#1.0#0"; "KGAX.ocx"
Begin VB.Form TestForm 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Kompas ActiveX Container"
   ClientHeight    =   7425
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   10365
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   7425
   ScaleWidth      =   10365
   StartUpPosition =   3  'Windows Default
   Begin KGAXLib.KGAX KGAX2D 
      Height          =   5175
      Left            =   5280
      TabIndex        =   17
      Top             =   480
      Width           =   4935
      _Version        =   65536
      _ExtentX        =   8705
      _ExtentY        =   9128
      _StockProps     =   18
   End
   Begin KGAXLib.KGAX KGAX 
      Height          =   5175
      Left            =   240
      TabIndex        =   16
      Top             =   480
      Width           =   4815
      _Version        =   65536
      _ExtentX        =   8493
      _ExtentY        =   9128
      _StockProps     =   18
      DocumentType    =   5
   End
   Begin VB.CommandButton Command14 
      Caption         =   ""
      Height          =   375
      Index           =   1
      Left            =   600
      TabIndex        =   15
      Top             =   0
      Width           =   975
   End
   Begin VB.CommandButton Command15 
      Caption         =   ""
      Height          =   375
      Index           =   0
      Left            =   6240
      TabIndex        =   14
      Top             =   0
      Width           =   975
   End
   Begin VB.CommandButton Command13 
      Caption         =   "Stop "
      Height          =   375
      Index           =   0
      Left            =   1800
      TabIndex        =   13
      Top             =   0
      Width           =   615
   End
   Begin VB.CommandButton Command11 
      Caption         =   "Orientation"
      Height          =   375
      Index           =   0
      Left            =   3480
      TabIndex        =   12
      Top             =   5880
      Width           =   1455
   End
   Begin VB.CommandButton Command9 
      Caption         =   "Rotate"
      Height          =   375
      Index           =   0
      Left            =   3480
      TabIndex        =   11
      Top             =   6960
      Width           =   1455
   End
   Begin VB.CommandButton Command7 
      Caption         =   "Move"
      Height          =   375
      Index           =   0
      Left            =   240
      TabIndex        =   10
      Top             =   6960
      Width           =   1455
   End
   Begin VB.CommandButton Command8 
      Caption         =   "Panorama"
      Height          =   375
      Index           =   0
      Left            =   1920
      TabIndex        =   9
      Top             =   6960
      Width           =   1455
   End
   Begin VB.CommandButton Command12 
      Caption         =   "Stop "
      Height          =   375
      Index           =   3
      Left            =   8040
      TabIndex        =   8
      Top             =   0
      Width           =   615
   End
   Begin VB.CommandButton Command6 
      Caption         =   "Run command"
      Height          =   375
      Index           =   0
      Left            =   5160
      TabIndex        =   7
      Top             =   5880
      Width           =   1455
   End
   Begin VB.CommandButton Command5 
      Caption         =   "Shaded"
      Height          =   375
      Left            =   3480
      TabIndex        =   4
      Top             =   6480
      Width           =   1455
   End
   Begin VB.CommandButton Command4 
      Caption         =   "HiddenRemoved"
      Height          =   375
      Index           =   0
      Left            =   1920
      TabIndex        =   3
      Top             =   6480
      Width           =   1455
   End
   Begin VB.CommandButton Command3 
      Caption         =   "Wireframe"
      Height          =   375
      Index           =   0
      Left            =   240
      TabIndex        =   2
      Top             =   6480
      Width           =   1455
   End
   Begin VB.CommandButton Command2 
      Caption         =   "Show all"
      Height          =   375
      Left            =   1920
      TabIndex        =   1
      Top             =   5880
      Width           =   1455
   End
   Begin VB.CommandButton Command1 
      Caption         =   "Run command"
      Height          =   375
      Left            =   240
      TabIndex        =   0
      Top             =   5880
      Width           =   1455
   End
   Begin VB.Label Label2 
      Caption         =   "2D"
      Height          =   255
      Left            =   5160
      TabIndex        =   6
      Top             =   120
      Width           =   1335
   End
   Begin VB.Label Label1 
      Caption         =   "3D"
      Height          =   255
      Left            =   240
      TabIndex        =   5
      Tag             =   "3D"
      Top             =   120
      Width           =   1215
   End
   Begin VB.Line Line1 
      X1              =   240
      X2              =   9960
      Y1              =   6360
      Y2              =   6360
   End
End
Attribute VB_Name = "TestForm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub Command1_Click()
    Dim iKompasObject As Application
    Set iKompasObject = KGAX.GetKompasObject
    If Not iKompasObject Is Nothing Then
 '############################################################################
        Dim iDocument3D As Document3D
        Set iDocument3D = iKompasObject.ActiveDocument3D
        If Not iDocument3D Is Nothing Then
                Dim part As ksPart
                Set part = iDocument3D.GetPart(pNew_Part) '  
                If Not part Is Nothing Then
                    Dim entitySketch As ksEntity
                    Set entitySketch = part.NewEntity(o3d_sketch)
                    If Not entitySketch Is Nothing Then
                        '   
                        Dim sketchDef As ksSketchDefinition
                        Set sketchDef = entitySketch.GetDefinition()
                        If Not sketchDef Is Nothing Then
                        
                            '     XOY
                            Dim basePlane As ksEntity
                            Set basePlane = part.GetDefaultEntity(o3d_planeXOY)
                            sketchDef.SetPlane basePlane '   XOY   
                            sketchDef.angle = 45         '   
                            entitySketch.Create          '  
            
                            '   
                            Dim sketchEdit As ksDocument2D
                            Set sketchEdit = sketchDef.BeginEdit()
                              '    - 
                              sketchEdit.ksLineSeg 50, 50, -50, 50, 1
                              sketchEdit.ksLineSeg 50, -50, -50, -50, 1
                              sketchEdit.ksLineSeg 50, -50, 50, 50, 1
                              sketchEdit.ksLineSeg -50, -50, -50, 50, 1
                            sketchDef.EndEdit   '   
      
                            Dim entityExtr As ksEntity
                            Set entityExtr = part.NewEntity(o3d_baseExtrusion)
                            If Not entityExtr Is Nothing Then
                            
                                '     
                                Dim extrusionDef As ksBaseExtrusionDefinition
                                Set extrusionDef = entityExtr.GetDefinition '    
                                If Not extrusionDef Is Nothing Then
                                    extrusionDef.directionType = dtNormal            '  
                                    extrusionDef.SetSideParam True, etBlind, 200, 0, False
                                    extrusionDef.SetThinParam True, dtBoth, 10, 10   '     
                                    extrusionDef.SetSketch entitySketch              '   
                                    entityExtr.Create                                '  
                                    
                                    Set extrusionDef = Nothing
                                Else
                                    MsgBox "BAD extrusionDef"
                                End If
                    
                                Set entityExtr = Nothing
                            Else
                                MsgBox "BAD entityExtr"
                            End If
                            
                            Set sketchDef = Nothing
                        Else
                            MsgBox "BAD sketchDef"
                        End If
                    Set entitySketch = Nothing
                    Else
                        MsgBox "BAD entitySketch"
                    End If
                    
                 Set part = Nothing
                Else
                    MsgBox "BAD Part"
                End If
            Set iDocument3D = Nothing
        Else
            MsgBox "BAD Document3D"
        End If
    
 '############################################################################
        Set iKompasObject = Nothing
    Else
        MsgBox "BAD KompasObject"
    End If
End Sub

Private Sub Command11_Click(Index As Integer)
  KGAX.OrientationDocument
End Sub

Private Sub Command12_Click(Index As Integer)
  KGAX2D.StopCurrentProcess True
End Sub

Private Sub Command13_Click(Index As Integer)
  KGAX.StopCurrentProcess True
End Sub

Private Sub Command14_Click(Index As Integer)
  KGAX.StopCurrentProcess False
End Sub

Private Sub Command15_Click(Index As Integer)
  KGAX2D.StopCurrentProcess False
End Sub

Private Sub Command16_Click(Index As Integer)

End Sub

Private Sub Command2_Click()
    KGAX.ZoomEntireDocument
End Sub

Private Sub Command3_Click(Index As Integer)
    KGAX.Document3DDrawMode = vt_WireframeMode
End Sub

Private Sub Command4_Click(Index As Integer)
    KGAX.Document3DDrawMode = vt_HiddenRemovedMode
End Sub

Private Sub Command5_Click()
    KGAX.Document3DDrawMode = vt_ShadedMode
End Sub

Private Sub Command6_Click(Index As Integer)
    Dim iKompasObject As Application
    Set iKompasObject = KGAX2D.GetKompasObject
    If Not iKompasObject Is Nothing Then
 '############################################################################
        Dim iDocument2D As Document2D
        Set iDocument2D = iKompasObject.ActiveDocument2D
        If Not iDocument2D Is Nothing Then
            iDocument2D.ksLineSeg 100, 100, 200, 200, 1
            iDocument2D.ksLineSeg 200, 100, 100, 200, 0
            
            Set iDocument2D = Nothing
        Else
            MsgBox "BAD Document2D"
        End If
    
 '############################################################################
        Set iKompasObject = Nothing
    Else
        MsgBox "BAD KompasObject"
    End If
End Sub

Private Sub Command7_Click(Index As Integer)
    KGAX.MoveViewDocument
End Sub

Private Sub Command8_Click(Index As Integer)
    KGAX.PanoramaViewDocument
End Sub


Private Sub Command9_Click(Index As Integer)
   KGAX.RotateViewDocument
End Sub


Private Sub KGAX2D_OnKgMouseDown(ByVal nButton As Integer, ByVal nShiftState As Integer, ByVal x As Long, ByVal y As Long, proceed As Boolean)

    If nButton <> 2 Then
        proceed = True
    Else
        MsgBox "KgMouseDown"
        proceed = False
    End If
End Sub


Private Sub KGAX_OnKgStopCurrentProcess()
  MsgBox "KGAX_OnKgStopCurrentProcess"
End Sub
