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

Catia v5 Macro Programming With Visual Basic Script

This document provides an overview of CATIA macro programming using Visual Basic Script (CATScript). It introduces basic concepts like objects, classes, object paths, macro structure, and tools for interacting with the CATIA environment. Specific topics covered include working with CATIA documents, selecting and recognizing elements, modifying appearances, reading/writing data, and using parameters, references and other CATPart components in macros.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
175 views

Catia v5 Macro Programming With Visual Basic Script

This document provides an overview of CATIA macro programming using Visual Basic Script (CATScript). It introduces basic concepts like objects, classes, object paths, macro structure, and tools for interacting with the CATIA environment. Specific topics covered include working with CATIA documents, selecting and recognizing elements, modifying appearances, reading/writing data, and using parameters, references and other CATPart components in macros.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

CATIA

Macro Programming with


Visual Basic Script

Dieter R. Ziethen
TransMedbyK/e E Brand

New ''ark Chicago Sazs fi•azscisco


Liehoa Lozsdozz Madzzé Mexico City
Milan Xew De1bi Saa Juaa
Seoul Siztgapoxe Sydzsey 3’oroato
Contents

fiefaCe.............................................................................................................XVii

1 Basics............................................................................................1

1.1 Definition of CATScript and CATVBS......................................................................1


1.2 Definition of Nomenclature...................................................................................3
1.3 Definition of Object, Class, and Object Path..............................................................4
1.3.1 Object and Class.............................................................................................................................4
1.3.2 Object Path......................................................................................................................................4
1.3.3 Root Class and Base Classes.......................................................................................................5
1.4 Basic Example of a Macro....................................................................................6
1.5 Selecting a Macro Editor......................................................................................8
1.6 Storage of a Macro.............................................................................................9
1.6.1 Storage in a CATIA Document................................................................................................10
1.6.2 Storage in a Separate File...........................................................................................................10
1.7 Starting a Macro from a Button..........................................................................11
1.7.1 Assigning a Macro to a Button.................................................................................................12
1.7.2 Creating a Toolbar.......................................................................................................................12
1.7.3 Assigning a Button to a Toolbar............................................................................................14
1.8 Blocks of a Macro............................................................................................14
!.8.1 Head of a Macro ..,........................................................................................................................15
1.8.2 Declaration of Global Variables and Objects.......................................................................16
1.8.3 CATMain, Subroutines, and Functions................................................................................17
1.9 Branches and Loops...........................................................................................................19
1.9.1 If-Then-Else..................................................19
1.9.2 Select-Case-Else................................................20
1.9.3 For-Next....................................................21
1.9.4 Do-While,...................................................21
1.9.5 DoUntIl....................................................22
1.10 Anchor Objects of CATScript............................................................................................................23
1.10.1 CATIA-Application...................................................................................................................23
1.102 CATIA Documents “CATPart” and “CATProduct”.............................................................24
1.10.3 Geometry Containers in CATParts........................................................................................25
1.10.4 Structural Information and Metadata..................................................................................26
1.11 Using the Macro Recorder...................................................................................28
1.12 Additional Information......................................................................................29

2 Communicating with the Environment...............................................31

2.1 Screen Output and Input..................................................................................................................31


2.1.1 ScreenOutput................................................31
2.1.2 Screenlnput.................................................33
2.2 Create, Load, and Save CATIA Documents................................................34
2.2.1 Creating Documents.....................................................................................................................35
2.2.2 Loading Documents.....................................................................................................................36
2.2.3 Saving Documents.........................................................................................................................37
2.3 User Selestion of CATIA Elements...................................................................................................38
2.3.1 Selection before Starting a Macro..........................................................................................39
2.3.2 Selection during the Execution of a Macro........................................................................40
2.4 Searching and Recognizing Elements....................................................................41
2.4.1 Search......................................................................................................................41
2.4.2 Recognize................................................................................................................42
2.5 Coorand HideEements:::::::::::::::.::::::::::::::.::::::::::::::::::44
2.5.1 Coloring Elements.........................................................................................................................44
2.5.2 Hiding Elements............................................................................................................................45
2.6 Reading and Writing Data...................................................................................46
2.6.1 Create or Declare a File................................................................................................................46
2.6.2 Reading Data....................................................................................................................................47
2.6.3 Writing Data...................................................................................................................................48
2.7 Executing External Programs and CATScripts..............................................................................48
2.7.1 External Program........................................................................................................................49
2.7.2 External CATScript.......................................................................................................................49
2.8 Reading Environment Variables............................................................................50
Components of CATParts.......................................................................53

