Vous êtes sur la page 1sur 26

Sa

m
Al ple
lc p
op ro
yi vid
ng e
d
an b
d yA
re S

Cover Page
us C

2nd Edition
e EN

Student Guide
st T
ric fo
tly r
CATIA V5-6R2016:

fo rev
rb ie
Visual Basic Automation

id w
de o
n. nly
Sa
m
Al ple
lc p
op ro
yi vid
ng e
d
an b
d yA
re S
us C
e EN
st T
ric fo
tly r
fo rev
rb ie
id w
de o
n. nly
ASCENT - Center for Technical Knowledge®
CATIA V5-6R2016: Visual Basic Automation
2nd Edition
Prepared and produced by:
ASCENT Center for Technical Knowledge

n. nly
630 Peter Jefferson Parkway, Suite 175
Charlottesville, VA 22911

de o
866-527-2368
www.ASCENTed.com

id w
Copyright

rb ie
ASCENT - Center for Technical Knowledge is a division of Rand Worldwide, Inc., providing custom
developed knowledge products and services for leading engineering software applications. ASCENT is

fo rev
focused on specializing in the creation of education programs that incorporate the best of classroom
learning and technology-based training offerings.

We welcome any comments you may have regarding this student guide, or any of our products. To contact

tly r
ric fo
us please email: feedback@ASCENTed.com.

© ASCENT - Center for Technical Knowledge, 2017

st T
All rights reserved. No part of this guide may be reproduced in any form by any photographic, electronic,
e EN
mechanical or other means or used in any information storage and retrieval system without the written
permission of ASCENT, a division of Rand Worldwide, Inc.
us C
CATIA and ENOVIA are registered trademarks of Dassault Systèmes.
re S

All other brand names, product names, or trademarks belong to their respective holders.
d yA

General Disclaimer:
Notwithstanding any language to the contrary, nothing contained herein constitutes nor is intended to
constitute an offer, inducement, promise, or contract of any kind. The data contained herein is for
an b

informational purposes only and is not represented to be error free. ASCENT, its agents and employees,
expressly disclaim any liability for any damages, losses or other expenses arising in connection with the use
d

of its materials or in connection with any failure of performance, error, omission even if ASCENT, or its
representatives, are advised of the possibility of such damages, losses or other expenses. No consequential
ng e

damages can be sought against ASCENT or Rand Worldwide, Inc. for the use of these materials by any third
yi vid

parties or for any direct or indirect result of that use.


The information contained herein is intended to be of general interest to you and is provided "as is", and it
does not address the circumstances of any particular individual or entity. Nothing herein constitutes
op ro

professional advice, nor does it constitute a comprehensive or complete statement of the issues discussed
thereto. ASCENT does not warrant that the document or information will be error free or will meet any
lc p

particular criteria of performance or quality. In particular (but without limitation) information may be rendered
inaccurate by changes made to the subject of the materials (i.e. applicable software). Rand Worldwide, Inc.
Al ple

specifically disclaims any warranty, either expressed or implied, including the warranty of fitness for a
particular purpose.
m
Sa

AS-56CAT16-VBA2-SG // RS-56CAT16-VBA2-SG
Sa
m
Al ple
lc p
op ro
yi vid
ng e
d
an b
d yA
re S
us C
e EN
st T
ric fo
tly r
fo rev
rb ie
id w
de o
n. nly
C o n t e n ts

n. nly
de o
id w
rb ie
fo rev
Preface ........................................................................................................... vii

In this Guide ................................................................................................... ix

tly r
ric fo
Practice Files .................................................................................................. xi

st T
Chapter 1: Fundamentals............................................................................. 1-1
e EN1.1 Visual Basic Evolution.................................................................... 1-2
CATIA Automation Platforms ............................................................ 1-2
us C
1.2 VB6 ................................................................................................... 1-3
re S

Event-driven Programming ............................................................... 1-3


d yA

IDE (Integrated Development Environment) ..................................... 1-4


GUI (Graphical User Interface) ......................................................... 1-5
COM (Component Object Model)...................................................... 1-5
an b

