0% found this document useful (0 votes)
235 views

Catia Visual Basic Automation

Uploaded by

melvin ekbote
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
235 views

Catia Visual Basic Automation

Uploaded by

melvin ekbote
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

y.

nl
O
e
n. Us
tio al
bu rn
CATIA V5-6R2018
tri e
is Int
Visual Basic Automation
r D ide
Fo w
ot rld
N o

Learning Guide
W

1st Edition
D
AN

Cover Page
rR
Fo
ASCENT - Center for Technical Knowledge®
CATIA V5-6R2018
Visual Basic Automation
1st Edition
Prepared and produced by:
ASCENT Center for Technical Knowledge
630 Peter Jefferson Parkway, Suite 175
Charlottesville, VA 22911

y.
866-527-2368
www.ASCENTed.com

nl
Lead Contributor: Scott Hendren
Copyright

O
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

e
focused on specializing in the creation of education programs that incorporate the best of classroom

n. Us
learning and technology-based training offerings.

We welcome any comments you may have regarding this guide, or any of our products. To contact us
please email: [email protected].

tio al
© ASCENT - Center for Technical Knowledge, 2020

bu rn
All rights reserved. No part of this guide may be reproduced in any form by any photographic, electronic,

tri e
mechanical or other means or used in any information storage and retrieval system without the written
is Int
permission of ASCENT, a division of Rand Worldwide, Inc.

CATIA and ENOVIA are registered trademarks of Dassault Systèmes.


r D ide

All other brand names, product names, or trademarks belong to their respective holders.
General Disclaimer:
Fo w

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 informational purposes only and is not
ot rld

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 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
N o

expenses. No consequential damages can be sought against ASCENT or Rand Worldwide, Inc. for the use of these
materials by any third parties or for any direct or indirect result of that use.
W

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 professional advice, nor does
it constitute a comprehensive or complete statement of the issues discussed thereto. ASCENT does not warrant that the
D

document or information will be error free or will meet any 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
AN

software). Rand Worldwide, Inc. specifically disclaims any warranty, either expressed or implied, including the warranty
of fitness for a particular purpose.
rR
Fo

AS-56CAT18-VBA1-SG // RS-56CAT18-VBA1-SG
C o n t e n ts

y.
nl
O
Preface ........................................................................................................... vii

e
n. Us
In this Guide ................................................................................................... ix

Practice Files .................................................................................................. xi

tio al
Chapter 1: Fundamentals............................................................................. 1-1

bu rn
1.1 Visual Basic Evolution.................................................................... 1-2
tri e
CATIA Programming Platforms......................................................... 1-2
is Int
1.2 VB6 Platform.................................................................................... 1-3
Event-driven Programming ............................................................... 1-3
r D ide

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


GUI (Graphical User Interface) ......................................................... 1-5
Fo w

COM (Component Object Model)...................................................... 1-5


ot rld

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


1.4 VBScript and CATScript ................................................................. 1-8
N o
W

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


1.6 In-process and Out-of-process Applications ............................. 1-10
D

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


Out-of-process Applications ............................................................ 1-10
AN

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


rR

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


2.1 Objects Oriented Programming..................................................... 2-2
Fo

Objects .............................................................................................. 2-2


Classes and Instances ...................................................................... 2-3
CATIA Objects and Classes.............................................................. 2-4
Example of an Object in CATIA ........................................................ 2-6
Object Instantiation and Referencing in CATIA................................. 2-6
2.2 Inheritance ....................................................................................... 2-8
Example of Inheritance in CATIA ...................................................... 2-8

© 2020, ASCENT - Center for Technical Knowledge® i


CATIA V5-6R2018: Visual Basic Automation

2.3 Aggregation ................................................................................... 2-10


Example of Aggregation in CATIA .................................................. 2-10
2.4 Abstract Class ............................................................................... 2-12
Example of Abstract Class in CATIA............................................... 2-13
2.5 Collections..................................................................................... 2-14
2.6 CATIA Object Diagram.................................................................. 2-16
2.7 CATIA Automation Documentation ............................................. 2-17

y.
Practice 2a Navigating Automation Documentation......................... 2-19

nl
O
Chapter 3: Introduction to Macros .............................................................. 3-1
3.1 Introduction ..................................................................................... 3-2