3.1
Anributes..........................................sg
3.1.1
Standard Attributes....................................................................................................................54
3.1.2
Custom Attributes........................................................................................................................54
3.2 Origin Elements.......................................................................................................,............................55
3.3 Bodies, Geometrical Sets, and Ordered Geometrical Sets...................................................55
3.3.1 Bodies.....................................................................................................................56
3.3.2 Geometrical Sets....................................................................................................58
3.3.3 Ordered Geometrical Sets......................................................................................59
3.3.4 Boolean Operations between Bodies.....................................................................61
3.4 Parameters and Relations................................................................................................................65
3.4.1 Parameter..................................................65
3.4.2 DesignTable................................................66
3.4.3 Formulas..................................................68
3.5 References.......................................................................................................................................69
3.5.1 References to Geometry..............................................................................................................70
3.5.2 References to Objects...................................................................................................................70
3.5.3 References to Object Names......................................................................................................70
3.5.4 References to the Name of the Boundary Representation.............................................71
3.6 Direction Definition........................................................................................................................74
3.6.1 Direction Defined by a Vector.................................................................................................75
3.6.2 Direction Defined by an Object...............................................................................................75

4 Components of CATProducts..............................................................77

4.1 Attributes.....................................................................................................77
4.2 Parameters and Formulas..................................................................................78
4.3 Assembly Structure..........................................................................................78
4.3.1 Analyzing an Existing Structure.............................................................................78
4.3.2 Adding Elements.....................................................................................................79
4.3.3 Replacing Elements..................................................................................................80
4.3.4 Deleting Elements..................................................................................................80
4.4 Constraints........................................................................................................................................81

2D Wireframe Geometry...........................................................................83

5.1 Sketch References and Sketch Objects..................................................................83


5.2 Creating Sketch Geometry..................................................................................85
5.3 Defining Construction Elements and the Rotation Axis..............................................88
5.4 Creating Constraints........................................................................................89

3D Wireframe Geometry and Surfaces........................................91

6.1 General Procedure...........................................................................................................91


6.2 Points...............................................................................................................................93
6.2.1 Methods for Creating Points....................................................................................................93
6.2.2 Case Studies: Points.....................................................................................................................95
6.3 Lines..................................................................................................................................................96
6.3.1 Methods for Creating Lines......................................................................................................97
6.3.2 Case Studies: Lines........................................................................................................................99
6.4 Planes.............................................................................................................................................101
6.4.1 Methods for Creating Planes................................................................................................101
6.4.2 Case Studies: Planes..................................................................................................................102
6.5 Cunes..............................................................................................................................................104
6.5.1 Methods for Creating Curves................................................................................................106
6.5.2 Case Studies: Curves.................................................................................................................109
6.6 Surfaces.......................................................111
6.6.1 Methods for Creating Surfaces.............................................................................................112
6.6.2 Case Studies: Surfaces..............................................................................................................113
6.7 Transformations.......................................................................................................................11 s
6.7.1 Methods for Creating Transformations............................................................................116
6.7.2 Case Studies: Transformations.............................................................................................117
6.8 Operations..................................................................................................................................118
6.8.1 Methods for Creating Operations.......................................................................................119
6.8.2 Case Studies: Operations.........................................................................................................121

7 Solids.........................................................................................123

7.1 General Procedure........................................................................................................................1 24


7.2 Sketch-Based Solids......................................................................................................................125
7.2.1 Methods for Creating Sketch-Based Solids .....................,..................................................126
7.2.2 Case Studies: Sketch-Based Solids.........................................................................................127

7.3 Surface-Based Solids....................................................................................................................... 129


7.3.1 Methods for Creating Surface-Based Solids......................................................................129
7.3.2 Case Studies: Surface-Based Solids ..................................,......................................................130
7.4 Transformation-Based Solids........................................................................................................132
7.4.1 Methods for Creating Transformation-Based Solids.....................................................133
7.4.2 Case Studies: Transformation-Based Solids......................................................................135
7.5 Operations.................................................................................................................................137
7.5.1 Methods for Creating Operations on Solids....................................................................138
7.5.2 Case Studies: Operations.........................................................................................................139

8 Featured Object Classes....................................................................143

8.1 Add.............................................................................................................143
8.2 Angle..........................................................................................................143
8.3 AngularRepartition.......................................................................................144
8.4 Any0bject...................................................................................................144
8.5 Application..................................................................................................145
8.6 Assemble...................................................................................................149
8.7 Axis2D........................................................................................................149
8.8 Bodies........................................................................................................150
8.9 Body...........................................................................................................150
8.10 BooleanShape.............................................................................................151
8.11 BoolParam..................................................................................................152
8.12 CATBaseDispatch.......................................................................................152
8.13 Chamfer......................................................................................................152
8.14 Circle2D......................................................................................................154
8.15 CircPattern..................................................................................................155
8.16 CloseSurface .......................,..........................................................................157
8.17 Collection....................................................................................................157
8.18 ConstRadEdgeFillet .............,...........................................................................158
8.19 Constraint...................................................................................................159
8.20 Constraints.................................................................................................163
8.21 ControlPoint2D............................................................................................164
8.22 Curve2D.....................................................................................................165
8.23 DesignTable.................................................................................................167
8.24 Dimension...................................................................................................169
8.25 Document.....................................................................................................................169
8.26 Documents.................................................................................................173
8.27 Draft..............,...................................................................................................................174
8.28 DraftDomain................................................................................................175
8.29 DraftD0mains..................................................................................................1..7.6...............
8.30 DressUpShape................................,...............................................................177
8.31 EdgeFillet........................................................................................................1..7.7...............
8.32 Ellipse2D....................................................,.....................................................178
8.33 FaceFillet.....................................................................................................179
8.34 Factory.......................................................................................................179
8.35 Factory2D....................................................................................................180
8.36 File.............................................................................................................182
8.37 FileComponent............................................................................................182
8.38 Files............................................................................................................183
8.39 FileSystem..................................................................................................183
8.40 Fillet............................................................................................................185
8.41 Folder.........................................................................................................186
8.42 Folders.......................................................................................................186
8.43 Formula.......................................................................................................186
8.44 GeometricElement.......................................................................................187
8.45 GeometricElements.....................................................................................187
8.46 Geometry2D................................................................................................187
8.47 Groove........................................................................................................188
8.48 Hole............................................................................................................188
8.49 HybridBodies..............................................................................................192
8.50 HybridBody..................................................................................................192
8.51 HybridShape................................................................................................193
8.52 HybridShape3DCurve0ffset..........................................................................194
8.53 HybridShapeAffinity.....................................................................................195
8.54 HybridShapeAssemble.................................................................................196
8.55 HybridShapeAxisLine...................................................................................200
8.56 HybridShapeAxisToAxis.................................................................................201
8.57 HybridShapeBlend.......................................................................................202
8.58 HybridShapeBoundary.................................................................................208
8.59 HybridShapeCircle........................................................................................20a
8.60 HybridShapeCircle2PointsRad......................................................................211
8.61 HybridShapeCircle3Points............................................................................213
8.62 HybridShapeCircleBitangentPoint.................................................................214
8.63 HybridShapeCircleBitangentRadius...............................................................216
8.64 HybridShapeCircleCenterAxis.......................................................................218
8.65 HybridShapeCircleCenterTangent.................................................................219
8.66 HybridShapeCircleCtrR................................................................................221
8.67 HybridShapeCircleCtrRad...............................................................................223
8.68 HybridShapeCircleExplicit............................................................................224
8.69 HybridShapeCircleTritangent.............,...........................................................225
8.70 HybridShapeCombine..................................................................................227
8.71 HybridShapeConic.........................................................................................228
8.72 HybridShapeConnect...................................................................................232
8.73 HybridShapeCorner.....................................................................................234
8.74 HybridShapeCurveExplicit............................................................................237
8.75 HybridShapeCurvePar ..............................................................................................2..3..7....
8.76 HybridShapeCurveSmooth......................................................................240
8.77 HybridShapeCylinder...............................................................................243
8.78 HybridShapeDirection.............................................................................244
8.79 HybridShapeExtract................................................................................246
8.80 HybridShapeExtractMulti..........................................................................248
8.81 HybridShapeExtrapoi...............................................................................use
8.82 HybridShapeExtremum.............................................................................254
8.83 HybridShapeExtremumPolar.....................................................................use
8.84 HybridShapeExtrude...............................................................................257
8.85 HybridShapeFactory................................................................................25g
8.86 HybridShapeFill......................................................................................2gg
8.87 HybridShapeFilletBiTangent.....................................................................292
8.88 HybridShapeFilletTriTangent....................................................................295
8.89 HybridShapeHelix...................................................................................296
8.90 HybridShapelntegratedLaw......................................................................299
8.91 HybridShapelntersection..........................................................................302
8.92 HybridShapelnverse................................................................................303
8.93 HybridShapeLawDistProj.........................................................................304
8.94 HybridShapeLineAngle............................................................................306
8.95 HybridShapeLineBisecting.......................................................................308
8.96 HybridShapeLineBiTangent......................................................................310
8.97 HybridShapeLineExplicit..........................................................................311
8.98 HybridShapeLineNormal...........................................................................312
8.99 HybridShapeLineRDir..............................................................................313
8.100 HybridShapeLineRR...............................................................................315
8.101 HybridShapeLineTangency......................................................................317
8.102 HybridShapeLoft.....................................................................................319
8.103 HybridShapeNear...................................................................................325
8.104 HybridShapeoffset..................................................................................326
8.105 HybridShapePlane1Curve........................................................................327
8.106 HybridShapePlane1LinelR.......................................................................328
8.107 HybridShapePlane2Lines.........................................................................328
8.108 HybridShapePlane3Points.......................................................................329
8.109 HybridShapePlaneAngle..........................................................................329
8.110 HybridShapePlaneEquation......................................................................331
8.111 HybridShapePlaneExplicit........................................................................332
8.112 HybridShapePlaneMean..........................................................................332
8.113 HybridShapePlaneNormal........................................................................333
8.114 HybridShapePlaneOffset..........................................................................334
8.115 HybridShapePlaneOffsetR.......................................................................335
8.116 HybridShapePlaneTangent.......................................................................335
8.117 HybridShapePointBeMeen.......................................................................336
8.118 HybridShapePointCenter.........................................................................337
8.119 HybridShapePointCoord...............................................................................337
8.120 HybridShapePointExplicit.............................................................................338
8.121 HybridShapePointOnCurve..........................................................................338
8.122 HybridShapePointOnPlane...........................................................................340
8.123 HybridShapePoint0nSurface.........................................................................341
8.124 HybridShapePointTangent...........................................................................342
8.125 HybridShapePolyline....................................................................................343
8.126 HybridShapePositionTransfo........................................................................344
8.127 HybridShapeProject.....................................................................................347
8.128 HybridShapeReflectLine...............................................................................348
8.129 HybridShapeRevol.......................................................................................350
8.130 HybridShapeRotate.....................................................................................351
8.131 HybridShapes...............................................................................................353
8.132 HybridShapeScaling....................................................................................353
8.133 HybridShapeSection....................................................................................354
8.134 HybridShapeSphere.....................................................................................354
8.135 HybridShapeSpine.......................................................................................356
8.136 HybridShapeSpiral.......................................................................................358
8.137 HybridShapeSpline......................................................................................360
8.138 HybridShapeSplit.........................................................................................365
8.139 HybridShapeSurfaceExplicit.........................................................................368
8.140 HybridShapeSweep.....................................................................................368
8.141 HybridShapeSweepCircle.............................................................................369
8.142 HybridShapeSweepConic...............................................................................375
8.143 HybridShapeSweepExplicit...........................................................................380
8.144 HybridShapeSweepLine...............................................................................386
8.145 HybridShapeSymmetry................................................................................395
8.146 HybridShapeThickness................................................................................396
8.147 HybridShapeTranslate.................................................................................397
8.148 HybridShapeTrim.........................................................................................399
8.149 Hyperb0la2D...............................................................................................402
8.150 Intersect......................................................................................................403
8.151 IntParam.....................................................................................................404
8.152 Knowledge0bject.........................................................................................405
8.153 KnowledgeActivateobject.............................................................................405
8.154 Length........................................................................................................406
8.155 Limit............................................................................................................406
8.156 Line............................................................................................................407
8.157 Line2D.........................................................................................................408
8.158 LinearRepartition.........................................................................................408
8.159 Loft.............................................................................................................409
8.160 Mirror..........................................................................................................409
8.161 OrderedGeometricalSet...............................................................................410
8.162 OrderedGeometricalSets...............................................................................411
8.163 0riginElements.............................................................................................412
8d64 pad..................................................................................................................................
8.165 Paraboia2D................................................................................................413
8.166 Parameter..................................................................................................413
8.167 Parameters.................................................................................................41s
8.168 Part...............................................................................................................4..1.7.................
8.169 PartDocument.............................................................................................421
8.170 Pattern.......................................................................................................422
8.171 Plane.........................................................................................................423
8.172 P0Cket............................................................................................................................424
8.173 Point .................................................................................................................................4 5
8.174 P0lnt2D...........................................................................................................................425
8.175 Prism..........................................................................................................426
8.176 PfOdUCt.........................................................................................................................427
8.177 ProductDocument.......................................................................................430
8.178 Products......................................................................................................431
8.179 RealParam.................................................................................................433
8.180 RectPattern.................................................................................................434
8.181 Reference....................................................................................................437
8.182 References..................................................................................................437
8.183 Relation......................................................................................................437
8.184 Relations.....................................................................................................439
8.185 Remove......................................................................................................440
8.186 RemoveFace...............................................................................................441
8.187 Repartiti0n..................................................................................................442
8.188 ReplaoeFace..............................................................................................442
8.189 Revolution...................................................................................................443
8.190 Rib..............................................................................................................443
8.191 Rotate.........................................................................................................444
8.192 Scaling.......................................................................................................445
8.193 Scaling2.....................................................................................................445
8.194 SelectedElement.........................................................................................446
8.195 Selection.....................................................................................................447
8.196 SewSurface................................................................................................452
8.197 Shaft..........................................................................................................453
8.198 Shape.........................................................................................................453
8.199 ShapeFactory...............................................................................................453
8.200 Shapes.......................................................................................................467
8.201 Shell...........................................................................................................468
8.202 Sketch........................................................................................................469
8.203 SketchBasedShape.....................................................................................471
8.204 Sketches........................................................................................................4..7.1................
8.205 Slot.............................................................................................................472
8.206 SolidCombine...............................................................................................472
8.207 Spline2D......................................................................................................473
8.208 Split............................................................................................................474
8.209 Stiffener......................................................................................................474
8.210 StrParam.....................................................................................................475
8.211 SurfaceBasedShape....................................................................................476
8.212 Sweep........................................................................................................476
8.213 Symmetry....................................................................................................479
8.214 SystemService............................................................................................479
8.215 TextStream..................................................................................................481
8.216 Thickness...................................................................................................482
8.217 ThickSurface...............................................................................................483
8.218 Thread.........................................................................................................484
8.219 TransformationShape....................................................................................485
8.220 Translate.....................................................................................................486
8.221 Trim.............................................................................................................486
8.222 TritangentFillet.............................................................................................487
8.223 UserPattern.................................................................................................488
8.224 VarRadEdgeFillet..........................................................................................489
8.225 VisPropertySet............................................................................................490