1.3 VBA................................................................................................... 1-7


d

1.4 VBScript and CATScript ................................................................. 1-8


ng e
yi vid

1.5 VB.NET ............................................................................................. 1-9


1.6 In-process and Out-of-process Applications ............................. 1-10
op ro

In-process Applications ................................................................... 1-10


Out-of-process Applications ............................................................ 1-10
lc p

1.7 Registering CATIA Libraries ........................................................ 1-11


Al ple

Chapter 2: CATIA Object Model .................................................................. 2-1


m

2.1 Objects, Classes, Properties, and Methods ................................. 2-2


Sa

Example of an Object in CATIA ........................................................ 2-2


2.2 Inheritance ....................................................................................... 2-4
Example of Inheritance in CATIA ...................................................... 2-5
2.3 Aggregation ..................................................................................... 2-6
2.4 Collections and Abstract Objects.................................................. 2-7
2.5 CATIA Object Diagram.................................................................... 2-8

© 2017, ASCENT - Center for Technical Knowledge® i


CATIA V5-6R2016: Visual Basic Automation

2.6 CATIA Automation Documentation ............................................... 2-9


Practice 2a Navigating Automation Documentation......................... 2-12

Chapter 3: Introduction to Macros .............................................................. 3-1


3.1 Introduction ..................................................................................... 3-2

n. nly
3.2 Macro Libraries ............................................................................... 3-3

de o
3.3 Recording or Replaying Macros .................................................... 3-4

id w
3.4 Viewing or Editing Macros ............................................................. 3-5
Interpreting Macro Recordings.......................................................... 3-6

rb ie
Replaying a Macro ............................................................................ 3-7

fo rev
Executing a Macro on CATIA startup................................................ 3-7
Macros with Parameters ................................................................... 3-8
3.5 Assigning a Macro to a Toolbar..................................................... 3-9

tly r
ric fo
Practice 3a Square Pad with Parameters........................................... 3-10

st T
Practice 3b Series of Round Pads ...................................................... 3-16
e EN
Chapter 4: Introduction to VBA ................................................................... 4-1
4.1 Overview .......................................................................................... 4-2
us C

4.2 Event-driven Programming ............................................................ 4-3


re S
d yA

4.3 Forms and Controls ........................................................................ 4-5


4.4 Modules............................................................................................ 4-6
an b

4.5 Early Versus Late Binding.............................................................. 4-7


d

4.6 Type Libraries.................................................................................. 4-8


ng e

4.7 Object Browser................................................................................ 4-9


yi vid

4.8 Programming Tips ........................................................................ 4-10


Running and Debugging ................................................................. 4-10
op ro

Starting a User Form from CATIA ................................................... 4-10


lc p

4.9 Error Handling ............................................................................... 4-11


Al ple

4.10 Late Binding when Calling some CATIA Methods ..................... 4-12
Practice 4a Simple User Form with Controls..................................... 4-13
m

Chapter 5: CATIA Infrastructure Automation............................................. 5-1


Sa

5.1 CATIA Root Object Diagram .......................................................... 5-2


5.2 Documents Collection .................................................................... 5-3
5.3 Windows Collection ........................................................................ 5-4
5.4 SystemConfiguration Object.......................................................... 5-5
Practice 5a Creating and Saving a Part................................................ 5-6
Practice 5b Opening a Product ............................................................. 5-9

ii © 2017, ASCENT - Center for Technical Knowledge®


Contents

Chapter 6: Part Infrastructure Automation................................................. 6-1


6.1 Part Document Object Diagram ..................................................... 6-2
6.2 Part and Product Objects ............................................................... 6-3
6.3 Bodies Collection............................................................................ 6-4

n. nly
6.4 HybridBodies Collection ................................................................ 6-5
Practice 6a Working with Part Infrastructure ...................................... 6-6

de o
id w
Chapter 7: Part Design Automation ............................................................ 7-1

rb ie
7.1 Part Design Object Diagram........................................................... 7-2
Types of Shape Objects.................................................................... 7-3

fo rev
7.2 Sketch Object Diagram................................................................... 7-4
7.3 Creating Sketches........................................................................... 7-5

