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.
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:
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 |
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?
Thanks for your work dedication towards Catalogue macro… I am just learning ur pdf regularly.. Its awesome to be a part of Catia and with you too…
Hi,
These email chains are very helpful for me.
Thanks much :)…
Hi emeett,
when I try yo create a program to open new document (part or product).Run time error is coming. But by recording macro and edit in that program those errors not coming.kindly help or guide me.
What is your code?
Thanks a lot for your reply and spending you valuable time for me.
kindly see below code which i typed in vba editor.
Sub CATMain()
Dim myDoc As Document
Set myDoc = CATIA.Documents.Add(“part”)
End Sub
it shows run time error (-2147467259(80004005) method ADD of object documents failed .i have no idea why it is coming like this.
kindly guide me .
thanks
vivek