车辆工程专业CATIA V5 自动化中英文对照外文翻译文献

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

中英文资料对照外文翻译文献综述附件1:外文翻译译文
CATIA V5 的自动化
CATIA V5的自动化和脚本:
在NT 和Unix上:脚本允许你用宏指令以非常简单的方式计划CATIA。

CATIA 使用在MS –VBScript中(V5.x中在NT和UNIX3.0 )的共用部分来使得在两个平台上运行相同的宏。

在NT 平台上:自动化允许CATIA像Word/Excel或者Visual Basic程序那样与其他外用分享目标。

ATIA 能使用Word/Excel对象就像Word/Excel能使用CATIA 对象。

在Unix 平台上:CATIA将来的版本将允许从Java分享它的对象。

这将提供在Unix 和NT 之间的一个完美兼容。

CATIA V5 自动化:介绍(仅限NT)
自动化允许在几个进程之间的联系:
CATIA V5 在NT 上:接口COM:Visual Basic 脚本(对宏来说),Visual Basic 为应用(适合前:Word/Excel ),Visual Basic。

COM(零部件目标模型)是“微软“标准于几个应用程序之间的共享对象。

Automation 是一种“微软“技术,它使用一种解释环境中的COM对象。

ActiveX 组成部分是“微软“标准于几个应用程序之间的共享对象,即使在解释环境里。

OLE(对象的链接与嵌入) 意思是资料可以在一个其他应用OLE的资料里连结并且可以被编辑的方法(在适当的位置编辑)。

在VBScript,VBA和Visual Basic之间的差别:
Visual Basic(VB) 是全部的版本。

它能产生独立的计划,它也能建立ActiveX 和服务器。

它可以被编辑。

VB中提供了一个补充文件名为“在线丛书“(VB的5.0)VBA(应用的Visual Basic)是一个Visual Basic的子集。

VBA是在诸如Word,Excel或CATIA的应用托管。

它提供了一个用编辑器,调试器,一个帮助对象查看器和完整的环境。

该<TOOLS>+< REFERENCE>菜单允许申报使用的对象库。

这使得可以访问结果和对象浏览器。

VBScript(Visual Basic脚本)是一个VBA的子集。

简单的语言解释基本法可以调用CATIA对象。

没有类型被使用。

系统动态地尝试调用方法和对象的属性。

(后期绑定通过他们的IDispatch接口调用对象)。

支持的语言
CATIA 支持的语言是:
CATScript :它是在V5的脚本语言,直到包容V5R7。

从V5R8,它变得过时,并建议使用MS VBScript 或MS VBA 。

MS VBScript:它是从V5R8首先使用的语言,唯一的解决方案是允许有一个在NT和UNIX可移植的脚本。

MS - VBScript不同于CATScript的是,这个概念在模糊地声明一个X变量为Y不存在。

MS -VBA:VBA是一个集成到CATIA和专用于VB的开发环境,但只在NT上。

MS - VBA不同于MS- VBScript的是编程的舒适性和实现简单图形界面的应用可能性。

面板ActiveX可以加入一个宏,但是只在NT 上。

如“Scripting.FileSystemObject“的其他服务被称为“CreateObject“,并只在NT中可用。

对象类型的声明记录在宏里(即使它不是在VBScript中使用),但它可以帮助你(在VB中与在NT上填写)计划你未来的应用。

CATIA V5的文件扩展名链接
在CATIA V5中双击打开Windows资源管理器的“。

CATPart“文件。

在NT上,如果没有运行CATIA V5,它会自动启动。

CATIA V5的脚本功能
在过程中的应用:
这是在CATIA菜单的工具+宏中进行。

当宏运行时,CATIA停用。

你不能在两个调用间存储一个宏变量。

使用VBScript(微软)和VBA访问Windows NT和使用VBScript(Winsoft)访问Unix 。

输出过程中的应用(仅限NT)
这基于自动化。

一个外部过程可以调用CATIA,创建或修改几何,解码,测量或试验CATIA。

CATIA仍然运行。

对于应用程序的每个动作,我们要检查是否CATIA 在良好的状态同步两个进程。