tly r
ric fo
Creating Sketch Geometry................................................................ 7-5
Creating Sketch Constraints ............................................................. 7-6

st T
7.4 Creating Solid Features.................................................................. 7-7
e EN
7.5 Reference Object............................................................................. 7-8
7.6 In Work Object and Part Update .................................................... 7-9
us C

Practice 7a Working with Sketcher and Part Design ........................ 7-10


re S
d yA

Chapter 8: Shape Design Automation ........................................................ 8-1


8.1 Shape Design Object Diagram....................................................... 8-2
an b

Types of Hybrid Shape Objects ........................................................ 8-3


d

8.2 HybridBody Object.......................................................................... 8-4


ng e

8.3 HybridShapeFactory Object........................................................... 8-5


yi vid

8.4 Creating Shape Features................................................................ 8-6


op ro

Practice 8a Working with Shape Design .............................................. 8-7


lc p

Chapter 9: Assembly Design Automation .................................................. 9-1


Al ple

9.1 Product Document Object Diagram .............................................. 9-2


9.2 Product Properties.......................................................................... 9-3
m

9.3 Reference Product .......................................................................... 9-4


Sa

Building Product Structure ................................................................ 9-5


9.4 Positioning Assembly Components.............................................. 9-6
Transformation Matrix ....................................................................... 9-6
9.5 Assembly Constraints .................................................................... 9-8
Analyze Object and Bill of Materials.................................................. 9-9
Practice 9a Working with Assembly Design...................................... 9-10

© 2017, ASCENT - Center for Technical Knowledge® iii


CATIA V5-6R2016: Visual Basic Automation

Chapter 10: Drafting Automation .............................................................. 10-1


10.1 Drawing Document Object Diagram............................................ 10-2
10.2 Sheets and Views.......................................................................... 10-3
Sheets ............................................................................................. 10-3
Views............................................................................................... 10-4

n. nly
10.3 Drawing View Object Diagram ..................................................... 10-5

de o
10.4 GenerativeBehaviour Object........................................................ 10-6

id w
10.5 Creating Generative Views........................................................... 10-7

rb ie
View Projection Plane and Direction ............................................... 10-8
View Positioning.............................................................................. 10-9

fo rev
10.6 Creating Dimensions .................................................................. 10-10
10.7 Creating Annotations.................................................................. 10-11

tly r
Drawing Text Object...................................................................... 10-12

ric fo
Drawing Table Object.................................................................... 10-13

st T
10.8 Creating Non-Generative Geometry .......................................... 10-15
e EN
10.9 Creating Frame and Title Block ................................................. 10-16
Frame and Title Block Macros ...................................................... 10-16
us C
Creating Frame and Title Block..................................................... 10-17
re S

Practice 10a Creating Drawing Views .............................................. 10-18


d yA

Practice 10b Creating Frame and Title Block .................................. 10-24

Chapter 11: Working with Graphic Properties ......................................... 11-1


an b

11.1 Selection Object ............................................................................ 11-2


d

11.2 Working with Selections............................................................... 11-3


ng e

Adding Elements to Selection ......................................................... 11-3


yi vid

11.3 Modifying Graphic Properties...................................................... 11-5


op ro

Practice 11a Working with Graphic Properties ................................. 11-6


lc p

Chapter 12: Interactive Selections ............................................................ 12-1


Al ple

12.1 Interactive Selection Options....................................................... 12-2


12.2 Preselection Methods ................................................................... 12-3
m

Item Method .................................................................................... 12-3


Sa

FindObject Method.......................................................................... 12-4


12.3 Interactive Methods ...................................................................... 12-5
SelectElement* Methods................................................................. 12-5
Using SelectElement Methods ........................................................ 12-5
IndicateOrSelectElement* Methods ................................................ 12-6
Practice 12a Parsing Pre-Selected Elements .................................... 12-7
Practice 12b Working with SelectElement2 ..................................... 12-10

iv © 2017, ASCENT - Center for Technical Knowledge®


Contents

Chapter 13: Cut, Copy, Paste, and Delete ................................................ 13-1


13.1 Deleting CATIA Objects................................................................ 13-2
13.2 Copying and Pasting CATIA Objects .......................................... 13-3
13.3 Paste Options ................................................................................ 13-4

n. nly
Practice 13a Copying and Pasting between Parts ............................ 13-5

de o
Chapter 14: Parameters and Formulas..................................................... 14-1

id w
14.1 Parameters and Relations Collections........................................ 14-2

rb ie
14.2 Parameters Object Model ............................................................. 14-3

fo rev
14.3 Creating Parameters ..................................................................... 14-4
14.4 Valuating Parameters ................................................................... 14-5

tly r
14.5 Working with Units........................................................................ 14-6

ric fo
14.6 Relations Object Model ................................................................ 14-7

st T
14.7 Creating Relations ........................................................................ 14-8
e EN
Practice 14a Measuring Spline Length using Formula..................... 14-9
us C
Chapter 15: Communication with Microsoft Office ................................. 15-1
re S

15.1 Microsoft Automation ................................................................... 15-2


d yA

15.2 Microsoft Office Object Model ..................................................... 15-3


15.3 GetObject and CreateObject Methods ........................................ 15-4
an b

Handling Errors when Contacting Server........................................ 15-4


d

Practice 15a Exporting CATIA Data to Excel ..................................... 15-6


ng e

Practice 15b Exporting Excel Data to CATIA................................... 15-10


yi vid

Appendix A: Completed Practices ..............................................................A-1


op ro

Practice A1 Practice A1 ......................................................................... A-2


lc p

Practice A2 Practice A2 ......................................................................... A-6


Al ple

Practice A3 Practice A3 ....................................................................... A-10


Practice A4 Practice A4 ....................................................................... A-11
m

Practice A5 Practice A5 ....................................................................... A-13


Sa

Practice A6 Practice A6 ....................................................................... A-15


Practice A7 Practice A7 ....................................................................... A-17
Practice A8 Practice A8 ....................................................................... A-19
Practice A9 Practice A9 ....................................................................... A-23
Practice A10 Practice A10 ................................................................... A-27
Practice A11 Practice A11 ................................................................... A-31

© 2017, ASCENT - Center for Technical Knowledge® v


CATIA V5-6R2016: Visual Basic Automation

Practice A12 Practice A12 ................................................................... A-35


Practice A13 Practice A13 ................................................................... A-37
Practice A14 Practice A14 ................................................................... A-38
Practice A15 Practice A15 ................................................................... A-40

n. nly
Practice A16 Practice A16 ................................................................... A-42
Practice A17 Practice A17 ................................................................... A-44

de o
Practice A18 Practice A18 ................................................................... A-46

id w
rb ie
fo rev
tly r
ric fo
st T
e EN
us C
re S
d yA
an b
d
ng e
yi vid
op ro
lc p
Al ple
m
Sa

vi © 2017, ASCENT - Center for Technical Knowledge®


Preface

n. nly
de o
id w
rb ie
fo rev
The CATIA V5-6R2016: Visual Basic Automation student guide provides you a
good understanding of the different ways to automate tasks using CATIA macros
and Visual Basic programming. Using hands-on practices, you will use VB

tly r
programming to work with parts, assemblies, drawings, selections, parameters

ric fo
and formulas, graphic properties, and to exchange data with Microsoft Excel.

st T
Topics Covered:
e EN
• CATIA V5 Object Model
us C
• Creating Part Design and Shape Design features
re S
d yA

• Working with Product Structure and Assembly Design

• Scripting Drawing Views, Frames, and Title Blocks


an b

• Deleting, Cutting, Copying, Pasting CATIA objects


d
ng e

• Interactive Selections
yi vid

• Communication with MS Office


op ro

Note on Software Setup


lc p

This student guide assumes a standard installation of the software using the
Al ple

default preferences during installation. Lectures and practices use the standard
software templates and default options for the Content Libraries.
m

This guide was written against CATIA V5-6R2016, Service Pack 1.


Sa

© 2017, ASCENT - Center for Technical Knowledge® vii


CATIA V5-6R2016: Visual Basic Automation

n. nly
de o
id w
rb ie
fo rev
tly r
ric fo
st T
e EN
us C
re S
d yA
an b
d
ng e
yi vid
op ro
lc p
Al ple
m
Sa

viii © 2017, ASCENT - Center for Technical Knowledge®


In th is Gu id e

n. nly
de o
id w
rb ie
fo rev
The following images highlight some of the features that can be found in this
Student Guide.

tly r
ric fo
st T
e EN
us C
Practice Files
re S

The Practice Files page tells


you how to download and install
d yA

the practice files that are


provided with this student guide.
an b

FTP link for practice files


d
ng e
yi vid
op ro
lc p
Al ple
m

Chapters
Sa

Each chapter begins with a brief


introduction and a list of the
chapter’s Learning Objectives.
Learning Objectives for
the chapter

© 2017, ASCENT - Center for Technical Knowledge® ix


CATIA V5-6R2016: Visual Basic Automation

n. nly
Instructional Content
Each chapter is split into a
series of sections of

de o
instructional content on specific

id w
topics. These lectures include
the descriptions, step-by-step

rb ie
Side notes procedures, figures, hints, and
Side notes are hints or information you need to achieve

fo rev
additional information for the chapter's Learning
the current topic. Objectives.

tly r
ric fo
st T
e EN
us C
Practice Objectives
re S

Practices
d yA

Practices enable you to use the


software to perform a hands-on
review of a topic.
an b

Some practices require you to


d

use prepared practice files,


which can be downloaded from
ng e

the link found on the Practice


yi vid

Files page.
op ro
lc p
Al ple
m
Sa

x © 2017, ASCENT - Center for Technical Knowledge®


Chapter

n. nly
de o
id w
rb ie
fo rev
Fundamentals

tly r
ric fo
Learning Topics in this Chapter

st T


e EN
Visual Basic Evolution
VB6
• VBA
us C
• VBScript and CATScript VB.NET
re S

• VB.NET
d yA

• In-process and Out-of-process Applications


• Registering CATIA Libraries
an b
d
ng e
yi vid
op ro
lc p
Al ple
m
Sa

© 2017, ASCENT - Center for Technical Knowledge® 1–1


CATIA V5-6R2016: Visual Basic Automation

1.1 Visual Basic Evolution


Each incarnation of Visual Basic has had a substantially different
syntax, as shown in Figure 1–1

n. nly
de o
id w
rb ie
Figure 1–1

fo rev
• The B.A.S.I.C. (Beginner's All-purpose Symbolic
Instruction Code) is a programming language that was
originally designed in 1963.

tly r
ric fo
• Visual Basic is Microsoft's dialect of BASIC including
controls, events, and IDE. It was very popular in 1980s

st T
and 1990s. CATIA V5 Automation was originally designed
e EN for VBScript, VBA, and VB6.
• VB.NET is a completely reworked version of VB. It
replaces VB6, which Microsoft no longer officially
us C
supports. However, it does not replace VBA or VBScript,
re S

both of which are still supported by Microsoft. VB.NET is


d yA

supported by CATIA V5R16 and up and should be


preferred over VB6 applications in the future. However, it
does not make VBA or VBScript scripts or macros
an b

obsolete.
d
ng e

CATIA
yi vid

Automation
op ro

Platforms
lc p
Al ple
m
Sa

Figure 1–2

1–2 © 2017, ASCENT - Center for Technical Knowledge®


Fundamentals

1.2 VB6
Visual Basic 6 (VB6) is an event-driven programming platform
and an associated integrated development environment (IDE) for
building graphical user interfaces (GUI) in the Microsoft

n. nly
Component Object Model (COM) programming model.

de o
Event-driven In event-driven programming, the flow of the program is

id w
determined by user actions (i.e., mouse clicks, key presses,
Programming

rb ie
etc.), or messages from other programs, as shown in Figure 1–3.

fo rev
tly r
ric fo
st T
e EN
us C
re S
d yA
an b
d
ng e
yi vid

Figure 1–3
op ro
lc p
Al ple
m
Sa

© 2017, ASCENT - Center for Technical Knowledge® 1–3


CATIA V5-6R2016: Visual Basic Automation

In contrast, in sequential programming the flow of the program is


determined by the programmer, as shown in Figure 1–4.

n. nly
de o
id w
rb ie
fo rev
tly r
ric fo
st T
e EN
us C
Figure 1–4
re S
d yA

IDE (Integrated IDE (Integrated Development Environment) is a type of computer


software that assists computer programmers in developing
Development
an b

software. It includes a source code editor, compiler or interpreter,


Environment) build-automation tools, debugger, and object browser, as shown
d

in Figure 1–5.
ng e
yi vid
op ro
lc p
Al ple
m
Sa

Figure 1–5

1–4 © 2017, ASCENT - Center for Technical Knowledge®


Fundamentals

GUI (Graphical GUI (Graphical User Interface) is a type of user interface that
enables you to interact with the computer using graphical
User Interface) elements (i.e., toolbars, icons, visual indicators, texts, labels,
etc.), which represent the available information and actions. The
actions are usually performed through direct manipulation of the

n. nly
graphical elements, as shown in Figure 1–6.

de o
id w
rb ie
fo rev
tly r
ric fo
st T
e EN
us C
re S
d yA
an b
d
ng e
yi vid
op ro

Figure 1–6
lc p
Al ple

COM COM (Component Object Model) is a Microsoft technology that


is designed to enable inter-process communication and dynamic
(Component object creation in any programming language. The term COM is
m

Object Model) often used as an umbrella term that encompasses OLE,


Sa

Automation, ActiveX, COM+, and DCOM technologies.

The essence of COM is a language-neutral way of implementing


software components. COM standard permits the reuse of
components with no knowledge of their internal implementation
because it forces component implementers to provide standard
binary interfaces that are separate from the implementation.

© 2017, ASCENT - Center for Technical Knowledge® 1–5


CATIA V5-6R2016: Visual Basic Automation

CATIA V5 is COM-enabled software, as shown in Figure 1–7.

Figure 1–7

n. nly
Codes for COM objects or components are stored in DLL
libraries and registered in the Windows registry. Therefore, they

de o
can be called, initiated, or created at any time.

id w
For example, if object A calls object B, object A is then the client

rb ie
and object B is the server (the one that provides services to the

fo rev
client). The client does not have to know the functions or
methods (i.e., interface) that the server contains in advance.
COM provides for a way to figure that out during the runtime.

tly r
This is called late binding. If the client is made aware of the

ric fo
server's interface before it is run, this is called early binding.

st T
e EN
us C
re S
d yA
an b
d
ng e
yi vid
op ro
lc p
Al ple
m
Sa

1–6 © 2017, ASCENT - Center for Technical Knowledge®


Fundamentals

1.3 VBA
The VB6 environment can be hosted in another application, such
as Excel, Word, CATIA, etc. and is event-driven and
GUI-oriented. It has full IDE (i.e., it contains an editor, debugger,

n. nly
type checker, object browser, etc.) as shown in Figure 1–8.
However, it cannot run without the host application running. The

de o
software can only be interpreted (i.e., executed line-by-line), and
might be slower than a compiled VB application.

id w
rb ie
fo rev
tly r
ric fo
st T
e EN
us C
re S
d yA
an b
d
ng e
yi vid

Figure 1–8
op ro
lc p
Al ple
m
Sa

© 2017, ASCENT - Center for Technical Knowledge® 1–7


CATIA V5-6R2016: Visual Basic Automation

1.4 VBScript and CATScript


VBScript is a subset of full VB syntax (some programming
features are omitted). It is designed to run in Web applications
(i.e., Internet Explorer, etc.) and is an extremely simple and

n. nly
limited tool. It does not contain IDE, debugging etc., and regular
text editors are used for coding. It is non-GUI-oriented and only a

de o
couple of very simple interactive dialog boxes are available. It is
non-event-driven and its code represents a flow with a sequence

id w
of actions that is determined by the programmer.