e
n. Us
3.2 Macro Libraries ............................................................................... 3-3
3.3 Recording Macros........................................................................... 3-4

tio al
3.4 Viewing or Editing Macros ............................................................. 3-5
Interpreting Macro Recordings.......................................................... 3-6

bu rn
Replaying a Macro ............................................................................ 3-7
tri e
Executing a Macro on CATIA startup................................................ 3-7
is Int
Macros with Parameters ................................................................... 3-8
3.5 Assigning a Macro to a Toolbar..................................................... 3-9
r D ide

Practice 3a Square Pad with Parameters........................................... 3-10


Practice 3b Series of Round Pads ...................................................... 3-16
Fo w
ot rld

Chapter 4: Introduction to VBA ................................................................... 4-1


4.1 Overview .......................................................................................... 4-2
N o
W

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


4.3 Forms and Controls ........................................................................ 4-4
D

4.4 Modules............................................................................................ 4-5


AN

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


4.6 Type Libraries.................................................................................. 4-7
rR

4.7 Object Browser................................................................................ 4-8


Fo

4.8 Programming Tips .......................................................................... 4-9


Explicit vs Implicit Variable Declaration............................................. 4-9
Running and Debugging ................................................................. 4-10
Starting a User Form from CATIA ................................................... 4-11
4.9 Error Handling ............................................................................... 4-12

ii © 2020, ASCENT - Center for Technical Knowledge®


Contents

4.10 Restricted CATIA Interfaces......................................................... 4-13


Restricted Interface Error Example ................................................. 4-14
Handling Restricted Interfaces ........................................................ 4-15
Practice 4a Simple User Form with Controls..................................... 4-17

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


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

y.
5.2 Documents Collection .................................................................... 5-3

nl
5.3 Windows Collection ........................................................................ 5-4

O
5.4 SystemConfiguration Object.......................................................... 5-5
Practice 5a Creating and Saving a Part................................................ 5-6

e
n. Us
Practice 5b Opening a Product ............................................................. 5-8

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

tio al
6.1 Part Document Object Diagram ..................................................... 6-2

bu rn
6.2 Bodies Collection............................................................................ 6-4
tri e
6.3 HybridBodies Collection ................................................................ 6-5
is Int
Practice 6a Working with Part Infrastructure ...................................... 6-6
r D ide

Chapter 7: Part Design Automation ............................................................ 7-1


7.1 Part Design Object Diagram........................................................... 7-2
Fo w

Types of Shape Objects.................................................................... 7-3


ot rld

7.2 Sketch Object Diagram................................................................... 7-4


7.3 Creating Sketches........................................................................... 7-5
N o

Creating Sketch Geometry................................................................ 7-5


W

Creating Sketch Constraints ............................................................. 7-6


D

7.4 Creating Solid Features.................................................................. 7-7


AN

7.5 Reference Object............................................................................. 7-8


7.6 In Work Object and Part Update .................................................... 7-9
rR

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

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


Fo

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


Types of Hybrid Shape Objects ........................................................ 8-3
8.2 HybridBody Object.......................................................................... 8-4
8.3 HybridShapeFactory Object........................................................... 8-5
8.4 Creating Shape Features................................................................ 8-6
Practice 8a Working with Shape Design .............................................. 8-7

© 2020, ASCENT - Center for Technical Knowledge® iii


CATIA V5-6R2018: Visual Basic Automation

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


9.1 Product Document Object Diagram .............................................. 9-2
9.2 Product Properties.......................................................................... 9-3
9.3 Reference Product .......................................................................... 9-4
Building Product Structure ................................................................ 9-5
9.4 Positioning Assembly Components.............................................. 9-6
Transformation Matrix ....................................................................... 9-7

y.
9.5 Assembly Constraints .................................................................... 9-8

nl
Analyze Object and Bill of Materials.................................................. 9-9

O
Practice 9a Working with Assembly Design...................................... 9-10

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

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

tio al
Sheets ............................................................................................. 10-3

bu rn
Views............................................................................................... 10-4

tri e
10.3 Drawing View Object Diagram ..................................................... 10-5
is Int
10.4 GenerativeBehaviour Object........................................................ 10-6
10.5 Creating Generative Views........................................................... 10-7
r D ide

