毕业设计论文外文资料翻译1_第1页
毕业设计论文外文资料翻译1_第2页
毕业设计论文外文资料翻译1_第3页
毕业设计论文外文资料翻译1_第4页
毕业设计论文外文资料翻译1_第5页
已阅读5页,还剩15页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、 南 京 理 工 大 学 紫 金 学 院毕业设计(论文)外文资料翻译系: 机械系 专 业: 车辆工程专业 姓 名: 宋磊春 学 号: 070102234 (用外文写)外文出处: EDU_E_CAT_VBA_FF_V5R9 附 件: 1.外文资料翻译译文;2.外文原文。 指导教师评语: 签名: 2011 年 3 月 25日附件1:外文资料翻译译文CATIA V5 的自动化CATIA V5的自动化和脚本:在NT 和Unix上:脚本允许你用宏指令以非常简单的方式计划CATIA。CATIA使用在MS VBScript中(V5.x中在NT和UNIX3.0 )的共用部分来使得在两个平台上运行相同的宏。 在

2、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(零部件目标

3、模型)是“微软“标准于几个应用程序之间的共享对象。Automation 是一种“微软“技术,它使用一种解释环境中的COM对象。 ActiveX 组成部分是“微软“标准于几个应用程序之间的共享对象,即使在解释环境里。 OLE(对象的链接与嵌入) 意思是资料可以在一个其他应用OLE的资料里连结并且可以被编辑的方法(在适当的位置编辑)。在VBScript,VBA和Visual Basic之间的差别:Visual Basic(VB) 是全部的版本。它能产生独立的计划,它也能建立ActiveX 和服务器。它可以被编辑。VB中提供了一个补充文件名为“在线丛书“(VB的5.0)VBA(应用的Visual B

4、asic)是一个Visual Basic的子集。VBA是在诸如Word,Excel或CATIA的应用托管。它提供了一个用编辑器,调试器,一个帮助对象查看器和完整的环境。该<TOOLS>+< REFERENCE>菜单允许申报使用的对象库。这使得可以访问结果和对象浏览器。VBScript(Visual Basic脚本)是一个VBA的子集。简单的语言解释基本法可以调用CATIA对象。没有类型被使用。系统动态地尝试调用方法和对象的属性。(后期绑定通过他们的IDispatch接口调用对象)。支持的语言 CATIA 支持的语言是: CATScript :它是在V5的脚本语言,直到包

5、容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“的其他服

6、务被称为“CreateObject“,并只在NT中可用。 对象类型的声明记录在宏里(即使它不是在VBScript中使用),但它可以帮助你(在VB中与在NT上填写)计划你未来的应用。 CATIA V5的文件扩展名链接在CATIA V5中双击打开Windows资源管理器的“。CATPart“文件。在NT上,如果没有运行CATIA V5,它会自动启动。 CATIA V5的脚本功能在过程中的应用: 这是在CATIA菜单的工具+宏中进行。当宏运行时,CATIA停用。你不能在两个调用间存储一个宏变量。使用VBScript(微软)和VBA访问Windows NT和使用VBScript(Winsoft)访问U

7、nix 。 输出过程中的应用(仅限NT) 这基于自动化。一个外部过程可以调用CATIA,创建或修改几何,解码,测量或试验CATIA。CATIA仍然运行。对于应用程序的每个动作,我们要检查是否CATIA在良好的状态同步两个进程。这种应用可以被发展在: Visual Basic Windows Scripting Host(VBScript,JScript),Windows Explorer HTML(VBScript,JScript)或者任何其他COM 应用。在将来,V5自动化对象的Java封装也将被提供。这将促使在NT和基于Java的Unix上应用软件的开发,无论是在输入进程和输出进程。 宏进

8、程我们在加工过程中调用它,因为该脚本的解释在与CATIA相同的过程里进行。一个列表显示了可用的宏。我们可以运行,编辑,重命名或删除现有的脚本,或创建一个新的。上述小组建议的脚本库的列表是可以通过对库的一个窗口进行修改的。利用CATIA的Visual Basic编辑器,我们可以编辑现有的宏或创建一个新的,插入图形形式,调试和运行VBA项目。对话框的界面“工具+宏+宏.“允许选择一个宏(一个宏目录或一个VBA项目)或一个我们希望工作的文档库上。 从这个窗口,我们可以关闭已打开的库,开放一个库,或建立一个库。库是按类型显示(目录,VBA项目)。 每库类型支持不同的语言。VBA 只支持语言MS -VB

9、A,当在一个目录里时,而在目录中,我们可以写在MS- VBScript或在CATScript。 录制宏该记录的VBA面板允许我们选择将记录的容器,使用的语言和宏的名字被记录。所录制的脚本的语法是要根据不同的菜单中选择。录制宏生成一个对应创建或修改对象的脚本再记录序列里。停止录音后,我们可以存储,编辑重放这个脚本(称为宏)。作为一项规则,记录一个宏可以帮助你学习如何编程的东西。运行宏CATIA一启动,你就能执行宏:CNEXT -macro E:UsersMacrosMacroToRun.CATScript。你可以在批处理模式下启动宏来执行CATIA:CNEXT -batch -macro E:U

10、sersMacrosMacroToRun.CATScript。你可以以交互方式从“宏“菜单中运行宏,你可以以交互方式从一个工具栏图标中运行宏。来自另一个宏的宏的实行 CATIA V5R9通过自动化功能提供能力从另一个宏中执行宏。该功能可以让用户调用另一个脚本函数,在另一个宏库中,可能在另外一种脚本语言编写。一个支持ENUM CATSys库类型是用来让开发人员介绍库那种要调用的函数包含所在。(来自VBScript的例子) 调用一个在确定的“E:宏数学”目录库里的新增功能,文件中的“整数Math.catvba“,一种将写成: Dim args2(1) args2(0) = 3 args2(1) =

11、 2 Dim addResult addResult = CATIA.SystemService.ExecuteScript ( "E:MacrosMath", catScriptLibraryTypeDirectory, "IntegerMath.catvbs", "Add", args2 ) MsgBox addResult 要调用一个PrintReport(),在一个确定的子的“E:零件 Part1.CATPart“V5文档库文件中的“Statistics.catvba“,一种将写成:Dim args() CATIA.Syste

12、mService.ExecuteScript "E:PartsPart1.CATPart",catScriptLibraryTypeDocument,"Statistics.catvbs", "PrintReport", args 在工具条里增加一个作为命令的宏选择你要添加自定义的工具和宏命令标签页的宏,拖放宏的名称到你想要的工具栏,要选择另一个默认的图标,单击显示属性。 宏选项界面对话框“工具+选项+宏“的面板允许根据语言选择,编辑器将被推出来编辑宏,并且指定外部类库来考虑到脚本回放。Whith新接口,运行时间意见的全部typeli

13、bs 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提供的类型

14、库文件(*. TLB)。该类型库文件包含所有对象,方法和公开对象属性的声明。类型定义允许的类型检查和“早期绑定“帮助完成给你所有属性和对象的方法,给你一个方法的参数类型。浏览器对象描述了全部的出口对象。下面是从VBA或Visual Basic来启动CATIA V5的语句。 如果CATIA已经运行: .Dim CATIA as ObjectSet CATIA = GetObject(,“CATIA.Application”). 第一个参数。为空白如果CATIA没运行: .Dim CATIA as ObjectSet CATIA = CreateObject(“CATIA.Application”

15、)CATIA.Visible = True. 这个宏开始CATIA如果类型库INFITF.tbl被引用,我们可以作为INFITF.Application声明CATIA。 使用Windows脚本宿主来运行输出进程WSH支持用不同语言编写,如VBScript和JavaScript脚本。你可以使用标准的编辑器来编写应用程序。如果你的程序失败,你将可以使用Windows开发环境。它可以在Visual Basic开发应用程序,然后评论类型和通过WSH运行它。要运行一个VBScript(*. vbs的)或JavaScript(*. js)文件,你可以使用CScript或Wscript命令。通常情况下,ws

16、cript.exe已经与这些扩展名相关。 在Windows脚本宿主的VBScript你可以在一个简单的ASCII文本文件中用扩展名“vbs“为Visual Basic脚本写一个VBScript程序。在WSH,对象Wscript也提供了GetObject和CreateObject。下面的代码启动CATIA V5:On Error Resume NextSet CATIA = Wscript.GetObject(,"CATIA.Application")If Err.Number <> 0 Then Set CATIA = Wscript.CreateObject(

17、"CATIA.Application") CATIA.Visible = TrueEnd IfBoltVBSript.vbs例子:看一看源码。运行BoltVBSript.vbs例子,你可以双击它。要运行一个命令提示符窗口的一个例子,你也可以使用:Cscript BoltVBScript.vbs或者wscript BoltVBScript.vbs 在Windows脚本宿主的JavaScript运用如VBScript中相同的方式,你可以在一个简单的ASCII文本文件中用扩展“js“为JavaScript写一个JavaScript 程序。 在WSH,对象Wscript也提供了Ge

18、tObject和CreateObject。下面的代码启动CATIA V5。 CATIA = WScript.GetObject(,"CATIA.Application"); if ( CATIA = null) CATIA = WScript.CreateObject("CATIA.Application"); CATIA.Visible = true;BoltJavaSript.js例子 看一看源码。要运行BoltJavaScript.js 例子,你可以双击它。要运行一个命令提示符窗口的一个例子,你也可以使用:Cscript BoltJavaScrip

19、t.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环境启动“Micros

20、oft Development“。在HTML使用VBScript的输出过程 在Microsoft Internet Explorer中载入“BoltVBScript.html“的例子。您可以点击“螺栓“按钮,在CATIA V5创建一个螺栓。您可以通过菜单<View>+<Source>查看源代码。由于安全原因,运行脚本的一些警告信息,可能会出现不同的配置并且要是服务器是本地或者不是。在HTML使用Java脚本的输出进程在Microsoft Internet Explorer中载入“BoltJavaScript.html“的例子。您可以点击“螺栓“按钮来在CATIA V5创

21、建一个螺栓。你能通过<View>+<Source>菜单查看源码。CATIA V5的脚本介绍公开对象的体系结构,CATIA V5公开模式,使得在CATIA的工作台可以创建文档,零部件,表面,线框,产品图纸和许多其他对象。那些公开对象提供属性和方法来读取和修改现有的所有对象。在交互出现的所有对象,可以从宏或输出进程方案编写脚本。关于对象,集合,属性和方法如Visual Basic脚本语言依靠的对象。与CATIA,文件,窗口,浏览器,配件,素描,垫.甚至直线和曲线表示为Visual Basic对象。 对象: 一个实体:例如:文件,填充,线。属性:一个对象的特点。DocName

22、 = CATIA.ActiveDocument.FullName 方法:有一个对象的行动CATIA.ActiveDocument.SaveAs yNewName 集合:对象列表。CATIA 集合指数从1开始,而不是0: For i=1 to CATIA.Documents.Countmsgbox CATIA.Documents.Item(i).Name Next我们还可以访问该对象的名称集合: 例子: msgbox CATIA.Documents.Item(" Product1.CATProduct" ). Name 我们用方法添加对象到集合: set myPartDoc

23、= CATIA.Documents.add("Part")关于继承和集中 在对象之间有两种关系:继承可以帮助你专注对象,而收集共同属性和方法,集中是一个对象到包含另一个的能力。在下面的图中,应用程序聚合Documents集合。该PartDocument对象是一个专门的文件,专于它继承属性的部件和文档对象的方法。脚本基础设施功能概览CATIA应用对象集合两个主要的集合对象:文件和Windows。因为多样性是设置为*文件收集了任意数量的文件。Document对象是一个抽象的对象,只有其派生类型可以被创造,这是PartDocument,ProductDocument和Drawin

24、gDocument。在Windows收集了数量的Window(S)和它们本身并集了一个并集任意数量浏览器的浏览器。窗口和文档对象之间的二进制关联意味着该文档对象是Window对象的上级。应用程序和文档应用程序是全部CATIA 宏的根对象。这对应于CATIA的框架窗口 。CATIA应用始终为进程宏命名CATIA。Documents集合提供一个方法来添加一个新的文件,另一个是打开现有文件。 一个文档可以是一个零件文档,产品文档或绘图文档。每个文档提供它自己的方法来保存或自救。 附件2:外文原文(复印件)CATIA V5 AutomationCATIA V5 Automation & Scr

25、ipting : PresentationOn 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

26、 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 co

27、mpatibility 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 BasicCOM (Component Object Model) is the “Micros

28、oft” 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 Em

29、bedding) 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 BasicVisual Basic(VB) is the full version:It can generate independent programs,It can also create Ac

30、tiveX 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

31、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 s

32、ystem tries dynamically to call methods and properties of objects. (Late binding calling objects through their IDispatch interface).Supported LanguagesThe languages supported by CATIA are:CATScript : It is the language of the scripting in V5 until the inclusive V5R7. From the V5R8, it becomes d

33、eprecated 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 declar

34、e 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

35、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

36、 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 p

37、review for all CATIA Documents. CATIA V5 Scripting capabilitiesIN 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, a

38、nd 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. Th

39、is 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 ap

40、plications on NT and Unix based on Java, both in-process and out-process. In-Process MacrosWe 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

41、 of libraries of script proposed into the panel above is modifiable through the window of libraries.CATIA V5 Visual Basic EditorWith CATIA Visual Basic Editor, We can edit existing macro or create a new one, insert graphic form, debug and run VBA project.Macro librariesThe interface of the dialog “T

42、ools + 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

43、 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 MacroThe 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 b

44、e 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 macr

45、o). As a rule, recording a macro helps you to learn how to program something。Running a MacroYou can execute a macro as soon as CATIA is started : CNEXT -macro E:UsersMacrosMacroToRun.CATScriptYou can start CATIA in batch mode to execute a macro:CNEXT -batch -macro E:UsersMacrosMacroToRun.CATScriptYo

46、u 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 MacroCATIA V5R9 offers the capability through an Automation function to execute a Macro from another Macro. The function lets the user invoke another sc

47、ripted 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

48、a “E:MacrosMath” 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:MacrosMath", catScriptLibraryTypeDirectory, "IntegerMath.catvbs", "Add", args2 ) M

49、sgBox addResult To call an PrintReport() sub that is defined in a “E:PartsPart1.CATPart” V5 document library, in a file “Statistics.catvbs”, one would write:Dim args() CATIA.SystemService.ExecuteScript "E:PartsPart1.CATPart", catScriptLibraryTypeDocument, "Statistics.catvbs", &qu

50、ot;PrintReport", argsAdding a Macro as a command in a ToolbarSelect 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 InterfaceThe

51、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 automaticall

52、y 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 Hos

53、t) with VBScript or JavaScript,Using HTML with VBScript or JavaScriptCATIA can be scripted from any other COM Application.Running Out-Process from VBA or Visual BasicVBA and Visual Basic provide useful tools:For this, you can declare all the typelib files (*.tlb) provided by Dassault Systemes.The ty

54、pelib files contain the declarations of all the objects, methods and properties of the exposed objects. Running Out-Process from VBA or Visual BasicType definition allows type checking and “early binding”.Helpful completion gives you all the properties and methods of an object and gives you the argu

55、ment types of a method.Browser Object describes all the exported objectsRunning Out-Process from VBA or Visual BasicHere are the statements to launch CATIA V5 from VBA or Visual Basic.If CATIA is already running :.Dim CATIA as ObjectSet CATIA = GetObject(, “CATIA.Application”).If CATIA is not alread

56、y running :.Dim CATIA as ObjectSet CATIA = CreateObject(“CATIA.Application”)CATIA.Visible = True.If the typelib INFITF.tbl is referenced, we can declare CATIA as INFITF.Application.Bolt from Excel ExampleThe purpose of this example is to launch CATIA and to create a bolt part from Excel.In this Exam

57、ple, 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 IfOn Error GoTo 0Both functions GetObje

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论