rb ie
fo rev
• CATScript is a portable version of VBScript. CATScript
macros can run on Unix, as shown in Figure 1–9.

tly r
ric fo
st T
e EN
us C
re S
d yA
an b
d
ng e
yi vid
op ro
lc p
Al ple
m

Figure 1–9
Sa

1–8 © 2017, ASCENT - Center for Technical Knowledge®


Fundamentals

1.5 VB.NET
VB.NET is the latest incarnation of the popular Microsoft
programming environment. It is also event-driven, has an
integrated development environment (IDE), and is used for

n. nly
building graphical user interfaces (GUI). However, it is not based
on COM (although it can call COM objects) and the syntax is

de o
quite different from VB6.

id w
The following difficulties are normally encountered when

rb ie
switching from VB6 to VB.NET:

fo rev
• New syntax

• New IDE

tly r
ric fo
• New GUI controls

st T
• New InstallShield
e EN When using VB.NET for CATIA automation, CATIA V5 is still a
us C
COM application. There is no change to how CATIA objects are
called and used.
re S
d yA
an b
d
ng e
yi vid
op ro
lc p
Al ple
m
Sa

© 2017, ASCENT - Center for Technical Knowledge® 1–9


CATIA V5-6R2016: Visual Basic Automation

1.6 In-process and


Out-of-process Applications
There are two ways in which a VB application or macro can

n. nly
communicate with CATIA: as an in-process or out-of-process
application.

de o
id w
In-process The VB application runs within the CATIA process in the

rb ie
computer memory. No inter-process communication is involved.
Applications CATIA freezes while the VB application is running. The VB

fo rev
application's allocation memory is wiped out after each run.
Therefore, passing data between two subsequent runs is not
possible.

tly r
ric fo
• Use the Tools>Macros interface (VBScript, CATScript, or
VBA).

st T
e EN
Out-of-process The VB application runs in its own process in the computer
memory. It communicates with CATIA using inter-process
us C
Applications messaging. CATIA is fully active while the VB application is
re S

running. For example, these applications could be VB.NET or


d yA

VB6 programs, VBA macros in Excel, Word, etc., or Windows


Explorer (i.e., embedded VBScript or Java scripts).
an b
d
ng e
yi vid
op ro
lc p
Al ple
m
Sa

1–10 © 2017, ASCENT - Center for Technical Knowledge®


Fundamentals

1.7 Registering CATIA Libraries


CATIA libraries are automatically registered in the Windows
registry when CATIA is installed. The registration enables you to
double-click on a CATPart or CATProduct to automatically start

n. nly
CATIA. A VB application or macro can also locate and
communicate with CATIA objects.

de o
Since CATIA libraries might change from release to release, a

id w
VB application that is developed or compiled with one CATIA

rb ie
release might or might not run correctly with another CATIA

fo rev
release. For example, a VB application developed for V5R21
might not work correctly with V5-6R2012, etc. Therefore, it is
recommended that you have the correct CATIA release

tly r
registered before the VB application is used.

ric fo
If several CATIA releases are installed on a computer, registering

st T
a specific release can be done by executing the following
e EN command from the Command Prompt:

<catia_executable> /regserver -env <catia_envir_file>


us C
-direnv <catia_envir_directory>
re S

For example, the following command registers CATIA


d yA

V5-6R2012 libraries on a Windows 7 64-bit system:


an b

"C:\Program Files\Dassault
Systemes\B22\win_b64\code\bin\
d
ng e

CNEXT.exe" /regserver -env CATIA.V5-6R2012.B22 -direnv


yi vid

"C:\Users\All Users\Application Data\DassaultSystemes\


CATEnv"
op ro
lc p
Al ple
m
Sa

© 2017, ASCENT - Center for Technical Knowledge® 1–11


CATIA V5-6R2016: Visual Basic Automation

n. nly
de o
id w
rb ie
fo rev
tly r
ric fo
st T
e EN
us C
re S
d yA
an b
d
ng e
yi vid
op ro
lc p
Al ple
m
Sa

1–12 © 2017, ASCENT - Center for Technical Knowledge®

Vous aimerez peut-être aussi