Tuesday, July 24, 2012

VB Scripting for CATIA V5 Giveaway!


catia v5 automation programming tutorialAre you looking for a free VB Scripting for CATIA V5 pdf download? How would you like a chance at getting a free copy of my ebook VB Scripting for CATIA V5? One of the only online sources where you can find how to write CATIA V5 macros, this 100+ page ebook includes step-by-step tutorials to teach you CATIA automation programming. These scripting tutorials sell for $34.99. To preview a copy of the book, sign up for our free email newsletter and you'll receive a link to download it.

To enter the contest please leave a public comment on this blog post about how the VB Scripting pdf tutorial will help you! What are you going to do with the information gained from the text? That’s all there is to it! Feel free to let us know if you’re going to use it at work or at home, or any unique macro uses and you could win a free copy.
Be sure to leave a name in which I can identify you by.

The contest entry period begins today and runs through August 31, 2012. The winner will be randomly selected and announced on September 4th, 2012.


To receive an additional entry into the contest and increase your chances of winning then “like” our Facebook page and add a comment on our wall post.


Also, be sure to sign up for our free email newsletter to receive notifications about future contests (I plan on having much more frequent giveaways).

Monday, July 2, 2012

CATIA Drawing CATScript Features

Scripting Drafting features

One area I have to admit I have neglected to write about in these posts and articles is how to write CATScripts for drafting and 2D drawings. I have not used this workbench myself as extensively as some of the others (like GSD) but I will share any information or tips as I pick up on them. Here we go.

CATIA’s drafting workbench features two basic types of grouping all 2D features: Generative Drafting takes the 3D CATIA objects and represents them in 2D views within a drawing while InteractiveDrafting represents 2D features directly created in the 2D views with no 3D data associated with it.

Scripting Drafting features Overview

Listed below are some of the key features used in macros for CATIA drawings.
  • DrawingSheets and DrawingViews
  • Main View and Background view.
  • ActiveSheet.
  • ActiveView.
  • The Front View and the others
  • Generative Views
  • Interactive Views
  •  Filling the Title block
  • Extract Dimensions

DrawingSheets and DrawingViews

The DrawingDocument object aggregates a DrawingSheets collection. Each DrawingSheet of this collection aggregates a DrawingViews collection.

Main View and Background view.

A drawing contains at least two views: the background view and the Main View, that is the view in which you can draw just after creating a drawing. The ActiveSheet: The active sheet can be found in the DrawingSheets collection. The ActiveView can be found in the DrawingViews collection

CATIA Drawing viewer: The Front View and the others

A DrawingView can be the “Front View” or another view relative to the “Front View”.DrawingViewGenerativeBehavior can define both behavior: DefineFrontView() defines the “Front View” and its direction. DefineProjectionView() defines another view relative to the “Front View”
Other methods allow creating other types of views such as Section Views, Detail Views, etc. Generative Views - DrawingViewowns a “document” property that allows you to specify the associated 3D document from which the “generative view” is created.

Interactive Views - DrawingViewowns a “Factory2D” property that allows you to create 2D features.This kind of view is called an “Interactive View”.

Filling the Title block - The Texts collection allows you to create 2D texts in the drawing

Extract Dimensions - A DrawingSheet has the method called GenerateDimension() that generates dimensions automatically in all the views from the 3D geometry.

Below are example scripts to help you get started! Then sign up to the VB Scripting for CATIA V5 newsletter for even more CATIA macros.



Download Architects Cad Drawings: Subsribe To Access Our Huge Database Of Downloadable Cad Symbols, Drawings & Detail
·     
'Revised June 21, 2012
'This macro will unlock all drawing views 

Sub CATMain() 

Set drawingDocument1 = CATIA.ActiveDocument 
Set Sheets = drawingDocument1.Sheets 
Set activeSheet = Sheets.ActiveSheet 
Set views = activeSheet.Views 
  
  
Dim sSel As Selection 
Set sSel = drawingDocument1.Selection 
  
sSel.Search "CATDrwSearch.DrwView,all" 
  
For i = 1 To sSel.Count 
  
  
If sSel.Count = 0 Then MsgBox "Select one view!", vbCritical,
 "Lock/Unlock": Exit Sub 
If TypeName(sSel.Item(i).Value) <> "DrawingView" Then MsgBox 
"Selected element is not a drawing view! Select a drawing view.",
 vbCritical, "Lock/Unlock": Exit Sub 
  
Dim drawView As DrawingView 
Set drawView = sSel.Item(i).Value 
  
      drawView.LockStatus = False 
  
  
Next 
  
End Sub

'This macro will change drawing dimensions from mm to inch 


Sub CATMain() 

Dim drawingDocument1 As DrawingDocument 
Set drawingDocument1 = CATIA.ActiveDocument 
Dim selection1 As Selection 

Set selection1 = drawingDocument1.Selection 
selection1.Search "CATDrwSearch.DrwDimension,all" 
  
For i = 1 To selection1.Count 
 
 Dim Dimension1 As DrawingDimension 
 Set Dimension1 = selection1.Item(i).Value 
 Dim DimDimValue As DrawingDimValue 
 Set DimDimValue = Dimension1.GetValue 
 DimDimValue.SetFormatName 1, "NUM.DINC" 
Next
 
selection1.Clear 

End Sub