这种应用可以被发展在:
Visual Basic
Windows Scripting Host(VBScript,JScript),Windows Explorer HTML(VBScript,JScript)或者任何其他COM 应用。

在将来,V5自动化对象的Java 封装也将被提供。

这将促使在NT和基于Java的Unix上应用软件的开发,无论是在输入进程和输出进程。

宏进程
我们在加工过程中调用它,因为该脚本的解释在与CATIA相同的过程里进行。

一个列表显示了可用的宏。

我们可以运行,编辑,重命名或删除现有的脚本,或创建一个新的。

上述小组建议的脚本库的列表是可以通过对库的一个窗口进行修改的。

利用CATIA的Visual Basic编辑器,我们可以编辑现有的宏或创建一个新的,插入图形形式,调试和运行VBA项目。

对话框的界面“工具+宏+宏...“允许选择一个宏(一个宏目录或一个VBA项目)或一个我们希望工作的文档库上。

从这个窗口,我们可以关闭已打开的库,开放一个库,或建立一个库。

库是按类型显示(目录,VBA项目)。

每库类型支持不同的语言。

VBA 只支持语言MS -VBA,当在一个目录里时,而在目录中,我们可以写在MS- VBScript或在CATScript。

录制宏
该记录的VBA面板允许我们选择将记录的容器,使用的语言和宏的名字被记录。

所录制的脚本的语法是要根据不同的菜单中选择。

录制宏生成一个对应创建或修改对象的脚本再记录序列里。

停止录音后,我们可以存储,编辑重放这个脚本(称为宏)。

作为一项规则,记录一个宏可以帮助你学习如何编程的东西。

运行宏
CATIA一启动,你就能执行宏:CNEXT -macro E:\Users\Macros\MacroToRun.CATScript。

你可以在批处理模式下启动宏来执行CATIA:CNEXT -batch -macro
E:\Users\Macros\MacroToRun.CATScript。

你可以以交互方式从“宏“菜单中运行宏,你可以以交互方式从一个工具栏图
标中运行宏。

来自另一个宏的宏的实行
CATIA V5R9通过自动化功能提供能力从另一个宏中执行宏。

该功能可以让用户
调用另一个脚本函数,在另一个宏库中,可能在另外一种脚本语言编写。

一个支持
ENUM CATSys库类型是用来让开发人员介绍库那种要调用的函数包含所在。

(来自VBScript的例子)
调用一个在确定的“E:\宏\数学”目录库里的新增功能,文件中的“整数
Math.catvba“,一种将写成:
Dim args2(1)
args2(0) = 3
args2(1) = 2
Dim addResult
addResult = CATIA.SystemService.ExecuteScript ( "E:\Macros\Math", catScriptLibraryTypeDirectory, "IntegerMath.catvbs", "Add", args2 ) MsgBox addResult
要调用一个PrintReport(),在一个确定的子的“E:\零件\ Part1.CATPart“V5
文档库文件中的“Statistics.catvba“,一种将写成:
Dim args()
CATIA.SystemService.ExecuteScript
"E:\Parts\Part1.CATPart",catScriptLibraryTypeDocument,"Statistics.ca
tvbs", "PrintReport", args
在工具条里增加一个作为命令的宏
选择你要添加自定义的工具和宏命令标签页的宏,拖放宏的名称到你想要的工
具栏,要选择另一个默认的图标,单击显示属性。

宏选项界面
对话框“工具+选项+宏“的面板允许根据语言选择,编辑器将被推出来编辑宏,
并且指定外部类库来考虑到脚本回放。

Whith新接口,运行时间意见的全部typelibs
V5被自动考虑到。

除运行时间意见(例如优于)之外,这种选择只为宣布typelibs 服
务。

运行输出进程方案(只在NT上)
该脚本是在另一个运行在另一个进程中的应用程序中运行,例如:Visual Basic VBA(在 Excel 或Word),使用VBScript或JavaScript的WSH(Windows脚本主机),使用VBScript或JavaScript的HTML,CATIA可以从任何其他COM应用编写脚本。

从VBA或者Visual Basic运行输出进程
VBA和Visual Basic提供有用的工具:对这来说,你可以声明所有由Dassault Systèmes提供的类型库文件(*. TLB)。

该类型库文件包含所有对象,方法和公开对象属性的声明。

类型定义允许的类型检查和“早期绑定“帮助完成给你所有属性和对象的方法,给你一个方法的参数类型。

浏览器对象描述了全部的出口对象。

下面是从VBA或Visual Basic来启动CATIA V5的语句。

如果CATIA已经运行:
[...]
Dim CATIA as Object
Set CATIA = GetObject(,“CATIA.Application”)
[...] 第一个参数。

为空白
如果CATIA没运行:
[...]
Dim CATIA as Object
Set CATIA = CreateObject(“CATIA.Application”)
CATIA.Visible = True
[...] 这个宏开始CATIA
如果类型库INFITF.tbl被引用,我们可以作为INFITF.Application声明CATIA。

使用Windows脚本宿主来运行输出进程
WSH支持用不同语言编写,如VBScript和JavaScript脚本。

你可以使用标准的编辑器来编写应用程序。

如果你的程序失败,你将可以使用Windows开发环境。

它可以在Visual Basic开发应用程序,然后评论类型和通过WSH运行它。

要运行一个VBScript(*. vbs的)或JavaScript(*. js)文件,你可以使用CScript或Wscript命令。

通常情况下,wscript.exe已经与这些扩展名相关。

在Windows脚本宿主的VBScript
你可以在一个简单的ASCII文本文件中用扩展名“vbs“为Visual Basic脚本写一个VBScript程序。

在WSH,对象Wscript也提供了GetObject和CreateObject。

下面的代码启动CATIA V5:
On Error Resume Next
Set CATIA = Wscript.GetObject(,"CATIA.Application")
If Err.Number <> 0 Then
Set CATIA = Wscript.CreateObject("CATIA.Application")
CATIA.Visible = True
End If
BoltVBSript.vbs例子:看一看源码。

运行BoltVBSript.vbs例子,你可以双击它。

要运行一个命令提示符窗口的一个例子,你也可以使用:Cscript BoltVBScript.vbs或者wscript BoltVBScript.vbs
在Windows脚本宿主的JavaScript
运用如VBScript中相同的方式,你可以在一个简单的ASCII文本文件中用扩展“js“为JavaScript写一个JavaScript 程序。

在WSH,对象Wscript也提供了GetObject和CreateObject。

下面的代码启动CATIA V5。

CATIA = WScript.GetObject(,"CATIA.Application");
if ( CATIA == null) {
CATIA = WScript.CreateObject("CATIA.Application");
CATIA.Visible = true;}
BoltJavaSript.js例子
看一看源码。

要运行BoltJavaScript.js 例子,你可以双击它。

要运行一个命令提示符窗口的一个例子,你也可以使用:Cscript BoltJavaScript.js 或者wscript BoltJavaScript.js 。

HTML输出进程(仅NT & Microsoft Internet Explorer )
在HTML中,你可以包括VBScript或JavaScript例程。

微软Explorer提供ActiveXObject(在JavaScript)和CreateObject(VBScript中)函数来启动自动化服务器。

因此,它可以用这种方式调用CATIA V5。

您可以访问Microsoft Development 环境来调试应用程序。

您可以通过“Script Debugger”“ Open”来从Explorer环境启动“Microsoft Development“。

在HTML使用VBScript的输出过程
在Microsoft Internet Explorer中载入“BoltVBScript.html“的例子。

您可以点击“螺栓“按钮,在CATIA V5创建一个螺栓。

您可以通过菜单<View>+<Source>查看源代码。

由于安全原因,运行脚本的一些警告信息,可能会出现不同的配置并且要是服务器是本地或者不是。

在HTML使用Java脚本的输出进程
在Microsoft Internet Explorer中载入“BoltJavaScript.html“的例子。

您可以点击“螺栓“按钮来在CATIA V5创建一个螺栓。

你能通过<View>+<Source>菜单查看源码。

CATIA V5的脚本
介绍
公开对象的体系结构,CATIA V5公开模式,使得在CATIA的工作台可以创建文档,零部件,表面,线框,产品图纸和许多其他对象。

那些公开对象提供属性和方法来读取和修改现有的所有对象。

在交互出现的所有对象,可以从宏或输出进程方案编写脚本。

关于对象,集合,属性和方法
如Visual Basic脚本语言依靠的对象。

与CATIA,文件,窗口,浏览器,配件,素描,垫...甚至直线和曲线表示为Visual Basic对象。

对象:一个实体:例如:文件,填充,线。

属性:一个对象的特点。

DocName = CATIA.ActiveDocument.FullName
方法:有一个对象的行动
CATIA.ActiveDocument.SaveAs yNewName
集合:对象列表。

CATIA 集合指数从1开始,而不是0:
For i=1 to CATIA.Documents.Count
msgbox CATIA.Documents.Item(i).Name
Next
我们还可以访问该对象的名称集合:
例子: msgbox CATIA.Documents.Item(" Product1.CATProduct" ). Name
我们用方法添加对象到集合:
set myPartDoc = CATIA.Documents.add("Part")
关于继承和集中
在对象之间有两种关系:继承可以帮助你专注对象,而收集共同属性和方法,集中是一个对象到包含另一个的能力。

在下面的图中,应用程序聚合Documents集合。

该PartDocument对象是一个专门的文件,专于它继承属性的部件和文档对象的方法。

脚本基础设施功能概览
CATIA应用对象集合两个主要的集合对象:文件和Windows。

因为多样性是设置为*文件收集了任意数量的文件。

Document对象是一个抽象的对象,只有其派生类型可以被创造,这是PartDocument,ProductDocument和DrawingDocument。

在Windows收集了数量的Window(S)和它们本身并集了一个并集任意数量浏览器的浏览器。

窗口和文档对象之间的二进制关联意味着该文档对象是Window对象的上级。

应用程序和文档
应用程序是全部CATIA 宏的根对象。

这对应于CATIA的框架窗口。

CATIA应用始终为进程宏命名CATIA。

Documents集合提供一个方法来添加一个新的文件,另一个是打开现有文件。

一个文档可以是一个零件文档,产品文档或绘图文档。

每个文档提供它自己的方法来保存或自救。

附件2:外文原文(复印件)
CATIA V5 Automation
CATIA V5 Automation & Scripting : Presentation
On both NT and UNIX:The scripting allows you to program CATIA in a very simple way with macros on both NT and UNIX platforms.CATIA Use the common part on MS-VBScript (v5.x on NT and v3.0 on Unix) to have the same macros running on both platforms.
On NT platforms:Automation allows CATIA to share objects with other external applications such as Word/Excel or Visual Basic programs.CATIA can use the Word/Excel objects as well as Word/Excel can use the CATIA Objects.
On UNIX platforms:A future version of CATIA will allow to share its objects from Java. This will provide a full compatibility between UNIX and NT.
CATIA V5 Automation: Presentation (NT only)
Automation allows communication between several process.
CATIA V5 On NT:Interfaces COM:Visual Basic Script (for Macros),Visual Basic For Applications (for ex:Word/Excel),Visual Basic
COM (Component Object Model) is the “Microsoft” standard to share objects between several applications.
Automation is a “Microsoft”technology to use COM objects in an interpreted environment.
ActiveX component is a “Microsoft” standard to share objects between several applications even in an interpreted environment.
OLE (Object Linking and Embedding) means that the document can be linked in the document of an other application OLE and can be edited in that other application (In place editing).
Differences between VBScript, VBA and Visual Basic
Visual Basic(VB) is the full version:It can generate independent
programs,It can also create ActiveX and Servers.It can be compiled. VB provides an added documentation called “Books on line” (VB 5.0)。

VBA (Visual Basic for Applications) is a subset of Visual Basic,VBA is hosted in applications such as Word, Excel or CATIA. It provides a complete environment with an Editor, a debugger, a Help Object Viewer and Completion.
The <TOOLS>+<REFERENCE> menu allows to declare the object library used.This gives access to the completion and the object browser.VBScript(Visual Basic Script) is a subset of VBA.Simple interpreted Basic language Can call CATIA Objects.No type is used. The system tries dynamically to call methods and properties of objects. (Late binding calling objects through their IDispatch interface).
Supported Languages
The languages supported by CATIA are:
CATScript : It is the language of the scripting in V5 until the inclusive V5R7. From the V5R8, it becomes deprecated and it is advised to use rather MS VBScript or MS VBA.
MS-VBScript : It is the language to use first and foremost from the V5R8, and the only solution allowing to have a portability of the scripts in NT and UNIX. MS-VBScript differs from CATScript by the fact that the notion to declare a variable by Dim X As Y does not exist.
MS-VBA : VBA is an environment of development integrated into CATIA and dedicated to VB but only on NT. MS-VBA differs from MS-VBScript by the comfort of programming and the possibility of realizing simple application with a graphic interface.
ActiveX with panels can be added in a macro but only on NT.
Other services such as “Scripting.FileSystemObject” are called with “CreateObject” and are available only on NT.
The declaration of object types is recorded in the macro (even if it is not used in VBScript) but it can help you (with the completion in VB on NT) to program your future application.
CATIA V5 Association with file extension
A double-click in Windows Explorer on a ”.CATPart” file opens it in CATIA V5. On NT, If CATIA V5 is not running, it is launched automatically.
In the Windows Explorer, with “As Web page” mode, a thumbnail shows a preview for all CATIA Documents.
CATIA V5 Scripting capabilities
IN process application:This is done from the Tools + Macro in CATIA menu. When the Macro is running, CATIA is deactivated. You cannot store variables in a macro between two calls. Access with VBScript (Microsoft) and VBA on Windows NT, and with VBScript (Winsoft) on Unix.
This is based on AUTOMATION. A foreign process can call CATIA, create or modify geometry, decode, measure or pilot CATIA. CATIA is still running. For each action of the application, we have to check if CATIA is in the good state to synchronize the two processes. This kind of applications can be developed in: Visual Basic,Windows Scripting Host (VBScript , JScript),Windows Explorer HTML (VBScript , JScript)or Any other COM applications.
In the future, a Java encapsulation of the V5 Automation objects will also be provided. This will enable the development of applications on NT and Unix based on Java, both in-process and out-process.
In-Process Macros
We call In-process because the script interpretation is performed in the same process as CATIA。

A list shows the Macro available. We can run, edit, rename or delete existing script, or create a new one.The list of libraries of script proposed into the panel above is modifiable through the window of libraries.
CATIA V5 Visual Basic Editor
With CATIA Visual Basic Editor, We can edit existing macro or create a new one, insert graphic form, debug and run VBA project.
Macro libraries
The interface of the dialog “Tools + Macro + Macros…” allows to choose
a library of macro (a directory of macro or a VBA project) or a document on which we wish to work.
From this window, we can close an already opened library, open a library, or create a library. Libraries are shown by type (directory, VBA project...).Every type of library supports different languages. VBA supports only the language MS-VBA, while in a directory we can write in MS-VBScript or in CATScript.
Recording a Macro
The panel of recording VBA allows to choose the container in which we are going to record, the used language and the name of the macro to be recorded.The syntax of the recorded script is going to differ according to the menu chosen. Recording a Macro generates a script corresponding to the creation or modification of the objects in the recorded sequence. After stopping the recording, we can store,edit or replay this script (called macro). As a rule, recording a macro helps you to learn how to program something。

Running a Macro
You can execute a macro as soon as CATIA is started : CNEXT -macro E:\Users\Macros\MacroToRun.CATScript
You can start CATIA in batch mode to execute a macro:CNEXT -batch -macro E:\Users\Macros\MacroToRun.CATScript
You can run a macro interactively from the “Macro” menu。

You can run a macro interactively from an icon in a toolbar。

Execution of a Macro from another Macro
CATIA V5R9 offers the capability through an Automation function to execute a Macro from another Macro. The function lets the user invoke another scripted function, contained in another macro library, potentially written in another scripting language. A support enum CATSysLibraryType is used to let the developer describe the kind of library the function to call is contained in. (Example from VBScript)。

To call an Add function that is defined in a “E:\Macros\Math” directory library, in a file “IntegerMath.catvbs”, one would write:
Dim args2(1)
args2(0) = 3
args2(1) = 2
Dim addResult
addResult = CATIA.SystemService.ExecuteScript ( "E:\Macros\Math",
catScriptLibraryTypeDirectory, "IntegerMath.catvbs", "Add", args2 )
MsgBox addResult
To call an PrintReport() sub that is defined in a “E:\Parts\Part1.CATPart” V5 document library, in a file “Statistics.catvbs”, one would write:
Dim args()
CATIA.SystemService.ExecuteScript "E:\Parts\Part1.CATPart", catScriptLibraryTypeDocument, "Statistics.catvbs", "PrintReport", args
Adding a Macro as a command in a Toolbar
Select the macro you want to add in Tools + Customize + Commands Tab page + Macros:Drag and Drop the macro nameto the toolbar you wish : To select another icon than the default one, click on Show Properties... Macros Options Interface
The panel of the dialog “Tools + Options + Macros” allows to choose according to the language, the Editor who will be launched to edit a macro, and to specify external typelibs to take into account in the replay of scripts.Whith the new interface, all the typelibs V5 of the runtime view are automatically taken into account. This option serves only for declaring typelibs except runtime view (Excel for example).
Running Out-Process programs (On NT only)
The script is running in another application running in another process, such as:Visual Basic,VBA (in Excel or Word),Using WSH (Windows Scripting
Host) with VBScript or JavaScript,Using HTML with VBScript or JavaScript CATIA can be scripted from any other COM Application.
Running Out-Process from VBA or Visual Basic
VBA and Visual Basic provide useful tools:For this, you can declare all the typelib files (*.tlb) provided by Dassault Systemes.The typelib files contain the declarations of all the objects, methods and properties of the exposed objects.
Running Out-Process from VBA or Visual Basic
Type definition allows type checking and “early binding”.Helpful completion gives you all the properties and methods of an object and gives you the argument types of a method.Browser Object describes all the exported objects
Running Out-Process from VBA or Visual Basic
Here are the statements to launch CATIA V5 from VBA or Visual Basic.
If CATIA is already running :
[...]
Dim CATIA as Object
Set CATIA = GetObject(, “CATIA.Application”)
[...]
If CATIA is not already running :
[...]
Dim CATIA as Object
Set CATIA = CreateObject(“CATIA.Application”)
CATIA.Visible = True
[...]
If the typelib INFITF.tbl is referenced, we can declare CATIA as INFITF.Application.
Bolt from Excel Example
The purpose of this example is to launch CATIA and to create a bolt part from Excel.
In this Example, we will learn : the Visual Basic for Application environment in Excel. how to create a Button in Excel. how to associate a macro to this button.the macro will launch CATIA and create a Bolt.
Bolt from Excel
Have a look on the code:This tries to retrieve CATIA and if not successful starts it.
Dim CATIA As Object
'Get CATIA or start it if necessary.
On Error Resume Next
Set CATIA = GetObject(, "CATIA.Application")
If Err.Number <> 0 Then
Set CATIA = CreateObject("CATIA.Application")
CATIA.Visible = True
End If
On Error GoTo 0
Both functions GetObject and CreateObject are provided by VBA (as well as Visual Basic).
Running Out-Process using the Windows Scripting Host (WSH) WSH enables scripts written in different languages such as VBScript and JavaScript. You can use a standard Editor to write your application. If your program fails, you will be able to use the Windows Development environment.
It is possible to develop an application in Visual Basic, then put the types in comment and run it with WSH. To run a VBScript (*.vbs) or JavaScript (*.js) file, you can use cscript or wscript commands. Usually, wscript.exe is already associated with those extensions.
VBScript under Windows Scripting Host.
You can write a VBScript program in a simple ASCII text file with the extension “.vbs” for Visual Basic Script. Under W SH, GetObject and CreateObject are provided by the object Wscript.The following code launches CATIA V5.
On Error Resume Next
Set CATIA = Wscript.GetObject(,"CATIA.Application")
If Err.Number <> 0 Then
Set CATIA = Wscript.CreateObject("CATIA.Application")
CATIA.Visible = True
End If
BoltVBSript.vbs example
Have a look on the source code.
To run the “BoltVBScript.vbs” example , you can double–click on it.
To run the example on a Command prompt Window you can also use : Cscript BoltVBScript.vbs Or wscript BoltVBScript.vbs
JavaScript under Windows Scripting Host
In the same way as VBScript, you can write a JavaScript program in a simple ASCII text file with the extension “.js” for JavaScript.
Under WSH, GetObject and CreateObject are provided by the object Wscript. The following code launches CATIA V5.
CATIA = WScript.GetObject(,"CATIA.Application");
if ( CATIA == null) {
CATIA = WScript.CreateObject("CATIA.Application");
CATIA.Visible = true;}
BoltJavaSript.js example
Have a look on the source code.
To run the “BoltJavaScript.js” example, you can double–click on it.
To run the example on a Command prompt Window you can also use : Cscript BoltJavaScript.js Or wscript BoltJavaScript.js
Out-Process in HTML (NT & Microsoft Internet Explorer Only) In HTML, you can include VBScript or JavaScript routines.Microsoft explorer provides ActiveXObject (in JavaScript) and CreateObject (in VBScript) functions to Launch Automation Servers.So, it is possible to call CATIA V5 this way.You can access to the Microsoft Development Environment
to debug your Application.You can launch the “Microsoft Development Environment from Explorer by :“Script Debugger”“ Open”
Out-Process in HTML with VBScript
Load the “BoltVBScript.html” example in Microsoft Internet Explorer. You will be able to Click on the “Bolt” button to create a Bolt in CATIA V5. You can view the source code by <View>+<Source> menus. Due to security reasons, some warning messages for running the script, may appear depending on the configuration and if the server is local or not.
Out-Process in HTML with JavaScript
Load the “BoltJavaScript.html” example in Microsoft Internet Explorer. You will be able to Click on the “Bolt” button to create a Bolt in CATIA V5. You can view the source code by <View>+<Source> menus.
About Objects, Collections, Properties and Methods
Scripting languages such as Visual Basic rely on objects. With CATIA, documents, windows, viewers, parts, sketches, pads, …even lines and curves are represented as objects in Visual Basic.
Object: an entity.
Ex: Document, Pad, Line, …
Property: a characteristic of an object.
DocName = CATIA.ActiveDocument.FullName
Method: an action on an object
CATIA.ActiveDocument.SaveAs “MyNewName”
Collection: a list of objects.
The CATIA collections index begins at 1, and not 0 :
For i=1 to CATIA.Documents.Count
msgbox CATIA.Documents.Item(i).Name
Next
We can also access a collection with the name of the object:
Example: msgbox CATIA.Documents.Item("Product1.CATProduct").Name We add objects to the collections with the method add :
set myPartDoc = CATIA.Documents.add("Part")
About Inheritance and Aggregation
There are two kinds of relations between objects : Inheritance helps you to specialize objects while gathering common properties and methods. Aggregation is the ability of an object to contain another one.
In the following diagram, the Application aggregates the Documents collection.The PartDocument object is a specialized document that is dedicated to parts and which inherits the properties and the methods of the Document object.
Scripting Infrastructure features overview
Documents and Windows
The CATIA Application object aggregates two main collection objects : Documents and Windows. The Documents collection aggregates any number of Document(s) since the multiplicity is set to *. The Document object is an abstract object, and only its derived type can actually be created, that is the PartDocument, ProductDocument and DrawingDocument. The Windows collection aggregates number of Window(s), which themselves aggregate one Viewers collection which aggregates any number of Viewer(s).The binary association between the Window and the Document objects means that the Document object is the parent of the Window object.
Infrastructure Object Architecture
These objects are shared by all CATIA products. The root object is the Application, which aggregates or includes Documents and Windows. Application and Document
Application is the Root object for all CATIA macros. This correspond to the CATIA frame window.The CATIA application is always named CATIA for in-process macro. The Documents collection provide a method to Add a new document and another to Open an existing document. A Document can be a
PartDocument, ProductDocument or a DrawingDocument. Each Document provide Its own methods to Save or SaveAs Itself.
Creating and Opening a Document
Creating a new Document :
Dim Doc as Document
Set Doc = CATIA.Documents.Add(“Part”) create a PartDocument
Instead of “Part”, Use “Product” for a Product Document or “Drawing”for a Drawing Document
Opening a new Document :
Dim Doc as Document
Set Doc= CATIA.Documents.Open(“E:\Parts\DocumentToOpen.CATPart”) Both Add and Open functions add the Document in the Documents Collection.。

相关文档
最新文档