CATIA VBA生成Ditto教程

原文链接

生成前
生成后
Option Explicit
' COPYRIGHT DASSAULT SYSTEMES 2003

' ***********************************************************************
'   Purpose:      This macro allows you to instantiate a ditto in 
'                      a view from a detail view
'   Author: 
'   Languages:   VBScript
'   Locales:       English 
'   CATIA Level: V5R11
' ***********************************************************************

Sub CATMain()

    ' Set the CATIA popup file alerts to False
    ' It prevents to stop the macro at each alert during its execution
    CATIA.DisplayFileAlerts = False

    ' Optional: allows to find the sample wherever it's installed
    dim sDocPath As String 
    sDocPath=CATIA.SystemService.Environ("CATDocView")
    If (Not CATIA.FileSystem.FolderExists(sDocPath)) Then
      Err.Raise 9999,,"No Doc Path Defined"
    End If

    ' Open the drawing document
    Dim oDrawing As DrawingDocument
    Set oDrawing = CATIA.Documents.Open(sDocPath & _
             "\online\CAAScdDriUseCases\samples\CAADriInstantiateDittoSource.CATDrawing")
    
    ' Retrieve the sheets collection of the drawing document
    Dim oSheets As DrawingSheets
    Set oSheets = oDrawing.Sheets
    
    ' Retrieve the sheet where the detail view will be instantiated
    Dim oSheet As DrawingSheet
    Set oSheet = oSheets.Item("Sheet.1")
    
    ' Retrieve the view where the detail view will be instantiated
    Dim oView As DrawingView
    Set oView = oSheet.Views.Item("View.3")
    oView.Activate
    
    ' Retrieve the detail sheet containing the detail view to be instantiated
    Dim oDetailSheet As DrawingSheet
    Set oDetailSheet = oSheets.Item("Sheet.2 (Detail)")
    
    ' Retrieve the detail view to be instantiated
    Dim oDetailView As DrawingView
    Set oDetailView = oDetailSheet.Views.Item("DrwDetail.1")
    
    ' Indicate the ditto location
    Dim ReturnStatus As String
    Dim iDittoCoordinates(1)
    Dim oDraw
    Set oDraw = oDrawing
    ReturnStatus = oDraw.Indicate2D("Indicate the ditto location", iDittoCoordinates)
       
    ' Retrieve the drawing components collection of the target drawing view
    Dim o2DComponents As DrawingComponents
    Set o2DComponents = oView.Components
    
    ' Create the ditto
    Dim o2DComponent As DrawingComponent
    Set o2DComponent = o2DComponents.Add(oDetailView, iDittoCoordinates(0), iDittoCoordinates(1))
    
    ' Retrieve the modifiable text of the ditto
    Dim oText As DrawingText
    Set oText = o2DComponent.GetModifiableObject(1)
    
    ' Modify the modifiable text value
    Dim ReturnValue As String
    ReturnValue = InputBox( "Enter a value", "", "New Value For Text" )
    oText.Text = ReturnValue

    ' Clear the variables
    Set oText = Nothing
    Set o2DComponent = Nothing
    Set o2DComponents = Nothing
    Set oDraw = Nothing
    Set oDetailView = Nothing
    Set oDetailSheet = Nothing
    Set oView = Nothing
    Set oSheet = Nothing
    Set oSheets = Nothing
    Set oDrawing = Nothing
    
End Sub

QR Code
微信扫一扫,欢迎咨询~

联系我们
武汉格发信息技术有限公司
湖北省武汉市经开区科技园西路6号103孵化器
电话:155-2731-8020 座机:027-59821821
邮件:tanzw@gofarlic.com
Copyright © 2023 Gofarsoft Co.,Ltd. 保留所有权利
遇到许可问题?该如何解决!?
评估许可证实际采购量? 
不清楚软件许可证使用数据? 
收到软件厂商律师函!?  
想要少购买点许可证,节省费用? 
收到软件厂商侵权通告!?  
有正版license,但许可证不够用,需要新购? 
联系方式 155-2731-8020
预留信息,一起解决您的问题
* 姓名:
* 手机:

* 公司名称:

姓名不为空

手机不正确

公司不为空