Pages

Monday, October 24, 2011

How to add amacro icon to a toolbar in CATIA V5?

There are multiple ways to initiate a CATScript macro in CATIA V5. Did you know that it is possible to invoke your macro through a tool bar icon? How do you create an icon for your macro? Go to tools >customize >commands > macros > show properties. Next, simply define a logo for your macro by picking one from the 180 plus icons to choose from (or browse to your own custom made icon) and then drag and drop it into the menu bar where you want it. It's that easy. So now you should have three ways to run your VBA CATScripts: going to Tools>Macro>Macros, hitting Alt+F8, or by clicking on your icon in a toolbar.

Saturday, October 22, 2011

Let's Go Design Episode #5: Chassis Design and Assemblies



In the last episode, we discussed weldment features and sketch techniques. This time, we move closer to the final overall CAD design of our Hot Rod Baby Buggy. We watch as Jeremy hot-wires the golf cart motors to show how the aluminum tracks perform flawlessly.

In this episode, Jeremy takes us through:

The Overall Design: Jeremy shares 80% of the CAD design, complete with a 3D model of a dad placed in the center. He shows us the fenders, talks about key components underneath the buggy, and creates a battery compartment using sheet metal.

Sustainability: We use SolidWorks® Sustainability to compare material selections for the fenders of our buggy - sheet metal vs. plastic.

The Assembly: Jeremy shows the basic build and sub-assemblies. He puts together the steel base weldment, aluminum floor, components from the golf cart’s electrical system and finally powers the tank treads.

Watch Episode #5 now at LetsGoDesign.tv

Wednesday, October 12, 2011

How to automatically take a picture using a catscript

Catscripts can be a powerful tool when needing to automate processes in CATIA V5. One common process which is helpful to automate is when you want to take a screenshot of a .catpart or .catproduct with a white background (to put into a powerpoint or Excelfile). This sounds like a daunting task if you are new to VB programming. I find the best thing to do is to break down this large, challenging project into smaller, more manageable tasks. Let's think about each stage we want the macro to complete:
1. Reframe on the part
2. Hide the specification tree
3. Change the background color to white
4. Take a screenshot and save it as a JPEG file
5. Change the background display color back to what it was
6. Unhide the specification tree
Now, if we take each of those steps one at a time it's not so big of a problem. I'll be explaining each of these steps in the next couple of posts starting with step one today- how to automatically reframe (or fit all in) on the part in CATIA. We'll create each step individually then combine them all into one CATScript at the end.  This tutorial will also help you learn visual basic programming and will help you write your own CATScripts.
First, go to Tools>Macro>Macros. Click "Create" and change the Macro language to CATScript. Enter a name for your macro. Copy and paste the following code.

Language="VBSCRIPT"
Sub CATMain()


Dim specsAndGeomWindow1 As Window

Set specsAndGeomWindow1 = CATIA.ActiveWindow


Dim viewer3D1 As Viewer

Set viewer3D1 = specsAndGeomWindow1.ActiveViewer


viewer3D1.Reframe


Dim viewpoint3D1 As Viewpoint3D

Set viewpoint3D1 = viewer3D1.Viewpoint3D


End Sub

What does all of the above actually mean? A CATIA VBA program or “macro” consists of a
“Subroutine” named CATMain(), called out with the line Sub CATMain(). Variables are “dimmed” (declared) and then “set” (given a value). Variables are “dimmed” as a type. A type is either a “primitive” type (single, double, integer, string, etc.) or an object type (more complex). 

Stay tuned to learn more in our next article...