Tip 1: Save macros in documents

When you create a macro library to execute your macros (a process I demonstrate how to do in one of my bonus videos), you can also save your macros inside of CATIA documents, such as CATParts and CATProducts. Go to current macro library or document and select your CATPart or Product, then Create a new macro. Save the part and then macro will be saved with it.

save catia macro in catpart

Tip 2: Send Email from CATIA

Did you know you can send emails directly from CATIA? Here’s an example how:

CATMain()
Dim Email As Mail

Set Email=CATIA.CreateMail

Email.SetContent “Hi” & Chr(10) & “This is awesome”

Email.SetOriginator “Emmett Ross”

Email.SetSubject “CATIA Macros and Automation”

Dim Receiver As Recipients

‘options are catRecipientBlindCopy, catRecipientCopy, catRecipientTo

Set Receiver=Email.GetRecipients(catRecipientTo)

Receiver.Add “---@---.com”

Email.GetAttachments.Add “C:\Temp\myName.txt”, “C:\Temp\tmp”

‘catDisplayClientUI, catNoUI

Email.Send catNoUI

End Sub

Please note, in order for this to work an email program needs to be associated, otherwise you get the error shown below:

catia email

Tip 3: Object up-to-date

You can quickly check whether an object needs to be updated:

1
2
3
4
5
6
7
8
9
10
11
12
13
Dim myPart As Part
 
Set myPart=CATIA.ActiveDocument.Part
 
If MyPart.IsUpToDate(MyPart) Then
 
Msgbox (“No update needed.”)
 
Else
 
Msgbox(“Update needed.”)
 
End If

catia macro update needed

Tip 4: Object deactivated check

Similarly, you can check whether an object is deactivated:

1
2
3
4
5
If myPart.IsInactive(myObject) Then
 
Msgbox(“Pad.2 is deactivated.”)
 
End If

 Tip 5: Launch CATIA Help file from a macro

If you get stuck or you think your end users will have problems you can launch the CATIA Help documentation from a macro. Before running the macro ensure you’ve set  the CATIAPATH in the Tools>Options area.

1
2
3
4
5
CATMain()
 
CATIA.Help “CATIAPath”
 
End Sub


I hope you’ve enjoyed these quick  CATIA macro tips! What are your quick tips?