⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.frm

📁 CATIA二次开发
💻 FRM
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "comdlg32.ocx"
Begin VB.Form Form1 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "视图和文件操作"
   ClientHeight    =   3225
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   1830
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   3225
   ScaleWidth      =   1830
   StartUpPosition =   3  '窗口缺省
   Begin MSComDlg.CommonDialog CommonDialog1 
      Left            =   1350
      Top             =   0
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin VB.CommandButton cmdExit 
      Caption         =   "退出(&X)"
      Height          =   510
      Left            =   225
      TabIndex        =   3
      Top             =   2520
      Width           =   1365
   End
   Begin VB.CommandButton cmdSave 
      Caption         =   "另存为(&S)"
      Height          =   510
      Left            =   225
      TabIndex        =   2
      Top             =   1620
      Width           =   1365
   End
   Begin VB.CommandButton cmdViewer 
      Caption         =   "视图操作(&V)"
      Height          =   510
      Left            =   225
      TabIndex        =   1
      Top             =   945
      Width           =   1365
   End
   Begin VB.CommandButton cmdOpen 
      Caption         =   "打开文件(&O)"
      Default         =   -1  'True
      Height          =   510
      Left            =   225
      TabIndex        =   0
      Top             =   225
      Width           =   1365
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub cmdExit_Click()
    Unload Me
End Sub

' 打开文档
Private Sub cmdOpen_Click()
    
    On Error Resume Next
    
    CommonDialog1.Filter = "零件文件|*.CATpart"
    CommonDialog1.ShowOpen
    
    If CommonDialog1.FileName <> "" Then
        InitCATIAPart False, CommonDialog1.FileName
    End If
    
    On Error GoTo 0
    
End Sub

' 保存文档
Private Sub cmdSave_Click()
    
    If MsgBox("要保存文件并关闭吗?", vbYesNo) = vbYes Then
        On Error Resume Next
        CommonDialog1.Filter = "零件文件|*.CATPart"
        CommonDialog1.ShowSave
        
        If oPartDoc.FullName = CommonDialog1.FileName Then
            oPartDoc.Save
        Else
            If Dir(CommonDialog1.FileName) <> "" Then
                Kill (CommonDialog1.FileName)
            End If
            oPartDoc.SaveAs CommonDialog1.FileName
        End If
        oPartDoc.Close
        On Error GoTo 0
    End If
    
End Sub

' 视图操作
Private Sub cmdViewer_Click()
    
    Dim myViewer As Viewer3D
    
    ' 获得当前活动视图
    Set myViewer = CATIA.ActiveWindow.ActiveViewer
    myViewer.RenderingMode = catRenderShading
    
    ' 摄像机总数
    MsgBox oPartDoc.Cameras.Count
    
    ' 扫描所有的摄像机
    Dim i As Integer
    Dim myCam3d As Camera3D
    For i = 1 To oPartDoc.Cameras.Count
        Set myCam3d = oPartDoc.Cameras.Item(i)
        
        ' 改变当前的活动视图
        myViewer.Viewpoint3D = myCam3d.Viewpoint3D
        
        myViewer.Reframe
        myViewer.ZoomIn
        myViewer.Update
        MsgBox myCam3d.Name
    Next

End Sub

Private Sub Form_Load()
    Me.Move Screen.Width - Me.Width, Screen.Height - Me.Height
    MakeMeOnTop Me.hwnd
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -