CATIA V5 Automation - Free

3y ago
493 Views
145 Downloads
3.67 MB
153 Pages
Last View : Today
Last Download : 1m ago
Upload by : Francisco Tran
Transcription

CATIA V5 AutomationCATIA V5 TrainingStudent Notes:FoilsCopyright DASSAULT SYSTEMESCATIA V5AutomationCopyright DASSAULT SYSTEMESVersion 5 Release 19January 2009EDU CAT EN VBA AF V5R191

CATIA V5 AutomationAbout this courseStudent Notes:Objectives of the courseUpon completion of this course, you will be able to create automationscripts, programs, and macros in CATIA V5, using Visual Basic and otherautomation tools available in CATIA V5.Targeted audienceApplication developersPrerequisitesCopyright DASSAULT SYSTEMESStudents attending this course should have knowledge of CATIA V5Interactive and Visual BasicCopyright DASSAULT SYSTEMES8 hours2

CATIA V5 AutomationStudent Notes:Table of Contents (1/4)Introduction to CATIA V5 AutomationCATIA V5 Automation & Scripting: PresentationKnowledgeware, VB Automation, and CAASkills Required for CATIA V5 AutomationCATIA V5 Automation: Presentation (Windows only)Language Used for AutomationVB ScriptVBAVisual BasicCommunication Chart on WindowsDocumentationsInterface DocumentationCATIA V5 Association with File ExtensionCATIA V5 OLE (Object Linking and Embedding)CATIA V5 Scripting CapabilitiesCopyright DASSAULT SYSTEMESIn-Process MarcosWhat is an 'In-Process' MacroCATIA V5 Visual Basic EditorCopyright DASSAULT SYSTEMES7891011121315161718192122232425263

CATIA V5 AutomationStudent Notes:Table of Contents (2/4)Macro LibrariesRecording a MacroRunning a MacroExecution of a Macro from another MacroExecution of a Macro which Require ParametersAdding a Macro as a command in a ToolbarMacros Options InterfaceCopyright DASSAULT SYSTEMESOut-Process ProgramsRunning Out-Process Programs (On Windows only)Running Out-Process from VBA or Visual BasicExample: Bolt from ExcelRunning Out-Process using the Windows Scripting HostVBScript under Windows Scripting HostBoltVBSript.vbs ExampleJavaScript under Windows Scripting HostBoltJavaSript.js ExampleOut-Process in HTML (Windows & Microsoft IE Only)Out-Process in HTML with VBScriptCopyright DASSAULT SYSTEMES2728293132333435363740434445464748494

CATIA V5 AutomationStudent Notes:Table of Contents (3/4)Out-Process in HTML with JavaScriptVBA / VB Programming Basics51Programming GeneralitiesVBA / VB Common ControlsVB Programming Techniques525770Scripting with CATIA V5CATIA V5 Object ArchitectureScripting Infrastructure FeaturesScripting SketchesScripting Part Design FeaturesScripting Shape Design FeaturesScripting Assembly Design FeaturesScripting Drafting FeaturesAccessing ElementsCopyright DASSAULT SYSTEMES50Automatic SelectionsScanning the ContainersAccess to a Specific ElementGraphic SelectionsCopyright DASSAULT SYSTEMES7778951041071101131181221231241251265

CATIA V5 AutomationStudent Notes:Table of Contents (4/4)Graphic Selection using 'Selection'Graphic Selections using SelectElement2Creating Panels from MacrosInput boxPanels in an ActiveX component (Windows Only)Miscellaneous InformationObfuscating and Converting MacrosObfuscate VBScript MacrosMulti-Product SupportRegistering CATIA and Type LibrariesConverting a Macro to a Visual Basic ProgramConverting a Visual Basic programm to a CATIA MacroMacros on UNIX / WindowsCalling an other Automation Server137138142144145146147148149151152Copyright DASSAULT SYSTEMESCalling WSH from VBScriptCalling ExcelDrawing a Chart in EXCEL127129130131132133Copyright DASSAULT SYSTEMES6

CATIA V5 AutomationIntroduction to CATIA V5 AutomationStudent Notes:Copyright DASSAULT SYSTEMESYou will be introduced to various tools and capabilities related to CATIA V5 Automation.Copyright DASSAULT SYSTEMES7

CATIA V5 AutomationCATIA V5 Automation & Scripting: PresentationStudent Notes:On both Windows and UNIXThe scripting allows you to program CATIA in a very simple way with macros onboth Windows and UNIX platforms.CATIA uses the common part on MS-VBScript to have the same macros runningon both the platforms.Copyright DASSAULT SYSTEMESOn Windows platformsAutomation allows CATIA to share objects with other external applications suchas Word/Excel or Visual Basic programs.CATIA can use the Word/Excel objects as well as Word/Excel can use the CATIAObjects.Copyright DASSAULT SYSTEMES8

CATIA V5 AutomationKnowledgeware, VB Automation, and CAAStudent Notes:VB AutomationKnowledgewareNeeds CATIA licensesLow interaction with final user (no window interface)Based on geometryMay be integrated to VB AutomationCopyright DASSAULT SYSTEMESCAA V5Need licensesHigh skills in programming (C )Usually for specific-domain solutionCopyright DASSAULT SYSTEMES9

CATIA V5 AutomationSkills Required for CATIA V5 AutomationStudent Notes:VBA (Visual Basic for Applications) or Visual Basic 6 basicsBasic languageObject programmingEvent programmingKnowledge of the CATIA workbench in which you are going to programCopyright DASSAULT SYSTEMESInfrastructureSurfacesAnalysis etc.Copyright DASSAULT SYSTEMES10

CATIA V5 AutomationCATIA V5 Automation: Presentation (Windows only)Student Notes:Automation allows communication between several process.Visual Basic Script (for Macros)CATIA V5On WindowsInterfacesCOMVisual Basic ForApplications (for ex:Word/Excel)Visual BasicCOM (Component Object Model) is the “Microsoft” standard to share objects betweenseveral applications.Automation is a “Microsoft” technology to use COM objects in an interpreted environment.Copyright DASSAULT SYSTEMESActiveX component is a “Microsoft” standard to share objects between severalapplications even in an interpreted environment.OLE (Object Linking and Embedding) means that the document can be linked in thedocument of an other application OLE and can be edited in that other application (In placeediting).Copyright DASSAULT SYSTEMES11

CATIA V5 AutomationLanguage Used for AutomationStudent Notes:Copyright DASSAULT SYSTEMESThree possible languages:Visual Basic 6VBAVB Script / CATScriptCopyright DASSAULT SYSTEMES12

CATIA V5 AutomationVB Script (1/2)Student Notes:VBScript (Visual Basic Script) is a subset of VBA. It is a simple interpreted Basic languageOnly Windows/Unix « compatible » languageCan call CATIA ObjectsDirectly launchable from a saved macroCopyright DASSAULT SYSTEMESWeak help to programmingVery ‘light’ internal editorNo type is used. The system tries dynamically to call methods and properties ofobjects.Sequential programmingPoor User Interface toolsCopyright DASSAULT SYSTEMES13

CATIA V5 AutomationVB Script (2/2)Student Notes:Copyright DASSAULT SYSTEMESPoor User Interface : ExamplesMessage boxInput boxFile Selection BoxNo more Copyright DASSAULT SYSTEMES14

CATIA V5 AutomationStudent Notes:VBAVBA (Visual Basic for Applications) is a subset of Visual Basic. VBA is hosted inapplications such as Word, Excel or CATIA.Programming help« Event » ProgrammingCATIA drive from another VBAapplication (Excel, Word )Rich User Interface(buttons, lists, )Copyright DASSAULT SYSTEMESWeak protectionNot easy to export programNo « InstallShield » toolCopyright DASSAULT SYSTEMES15

CATIA V5 AutomationVisual BasicStudent Notes:Visual Basic is the full versionAll the advantages of VBA More extended set of instructionsCode protection (compiled program)Can create ActiveX and Serversprovides an added documentation called “Books on line” (VB 5.0)Packaging and deployment assistantCopyright DASSAULT SYSTEMESNeeds an additional installationMicrosoft licensed softwareCopyright DASSAULT SYSTEMES16

CATIA V5 AutomationStudent Notes:Communication Chart on WindowsMacros(VBScript)Panels in ActiveX(Windows)CATIA V5Copyright DASSAULT SYSTEMES*.VBS or *.JSVisual BasicIn-ProcessOut-ProcessCopyright DASSAULT SYSTEMESHTML-WSH Internet/IIS(VBScript- JavaScript)Word/Excel (VBA)17

CATIA V5 AutomationStudent Notes:DocumentationsJournaling guides for eachworkbenchesArchitectureConcepts, rules, samples .Copyright DASSAULT SYSTEMESUnderstandCopyright DASSAULT SYSTEMES18

CATIA V5 AutomationStudent Notes:Interface Documentation (1/2)Public InterfacesCopyright DASSAULT SYSTEMESUseCopyright DASSAULT SYSTEMES19

CATIA V5 AutomationInterface Documentation (2/2)Student Notes:Copyright DASSAULT SYSTEMESAdditional InformationThe documentation is also available in the CATIA code installation directory.Look for \Bxx\intel a\code\bin\V5Automation.chmand create a shortcut on your Desktop.In the documentation, you will find helpful ‘Use cases’.Copyright DASSAULT SYSTEMES20

CATIA V5 AutomationCATIA V5 Association with File ExtensionStudent Notes:A double-click in Windows Explorer on a ”.CATPart” file opens it in CATIA V5. On Windows,If CATIA V5 is not running, it is launched automatically.Copyright DASSAULT SYSTEMESDouble-click,Open, or press EnterIn the Windows Explorer, the “Details” section shows a preview for all CATIA Documents.Copyright DASSAULT SYSTEMES21

CATIA V5 AutomationCATIA V5 OLE (Object Linking and Embedding)Student Notes:Copyright DASSAULT SYSTEMESDrag and Drop inan OLE containerCopyright DASSAULT SYSTEMESA double-click on thepicture lets you edit thebolt in CATIA V522

CATIA V5 AutomationCATIA V5 Scripting CapabilitiesStudent Notes:IN process application:This is done from the Tools Macro in CATIA menu. When the Macro is running, CATIA isdeactivated. You cannot store variables in a macro between two calls. Access with VBScript(Microsoft) and VBA on Windows, and with VBScript (Winsoft) on Unix.OUT process application (Windows only)Copyright DASSAULT SYSTEMESThis is based on AUTOMATION. A foreign process can call CATIA, create or modifygeometry, decode, measure or pilot CATIA. CATIA is still running. For each action of theapplication, we have to check if CATIA is in the good state to synchronize the twoprocesses. This kind of applications can be developed in:Visual BasicWindows Scripting Host (VBScript , JScript)Windows Explorer HTML (VBScript , JScript)or Any other COM applications.Copyright DASSAULT SYSTEMES23

CATIA V5 AutomationIn-Process MacrosStudent Notes:Copyright DASSAULT SYSTEMESYou will learn how to record and run the In-Process macros.Copyright DASSAULT SYSTEMES24

CATIA V5 AutomationWhat is an ‘In-Process’ MacroStudent Notes:Copyright DASSAULT SYSTEMESWe call In-process because the script interpretation is performed in the sameprocess as CATIA.A list shows the Macro available. We can run, edit, rename or delete existing script, or create a newone.The list of libraries of script proposed into the panel above is modifiable through the window oflibraries.Copyright DASSAULT SYSTEMES25

CATIA V5 AutomationCATIA V5 Visual Basic EditorStudent Notes:Copyright DASSAULT SYSTEMESWith CATIA Visual BasicEditor, We can edit existingmacro or create a new one,Insert graphic form, debug andRun VBA project.Copyright DASSAULT SYSTEMES26

CATIA V5 AutomationMacro LibrariesStudent Notes:Copyright DASSAULT SYSTEMESThe 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.Copyright DASSAULT SYSTEMES27

CATIA V5 AutomationRecording a MacroStudent Notes:Copyright DASSAULT SYSTEMESThe panel of recording VBA allows to choose the container in which we are going torecord, 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 theobjects in the recorded sequence. After stopping the recording, we can store, edit or replay thisscript (called macro).As a rule, recording a macro helps you to learn how to program something.Copyright DASSAULT SYSTEMES28

CATIA V5 AutomationRunning a Macro (1/2)Student Notes:You can execute a macro as soon as CATIA is started CATScriptE:\Users\Macros\MacroToRun.CATScriptYou can start CATIA in batch mode to execute a n.CATScriptCopyright DASSAULT SYSTEMESYou can run a macro interactively from the “Macro” menuYou can run a macro interactively from an icon in a toolbarCopyright DASSAULT SYSTEMES29

CATIA V5 AutomationStudent Notes:Running a Macro (2/2)The syntax to execute macros in text files using the CNEXT -macro command line, hasbeen expanded to allow replaying macro which are in VBA projects, in V5 documents,and are written in VBScript, CATScript or VBA.Here is a complete summary of the Supported Syntax:Previously available options:CNEXT -macro X.CATScript// Replays file X.CATScript (CATScript file)CNEXT -macro X.catvbs// Replays file X.catvbs (pure VBScript file)// Replays macro Y in the VBA project X.catvba// Replays macro Y in the V5 document X.CATPartCopyright DASSAULT SYSTEMESNew options:CNEXT -macro X.catvba YCNEXT -macro X.CATPart YCopyright DASSAULT SYSTEMES30

CATIA V5 AutomationExecution of a Macro from another MacroStudent Notes:CATIA V5 offer the capability through an Automation function to execute a Macro from anotherMacro. The function lets the user invoke another scripted function, contained in another macrolibrary, potentially written in another scripting language. A support enum CATSysLibraryType isused 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:Copyright DASSAULT SYSTEMESDimDimargs2(1)args2(1)args2(0)args2(0) 33args2(1)args2(1) 22DimDimaddResultaddResultaddResultaddResult ce.ExecuteScript( rgs2args2) )MsgBoxMsgBoxaddResultaddResultTo call an PrintReport() sub that is defined in a “E:\Parts\Part1.CATPart” V5 document library,in a file “Statistics.catvbs”, one would tvbs", "PrintReport", argsCopyright DASSAULT SYSTEMES31

CATIA V5 AutomationExecution of a Macro which Require ParametersStudent Notes:CATIA V5 gives the possibility to add parameters to the CATMain function.When the function is executed, an interactive window pops up which lets the user value theparameters by selecting V5 objects or typing the values directly. Parameters of type string, int,float, boolean and object can be entered.If the user writes the following VBScript eight)SetpartDocument1Set partDocument1 1part1 tory1shapeFactory1 part1.ShapeFactorypart1.ShapeFactorySetpad1Set pad1 EndEndSubSubCopyright DASSAULT SYSTEMESand runs it, the following window pop up automaticallyto let him/her enter the value of the sketch and heightparameters.Copyright DASSAULT SYSTEMES32

CATIA V5 AutomationAdding a Macro as a command in a ToolbarStudent Notes:Select the macro you want to add in Tools Customize Commands Tab page Macros:Drag and Drop the macro nameto the toolbar you wish :Copyright DASSAULT SYSTEMESTo select another icon than the default one,click on Show Properties.Copyright DASSAULT SYSTEMES33

CATIA V5 AutomationMacros Options InterfaceStudent Notes:Copyright DASSAULT SYSTEMESThe 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 intoaccount in the replay of scripts.With the new interface, all the typelibs V5 of the runtime view are automatically taken intoaccount. This option serves only for declaring typelibs except runtime view (Excel for example).Copyright DASSAULT SYSTEMES34

CATIA V5 AutomationOut-Process ProgramsStudent Notes:Copyright DASSAULT SYSTEMESYou will learn methods to create and execute Out-Process programs for CATIA V5Automation.Copyright DASSAULT SYSTEMES35

CATIA V5 AutomationRunning Out-Process Programs (On Windows only)Student Notes:The script is running in another application running in another process, such as:Visual BasicVBA (in Excel or Word)Using WSH (Windows Scripting Host) with VBScript or JavaScriptUsing HTML with VBScript or JavaScriptCopyright DASSAULT SYSTEMESCATIA can be scripted from any other COM Application.Copyright DASSAULT SYSTEMES36

CATIA V5 AutomationRunning Out-Process from VBA or Visual Basic (1/3)Student Notes:Copyright DASSAULT SYSTEMESVBA 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 theExposed objects.Copyright DASSAULT SYSTEMES37

CATIA V5 AutomationRunning Out-Process from VBA or Visual Basic (2/3)Student Notes:Copyright DASSAULT SYSTEMESType definition allows type checking and “early binding”.Helpful completion gives you all the properties and methods of an object and givesyou the argument types of a method.Browser Object describes all the exported objects.Copyright DASSAULT SYSTEMES38

CATIA V5 AutomationRunning Out-Process from VBA or Visual Basic (3/3)Student Notes:Here are the statements to launch CATIA V5 from VBA or Visual Basic.If CATIA is already running :[.][.]DimDimCATIACATIAasasObjectObjectSetCATIA GetObject(,Set CATIA ation”)[.][.]First arg. is left blankCopyright DASSAULT SYSTEMESIf CATIA is not already running :[.][.]DimDim CATIACATIA asas ObjectObjectSetSet CATIACATIA “CATIA.Application”)CATIA.VisibleCATIA.Visible TrueTrueThis macro starts CATIA[.][.]If the typelib INFITF.tbl is referenced, we can declare CATIA as INFITF.Application.Copyright DASSAULT SYSTEMES39

CATIA V5 AutomationStudent Notes:Example: Bolt from Excel (1/3)1Start a New ExcelDocument and activate thetoolbars:Forms and Visual Basic.2Activate theDesign mode.3Copyright DASSAULT SYSTEMESCreate a new Button and click on“New” button to “Assign Macro”.Copyright DASSAULT SYSTEMES40

CATIA V5 AutomationExample: Bolt from Excel (2/3)Student Notes:1You go automatically inVisual Basic.Insert the Code from the file“BoltFromExcel.txt”2Copyright DASSAULT SYSTEMESClose Visual Basic and return toExcel.Click on Button1CATIA will be launched and abolt will be created.Copyright DASSAULT SYSTEMES41

CATIA V5 AutomationExample: Bolt from Excel (3/3)Student Notes:Have a look on the code:This tries to retrieve CATIA and if not successful starts orResumeNextOn Error Resume NextSetSetCATIACATIA pplication")IfIfErr.NumberErr.Number 00ThenThenSetSetCATIACATIA IA.Application")CATIA.VisibleCATIA.Visible t DASSAULT SYSTEMESBoth functions GetObject and CreateObject are provided by VBA (as well as Visual Basic).Copyright DASSAULT SYSTEMES42

CATIA V5 AutomationRunning Out-Process using the Windows Scripting HostStudent Notes:WSH enables scripts written in different languages such as VBScript and JavaScri

CATIA V5 Automation & Scripting: Presentation 8 Knowledgeware, VB Automation, and CAA 9 Skills Required for CATIA V5 Automation 10 CATIA V5 Automation: Presentation (Windows only) 11 Language Used for Automation 12 VB Script 13 VBA 15 Visual Basic 16 Communication Chart on Windows 17 Documentations 18 Interface Documentation 19

Related Documents:

I am using CATIA V5 standalone license at the office. How do I use CATIA V5 in my laptop at home which does not have any CATIA V5. Shall I use the Same License Package? To whom should I contact? Indeed, you would need to have CATIA code on your laptop and have access to a CATIA V5 license. In the case your company has the CATIA V5 licenses on .

The CATIA-CADAM Interface product allows you to integrate your CADAM Drafting environment with other V5 CATIA product offerings. Depending on your intended usage, there are two basic design methodologies that the CATIA-CADAM Interface product supports for integrating your V5 CATIA and CADAM drafting environments. They are as follows:

A prerequisite for this guide is to knowthe basics of CATIA, programming by Visual Basic, and VBScript for CATIA. To start learning programming for CATIA V5 from scratch, please read VB SCRIPTING FOR CATIA V5 by Emmett Ross.

CATIA Student Edition isn't certified on Windows 8 and Windows 10 but some students reported it works well NB: Windows 10 will be certified soon on further CATIA V5 Student Edition releases ATI Radeon graphic cards are not supported. CATIA Student Edition will not work with this GPU. A. Differences between CATIA V5 Student Edition and the

added very easily and designers can start the necessary CATIA V5 Release configuration file a list of available projects will be build for which the user can start CATIA V5. Several additional options are available to start CATIA V5 (Start CATIA V5

CATIA V5 Fundamentals, Getting started with CATIA V5, CATIA Sketcher, and Part Design Fundamentals Available Online Yes. 3DS Learning Solutions Course Catalog 9 / 19 CATIA Product Design (ASM) Course Code CAT-en-ASM-F-V5R23 Available Releases V5R19 , V5

With Abaqus for CATIA V5 your CATIA V5 models and your Abaqus models become one and the same, making this software a highly scalable solution. Design engineers skilled in using CATIA V5 have access to a wide array of Abaqus simulation capabilities, while Abaqus experts can readily access CATIA V5 models for their analysis work.

Thomas Coyne, LEM, Dir. Greg Lesko Nina Mascio Debbie Walters, LEM Faith Formation Lori Ellis, LEM, Religious Education Baptism/Marriage Please contact Lori Ellis at 412-462-8161 Confession Schedule Mondays at St. Therese at 7:00 p.m. Saturdays at Holy Trinity from 3:00-3:45 p.m. Saturdays at St. Max from 3:00-3:45 p.m. Hall Rentals Please call 412-461-1054 Website www.thomastheapostle.net .