Ads

Sunday, January 29, 2012

Published my third book

I published my third book. This one is all about writing macros for the CAD system. It's called VB Scripting for CATIA V5: How to write macros. Available in paperback and Kindle eBook additions.

Here is a brief excerpt from Chapter 2 of the book:


Get Workbench


The Document object also has methods such as the “GetWorkbench” method. The GetWorkbench command takes a string as an argument and returns a Workbench object. To load the structural workbench:
Dim doc1 as Document
Set doc1 = CATIA.ActiveDocument
Dim workbench1 as Workbench
Set workbench1 =doc1.GetWorkbench(“Structural”)

Work with Collections: Count and Item


Collections are special kinds of objects that hold a list of objects of a certain class. The property “Count” and the method “Item()” are frequently used on collections in CATIA. For example:

Sub CATMain()
'Count the number of open documents
Dim docs1 as Documents
Set docs1 = CATIA.Documents
MsgBox “The number of open documents is “ & docs1.Count
'Accessing the first Document object in the collection
Dim doc1 as Document
Set doc1 = docs1.Item(1)
MsgBox “The FullName of the first document is “ & doc1.FullName
End Sub

No comments: