Sunday, January 22, 2012

Knowledgeware, Design Table, and Macro in CATIA

Knowledgeware is not one specific CATIA workbench but several workbenches. Some of the tools can be accessed in the Standard toolbar in the Part Design workbench. Simply put, Knowledgeware is a group of tools that allow you to create, manipulate and check your CATIA creations. 

Workbench Tools and Toolbars: 
There are combination of six toolbars in Knowledgeware Product. The knowledgeware Product is made up of the following workbenches; Knowledge advisor, Knowledge expert, Product engineering optimizer, product knowledge template, product function optimization and product functional definition. Each of these workbenches has a different combination of tools in each toolbar. If you switch between any of these workbenches you may see the same tool in a different toolbar.
CATScript Macro in CATIA:
A question is "how do you create vba macros in CATIA?" One solution is to write a script. No, not a script for a movie, a CATScript file! To create a CATScript macro for CATIA open Notepad and write your code, then save the file with whatever name you want and type extension .CATScript instead of .txt. Here is a simple CATScript you can use as an example. This CATScript will tell you which version of CATIA you are currently using, including the service pack number. Copy and paste the code into Notepad then save as CatiaVersion.CATScript.

Sub CATMain()
Set SystemConfiguration1 = CATIA.SystemConfiguration
Msgbox "CATIA V" & SystemConfiguration1.Version & " R " & SystemConfiguration1.Release & " sp " & SystemConfiguration1.ServicePack
End Sub

Make a macro out of a Power Input command (V5) - Not all commands are available as buttons, but they are available as Power Input commands. Like for instance the 'scale planes' tool that can be helpful to have as a button on your own toolbar. You can also include other commands like New, Open, and etc. Use the built in Visual Basic editor to make a catvba project where you add this code in a new module:
Language "VBScript"

Sub CATMain()
CATIA.StartCommand "scale planes"
End Sub

The script below creates two parameters in a new CATIA document. 

Dim oActiveDoc As Document
Set oActiveDoc = CATIA.ActiveDocument

If (InStr(oActiveDoc.Name,".CATPart")) <> 0 Then

Dim oParams As Parameters
Set oParams = oActiveDoc.Part.Parameters

Dim strParam1 As StrParam
Set strParam1 = oParams.CreateString("FirstName", "")

Dim strParam2 As StrParam
Set strParam2 = oParams.CreateString("LastName", "")

strParam1.Value = fname
strParam2.value = lname

Else MsgBox "The active document must be a CATPart"
End If

End Sub

  1. Click OK to add the macro to the document. A 'VB Scripts' sub-node is added to the specification tree below the Relations node. A VB Script object is added below this sub node.
  2. Double-click the VB Script object. The Script Editor is displayed. Insert Object Resolution allows you to retrieve a feature definition
  3. Click Run script.... The Select Inputs for Script Arguments is displayed.
  4. If need be, select fname from the argument list, then enter a string into the value field (no quotation marks). Then select lname and enter the lname value.
  5. Click OK to run the script.  The two string type parameters are added to the document. Their values are those you have specified

Joggled Extrusion part problem: 

A design table and a macro script will be created for Joggled Extrusion part.
A parametrized sketch/solid is a basic form of Knowledgeware; it contains intelligence. Prior to parametric applications you would have to create each variation of the extrusion from scratch. Parametric applications allow you to modify one constraint and the extrusion (solid) will update to that constraint. 

1). Determine the Requirements:
The general problem solving skills apply to implementing the Knowledgeware solution. You need to list all that is known and unknown and you need to list all of the variables, for example, what is known.
If you are not sure at first, manually go through the process. You must be able to create the process manually.

2). Creating the Extrusion Profile Sketch:
Create an Extrusion Profile sketch on the ZX Plane. The 0,0 point is located at the lower left corner of the extrusion. This sketch will be used as the standard; all other extrusions will be derived from this basic sketch. When you complete the sketch, you have to constrain the extrusion profile as bellow. Then exit the Sketcher workbench but do not use the Pad tool to create a solid. The solid will be created later using a different tool.

3). Modifying the Constraint Names: 
To change the constraint names, for example double click on the constraint as shown in the figure. Constraint Definition window appears.

Click on more. And change the name to B. Carry on changing all the constraints name as before.

Repeat the above process for the rest of the constraints as shown in the figure below.

4). Creating the Profile Sketch of the Joggle:
This sketch is created on the YZ Plane in the negative direction. Then change the names of the constraints as described above.

To modify the constraint names, double click on the constraint. Constraint Definition window appears. Change the constraints names as shown in the figure below.

5). Creating the Joggled Extrusion solid:
Now the both sketches are created you are ready to create the solid. To create the extrusion solid, use Rib tool in Part Design workbench.

7). Creating an Extrusion Table:

In Excel create a spreadsheet that contains the dimensions to four different types of aluminium extrusions.

8). Importing the Extrusion Table:
In the Part design workbench, double click on the Design Table tool. The Design Table tool is located in the Standard toolbar at the bottom of the CATIA screen. This will bring up the Creation of a Design Table window. Name the design table as Extrusion Table. Select Create a design table from a pre-existing file option. Click OK.

Select the spreadsheet file created in previous step.

This will bring up Automatic association? window. Select YES.

The Extrusion Table Active window appears with the Associations tab selected, not the Configurations tab. If there are no associations listed in the Configurations box, CATIA was not able to automatically associate any of the Constraint Parameters or Extrusion Table Column Headings.

When CATIA is not able to automatically associate the two together, you will have to manually associate them. To do this, select the Associates tab in the Extrusion Table Active window.
The Parameters box lists all the parameters CATIA created in the Extrusion Profile sketch. A CATIA sketch contains a lot of parameters that the users are not usually aware of.
What makes it more difficult, is the CATIA naming convention. It is difficult to identify a CATIA parameter listed in this box to an actual parameter in the Extrusion Profile sketch. This is where renaming the constraints in the previous steps will prove to be beneficial. You should be able to scroll through the Parameters box and identify the constraints you renamed. All the parameters are represented on two separate lines. You will use the line that ends with a type of measurement such as Radius, Offset or Length. You will not use the line ending in Activity. For this step, scroll through the Parameters list; verify the constraints you renamed in previous steps.
For example, select A from the Columns box and from the Parameters box select PartBody\Extrusion Profile\A\Length.
Then select the Associate button. Your two selections from the Parameters and Column boxes will show up in the Associations between parameters and columns box. This means that they were successfully associated.
Continue this process until all the variables in the Columns box, except for Extrusion Number, is matched up to the appropriate parameter. (R, R1, etc. will of course be a Radius rather than a Length).

Now you can take care of the Extrusion Number column heading. The Extrusion Profile sketch has no associative value to the Extrusion Number that was created in the Extrusion Table. You can assign it one by selecting the Extrusion Number in the Columns box.

Select the Create Parameters... button. This will bring up the OK Creates Parameters for Selected Lines window.

Make sure Extrusion Number is selected. Select OK button.

What this really does for you is allows the Specification Tree to show the Extrusion Number.

Select the Configuration tab in the Extrusion Table Active window. If you correctly associated the Parameters and Columns. Select the OK button to complete the association process.

9). Applying the Extrusion Table to the Joggled Extrusion:
The purpose for linking a design table to the CATPart file is to update the part without having to redraw and/or revise the constraints manually. (Keep in mind that if you move your saved table, it will break the link and you will need to re-link it.) To test this, complete the following.

Double click on Extrusion Table in the Specification tree. This will bring up the Extrusion Table Active window. The data in row 1 is currently the active row. There are several methods to tell which row of data is active.

Row 1 has brackets around it [<1>]. The inactive lines do not have the brackets around it. One other method is to check the data against actual extrusion dimensions.
To make row 4 (Extrusion Number 60-13028) active, select the row. The existing extrusion will turn red signifying it needs to be updated.

Select OK button. This will update your active extrusion to the data contained in row 4. The image below shows the row 4 extrusion. Compare the differences between the extrusion represented in above and below image. Verify the extrusions with the dimensions in the Extrusion Table (design table).

If your extrusion does not automatically update you will have to select the Update button in the Standard toolbar section to force the solid to update. If you want CATIA to automatically update select Tools, Options, Infrastructure branch, Part Infrastructure branch, General tab, Update section and select the Automatic button.

10). Editing the Extrusion Table:
You now have the Extrusion Table linked to the Joggled Extrusion CATPart. To modify the Extrusion Table inside of CATIA , complete the following steps:

Double click on the Extrusion Table in the Specification Tree. This brings up the Extrusion Table Active window.

Click on the Edit Table button at the bottom left of the window.

This brings up the original spreadsheet that the Extrusion Table was created in. Modify the number 2 in row 2 (Extrusion Number 60-10677) and column C (header B (in)) to 4.

Save and exit the revised spread sheet program. CATIA will notify you that the Extrusion Table has been revised. Select Close to update the link.

The part will turn red because it is the active row. Select OK to update the Joggled Extrusion CATPart.

11). Displaying the Extrusion Type in the Specification Tree:
Select Tools, Options, Parameters and Measure under the General branch, Knowledge tab, Parameters Tree View section; check the With Value box.

12). Automating the Modification Using a Macro:
Enter the Joggle Profile sketch. The first thing you need to remember is to record only what is necessary, other wise you get a lot of information that only complicates the process.

Select Tools, Macro, Start Recording. This will bring up the Record Macro window.

The Current Macro Library Or Document: should default to your CATPart at its designated saved location. Select CATScript for the Language Used: box.
Name the macro "JoggleDimensions. CATScript." CATIA will default the name to Macro1.catvbs unless you specify a name. You must also add the .CATScript extension. Adding the extension allows CATIA to save the macro externally not only as a macro but also a CATcript.

Before you start recording, make sure you know from start to finish what you are going to record. In this step you are going to modify all of the constraints in the Joggle Profile sketch to match the constraints. Select the Start button to start recording. Notice when you start recording, CATIA creates a Stop Recording toolbar with a Stop Macro Recording tool on it.

Revise the constraints to match the constraints in the following order: 0.75 to 1.0 (Depth), 5 to 3.74 (Transition), and 4 to 2.5 (Dist. To Endp).

Stop the recording. You can stop the recording by selecting the Stop Macro Recording tool in the Stop Recording window. Another method is to select Tools, Macro, Stop Recording.

Now go back to the Joggle Profile sketch and change the constraints to the previous values.

Exit the Sketcher workbench.
Select Tools. Macro, Macros. This will bring up the Macros. Select JoggleDimensions.CATScript macro.

Select the Run button. This will run the JoggleDimension.CATScript macro. Notice the part will turn red and then update to the joggled dimensions you created in the macro.

The previous step demonstrates the result of the macro/script you just created. As you recorded the macro, CATIA translated the action into the VBScript Language. CATIA allows you to view and edit the scripted language. To view the VBScript Language you just created, select Tools, Macro, Macro, and then select the JoggleDimensions.CATScript file in the Macros window. Select the Edit button.
This will bring up the Macros Editor window.

The macro function is a powerful tool when it comes to accomplishing a process that is repeated over and over. The macro or CATScript you just created are powerful tools in automation as well.
The values shown in the Macro Editor are shown in metric units.

13). Customizing the Macro Using VBScript:

CATIA knowledgeware allows you to customize the CATScript using VBScript Language. This customization makes the Macro and Scripting capabilities of CATIA Knowledgeware almost limitless. You don't have to be a VBScript guru to take advantage of this tool, but obviously the more you know about it the more powerful a tool it becomes.
To add the constraint variables you created in the Joggle Profile sketch complete the following steps. 

The macro you created in previous steps assigned the constant value of 25.4 to the first constraint you modified when recording the macro. The macro recorded the value as length1.Value. You will need to find the line where length1.Value is assigned the length.

Insert the three lines indicated in bottom image above the line with the value as length1.Value. The purpose of doing this is to create prompt windows for the variables you are about to assign in place of the constant values that are assigned manually. Just adding variables would do you no good; you need some method of entering a value for the variables that you will create. The prompt window will allow the user to enter a value for the variable. (Make sure you type in the syntax exactly as it is shown.)

Depth = InputBox("Enter the Depth Distance:","Depth")
Transition = InputBox("Enter the Transition Distance:","Transition")
DistToEndp = InputBox("Enter the Distance to the Endpoint:","Dist. To Endp.")

NOTE: It is obvious that each line represents a specific constraint variable. Depth is the variable. InputBox is VBScript syntax that creates a prompt window. Enter the Depth Distance is the text that will show up in the prompt window header. Depth at the end of the syntax creates a value input box.

Now back to the line that has the value as length1.Value. The macro converted the constant value to metric (mm). You will want to keep the units in inches so multiply the Depth value by 25.4. The variable name used for the first constraint is Depth*(25.4). This will convert the value back to inches.

Find the line that assigns length2.value. Change the value to the variable constraint named Transition*(25.4). This variable needs to be converted back to inches.

Find the line that assigns length3.Value. Change the value to the variable constraint named DistToEndp*(25.4).

Save the changes and then close the Macros Editor window. The Macros window will still be available - don't close it.

14). Testing the Customized Macro:

The Macros window should still be on the screen. Select the Run button.

This should bring up the first of the three prompt windows that were created previously (Depth). Type in the original value (0.75), then select OK.

This will take you to the next prompt window (Transition). Again type in the original value (5) and then select OK.

The last prompt window created (Dist. To Endp.) will appear. Type in the original value (4) and select OK.

If the syntax was set up correctly, your extrusion should update automatically or turn red to indicate updating is needed. Your extrusion should be back to its original configuration.



15). Creating a Tool Icon for the Macro:

The macro created and modified in the previous steps is a very powerful tool. CATIA has developed another powerful tool that will save you additional time. This tool allows you to customize your CATIA work environment by creating your own tool icons.

Select Tools and then select the Customize option.

This will bring up the Customize window.

Select the Commands tab in the Customize window. Then select Macros from the Categories box. This will bring up all the macros that were created and saved with the *.CATScript extension.

Select the macro located in the Commands box. With the macro file highlighted, drag it to the Tools toolbar. Drop the file on the toolbar as shown below.

Close the Customize window and click on the newly created tool icon. This will start the macro.

16). Applying correct processes and standards using the Check Tool:

Currently the macro will accept the value of 1 inch for the Transition dimension and 5 inch for the Depth dimension. Any experienced joggle operator would tell you that is not a reasonable ratio for an aluminium extrusion. A safe standard for aluminium extrusion is about 4 (run or Transition) to 1 (rise or Depth). This is a basic standard, but not every one is aware of it. It is very possible that the engineer/planner creating the drawing is not aware of the standard, thus could violate the standard. The engineer/planner could spend time planning and drawing the Joggled Extrusion. The part could use up time and resources being prepared for the joggle operation. Only after the extrusion gets to the joggle process would it be discovered that the joggle dimensions are not within company and/or industry standards. All of the time, material and resources have gone to waste. All of this could have been avoided if the engineer/planner was aware of the standard.
One way to safeguard yourself and/or company from such mistakes is by incorporating the standard into the intelligence of the part.
CATIA offers you the tools to capture the knowledge and/or standard and apply it to your CATParts. The following step explains how to incorporate the JoggleRatio standard to Joggled Extrusion.CATPart.

Double click on the Relations branch of the specification tree. This will bring up the Knowledge Advisor workbench.

Select the Check tool. This will bring up the Check Editor window.

Label the check "JoggleRatio". Select OK. This will bring up the Check Editor: JoggleRatio Active window.

Select Warning as the Type of Check. In the Message box, type "The Depth Ratio must be less than 1 to 4!"

Under Dictionary, select Parameters. In the Members of Parameters box, select Length. In the Members of Length box, double click on the "PartBody Joggle Profile\Transition\Offset" parameter. This will copy it to the input box above it.

Type in the symbol for divide (/) after the inserted line. In the Member of Length box, double click the "PartBody\Joggle Profile\Depth\Offset" parameter. This will copy it to the end of the line you have been creating in the input box above it.

Type in >=4 following the "...\Depth\Offset" parameter. These steps created a formula that tests the values the user enters when running the JoggleDimensions.CATScript macro. The formula needs to be the exact format as below image. If the Transition value divided by the Depth value is >=4, everything is OK. If the value is not >=4, then a Warning window will appear on screen stating the message you created in the message box, "The Depth Ration must be less than 1 to 4!"

Select OK button. Notice that CATIA adds a Check branch labelled JoggleRatio on the specification tree under the Relations branch. When the conditions of the check are met, the JoggleRatio branch will show a Green light. When the conditions are not met, the JoggleRatio branch will show a Red light.

If the values you enter for the JoggleDimensions.CATScript macro are not >=4, the JoggleRatio warning window appear, In this particular Check the Joggled Extrusion will still be updated even though it did not pass the check. The Type of Check was a Warning.

Even though this is a simplified application of the CATIA Check tool, it is very useful. It also gives you a glimpse of how powerful this tool can be. This step should give you enough information to start building on more complex checks.

17). Creating an Up-to-Date Production Drawing Automatically:

The objective from the beginning was to develop an automated process of creating Detailed Production Drawings. To accomplish this, complete the following steps:

Using the Drafting workbench, create a basic Production Drawing of the Joggled Extrusion. Use the Orthographic views and one Isometric view.

Dimension the characteristics of the Joggled Extrusion. The characteristics of the joggle are: End of part to start of joggle - Joggle transition - Joggle depth.

Save the Production Drawing as "Joggled Extrusion.CATDrawing." Run the JoggleDimension.CATScript. Change the joggle dimensions as below:

Depth = 0.40 inch
Transition = 3 inch
Dist. To Endp. = 2 inch

Bring up the Joggled Extrusion.CATDrawing. Update the drawing using the Update tool. Notice the view and dimensions automatically update to the newly selected extrusion and joggle dimensions.


  1. Hi there! This is my first visit to your blog! We are a group of volunteers and starting a new initiative in a community in the same niche.
    Your blog provided us valuable information to work on. You
    have done a extraordinary job!
    My webpage ... used car valuation

    1. Thank you. It is kind of you. I hope my blog would be helpful.

  2. This is a topic that's near to my heart... Thank you! Exactly where are your contact details though?
    Feel free to surf my site ; lose weight fast

  3. Excellent tutorial! Really, really good job showing the entire process.

  4. Is it possible to have a automated drawing for each different configuration in the design table? so one sheet per design configuration with the same views and dimensions shown?
    That would be so useful. Great job by the way, nice tutorial.

  5. You can have only one drawing for the configuration. Once the component configuration changed the drawing will change automatically. Because you can have only one configuration at the time. So the drawing will update according to the last configuration. I hope my answer is helpful. Thanks.

  6. Do you know the code to rename the instance numbers for Points in a Part and not an assembly?

    1. Hi. Can you explain more and give me more details. Thanks

  7. Haνe you eνer thought abοut adԁing a
    little bit morе thаn just yοur articlеѕ?
    I meаn, what you say iѕ impoгtant аnd еverything.
    Hοwever јust imаgіne if you adԁed ѕome greаt images or videο
    clіps to give your posts more, "pop"!

    Your сontent is excеllent but ωith imageѕ аnԁ videоs, this blog cοuld
    certаinly bе onе οf the best іn its niche.

    Wonԁerful blog!

    My blοg cheap search engine optimization