9 Featured VBScript Commands...........................................................497

9.1 Abs.............................................................................................................497
9.2 Asc.............................................................................................................497
9.3 Boolean......................................................................................................498
9.4 Byte...........................................................................................................498
9.5 CBool..........................................................................................................498
9.6 CByte.........................................................................................................498
9.7 CDate.........................................................................................................499
9.8 C0bl.............................................................................................................499
9.9 Chr..............................................................................................................499
9.10 Clnt.............................................................................................................500
9.11 CLng...........................................................................................................500
9.12 Const...........................................................................................................500
9.13 Cos.............................................................................................................501
9.14 CSng......................................................................................... so1
9.15 CStr............................................................................................................501
9.16 Date............................................................................................... s02
9.17 Day.............................................................................................................502
9.18 Dim.............................................................................................................502
9.19 Dim 0.............................................................................................................5.0..3................
9.20 Double........................................................................................................503
9.21 Do-UntiI.......................................................................................................st3
9.22 D0-While.....................................................................................................503
9.23 Empty.........................................................................................................503
9.24 End ...................................................................................................................................5 4
9.25 Err..............................................................................................................504
9.26 Exit.............................................................................................................504
9.27 Exp.............................................................................................................504
9.28 Fix..............................................................................................................505
9.29 For-Next......................................................................................................505
9.30 Function.....................................................................................................505
9.31 Hour............................................................................................................505
9.32 If-Then-Else...................................................................................................506
9.33 InputBox.....................................................................................................506
9.34 lnstr............................................................................................................506
9.35 Int...............................................................................................................506
9.36 Integer........................................................................................................507
9.37 lsDate.........................................................................................................507
9.38 lsEmpty......................................................................................................507
9.39 lsNull..........................................................................................................508
9.40 IsNumeric...................................................................................................508
9.41 Join............................................................................................................508
9.42 LCase.........................................................................................................509
9.43 Left.............................................................................................................509
9.44 Len.............................................................................................................509
9.45 Log.............................................................................................................510
9.46 Long...........................................................................................................510
9.47 LTrim..........................................................................................................510
9.48 Mid.............................................................................................................511
9.49 Minute........................................................................................................511
9.50 Mod............................................................................................................511
9.51 Month.........................................................................................................512
9.52 MsgBox..........................................................................................................5..1.2................
9.53 Now............................................................................................................512
9.54 Null.............................................................................................................512
9.55 0n Error Resume Next.....................................................................................513
9.56 Randomize......................................................................................................5.1..3...............
9.57 ReDim............................................................................................................5..1.3................
9.58 Rem............................................................................................................514
9.59 Right.............................................................................................................5..1..4................
9.60 Rnd........................................................................................... 514
9.61 RTrim..........................................................................................................514
9.62 Second...........................................................................................................5.1..5................
9.63 Select Case.....................................................................................................5..1.5...............
9.64 Set..............................................................................................................515
9.65 Sin..............................................................................................................515
9.66 Single.........................................................................................................516
9.67 Sgn.............................................................................................................516
9.68 Sqr..............................................................................................................516
9.69 StrReverse..................................................................................................517
9.70 String..........................................................................................................517
9.71 Sub.............................................................................................................517
9.72 Tan.............................................................................................................517
9.73 Time...........................................................................................................518
9.74 Timer..........................................................................................................518
9.75 TimeValue...................................................................................................518
9.76 Trim............................................................................................................519
9.77 UCase ............................................,.................................................................519
9.78 Year............................................................................................................519

Index....................................................................................................................521

You might also like