View Projection Plane and Direction ............................................... 10-8


View Positioning.............................................................................. 10-9
Fo w

10.6 Creating Dimensions .................................................................. 10-10


ot rld

10.7 Creating Annotations.................................................................. 10-11


Drawing Text Object...................................................................... 10-12
N o

Drawing Table Object.................................................................... 10-13


W

10.8 Creating Non-Generative Geometry .......................................... 10-15


D

10.9 Creating Frame and Title Block ................................................. 10-16


AN

Frame and Title Block Macros ...................................................... 10-16


Creating Frame and Title Block Macro.......................................... 10-17
Practice 10a Creating Drawing Views .............................................. 10-18
rR

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


Fo

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


11.1 Selection Object ............................................................................ 11-2
11.2 Working with Selections............................................................... 11-3
Adding Elements to Selection ......................................................... 11-3
11.3 Modifying Graphic Properties...................................................... 11-5
Practice 11a Working with Graphic Properties ................................. 11-6

iv © 2020, ASCENT - Center for Technical Knowledge®


Contents

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


12.1 Interactive Selection Options....................................................... 12-2
12.2 Selection Parsing Methods .......................................................... 12-3
Item Method .................................................................................... 12-3
FindObject Method.......................................................................... 12-4
12.3 Interactive Methods ...................................................................... 12-5
SelectElement* Methods................................................................. 12-5

y.
Using SelectElement Methods ........................................................ 12-5

nl
IndicateOrSelectElement* Methods ................................................ 12-6

O
Practice 12a Parsing Pre-Selected Elements .................................... 12-7
Practice 12b Working with SelectElement2 ..................................... 12-10

e
n. Us
Chapter 13: Cut, Copy, Paste, and Delete ................................................ 13-1
13.1 Deleting CATIA Objects................................................................ 13-2

tio al
13.2 Copying and Pasting CATIA Objects .......................................... 13-3

bu rn
13.3 Paste Options ................................................................................ 13-4

tri e
Practice 13a Copying and Pasting between Parts ............................ 13-5
is Int
Chapter 14: Parameters and Formulas..................................................... 14-1
r D ide

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


14.2 Parameters Object Model ............................................................. 14-3
Fo w

14.3 Creating Parameters ..................................................................... 14-4


ot rld

14.4 Valuating Parameters ................................................................... 14-5


N o

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


W

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


14.7 Creating Relations ........................................................................ 14-8
D

Practice 14a Measuring Spline Length using Formula..................... 14-9


AN

Chapter 15: Communication with Microsoft Office ................................. 15-1


rR

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


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

15.3 Registering Libraries .................................................................... 15-4


15.4 GetObject and CreateObject Methods ........................................ 15-5
Handling Errors when Contacting Server ........................................ 15-5
Practice 15a Exporting CATIA Data to Excel ..................................... 15-7
Practice 15b Exporting Excel Data to CATIA................................... 15-11

© 2020, ASCENT - Center for Technical Knowledge® v


CATIA V5-6R2018: Visual Basic Automation

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


Practice 1a Practice A1.......................................................................... A-2
Practice 1b Practice A2.......................................................................... A-6
Practice 1c Practice A3........................................................................ A-10
Practice 1d Practice A4........................................................................ A-11
Practice 1e Practice A5........................................................................ A-13

y.
Practice 1f Practice A6......................................................................... A-15

nl
Practice 1g Practice A7........................................................................ A-17

O
Practice 1h Practice A8........................................................................ A-19

e
Practice 1i Practice A9......................................................................... A-23

n. Us
Practice 1j Practice A10....................................................................... A-27
Practice 1k Practice A11...................................................................... A-31

tio al
Practice 1l Practice A12....................................................................... A-35

bu rn
Practice 1m Practice A13..................................................................... A-37
tri e
Practice 1n Practice A14...................................................................... A-38
is Int
Practice 1o Practice A15...................................................................... A-40
Practice 1p Practice A16...................................................................... A-42
r D ide

Practice 1q Practice A17...................................................................... A-44


Fo w

Practice 1r Practice A18 ...................................................................... A-46


ot rld
N o
W
D
AN
rR
Fo

vi © 2020, ASCENT - Center for Technical Knowledge®

You might also like