Many companies today are using MBD, model based definition, meaning the 3D CATPart contains all the information required to manufacturer the part (such as special notes, dimensions, tolerances, instructions, etc.) To do this the CATIA model will most likely contain captures, views, dimensions, and notes within an annotation set. The following example CATIA macro (CATVBA) will show you how:
- Drill down to the captures and loop through them.
- Display a capture
- Activate a capture with SendKeys
- Find a View of the same name of the activated capture
Sub CATMain()
‘This code assumes that a CATPart file is the active document in CATIA
Dim partDocument1 As Document
Set partDocument1 = CATIA.ActiveDocument
‘—error handling for part doc————
On Error Resume Next
Set PartDoc = CATIA.ActiveDocument
Set Part = PartDoc.Part
If Err.Number = 0 Then
‘———————————-
‘set the first annotation set
Set oAnnotationSets = Part.AnnotationSets
Dim AnnoSet1 As AnnotationSet
Set AnnoSet1 = oAnnotationSets.Item(1)
‘count the number of captures
NumberCaptures = AnnoSet1.Captures.Count
MsgBox “Number of annotation sets is: ” & oAnnotationSets.Count & ” Number of captures is: ” & NumberCaptures
‘Loop through captures
For j = 1 To NumberCaptures
‘display the current capture
Set CurrentCapture = AnnoSet1.Captures.Item(j)
CurrentCapture.DisplayCapture
‘—set capture j as the selection and activate it in order to edit and save the views———–
Dim sCapSel As Selection
Set sCapSel = CATIA.ActiveDocument.Selection
sCapSel.Clear
sCapSel.Add CurrentCapture
CATIA.RefreshDisplay = True
AppActivate “CATIA V5”
Application.Wait Now + TimeValue(“00:05:00”)
SendKeys “c:Activate” + Chr(13), True
Application.Wait Now + TimeValue(“00:05:00”)
CATIA.RefreshDisplay = True
‘show the name of the capture in a message box
CaptureName = CurrentCapture.Name
MsgBox “The activated capture is: ” & CaptureName
CATIA.RefreshDisplay = True
‘—add views to the selection
Dim sSelView As Selection
Set sSelView = CATIA.ActiveDocument.Selection
sSelView.Add oAnnotationSets.Item(1)
‘ search views for any with name matching captures
sSelView.Search “Name=” & CaptureName & “,sel”
‘count the number of views found
Dim viewFound As Integer
viewFound = sSelView.Count
If viewFound > 1 Then
MsgBox “Number of views found is ” & viewFound
sSelection2.Clear
Else
MsgBox “No view associated with capture. Click OK to continue.”
End If
Next ‘j
‘—error handling and cleanup——-
Else
‘error handling
MsgBox “Not a part document! Open in new window.”
End If
End Sub
Hi,
I was wondering if it is possible to get the text out of a geometrical tolerance annotation in 3d? I just want to get the holes upper limits and lower limits from it. I’ve tried tons and tons of ways! I can get to the geometrical tolerance, just can’t extract the text from it. I’ve tried collecting it’s .Get2dAnnot.text from that but no luck the string comes back blank. Do you have to have a certain license to capture that data from it? I would atleast like to know if it is possible or if I am just wasting my time, or taking the wrong approach? Would I want to make a drawing out of the views and then search for them in there, that way seems like a very slow way though.
Thanks You for your time!
Hi, please email me the code you’ve tried so far and I can see what I can do! Thanks, Emmett
I sent it to Emmett Ross . Is that where I should send it?
Your info@ email.
Hi,I have the exact requirement..Have broken my head to get the text out.Please help.
I am looking for some way to automatically print out all captures.
What is the purpose of this macro? It is not clear.
I am looking for some way to automatically print out all captures.
Hi Paul. The above code shows you how you can activate a capture. Are you trying to directly print the captures or export to powerpoint first?
I’m also looking for a way to print captures, but not to print directly. Before printing i want macro to export all captures to power point.
can you help me..what is the setting needs to be changed for viewing annotation in CATIA V5.
how to take only front view Capture
I can’t hear anyihtng over the sound of how awesome this article is.
Hello Emmett,
I have to manually print lots of Captures one-by-one (under CATIA 3D Annotation set) out in both CATParts and CATProducts every day. It is really repetitive and time consumption every day.
I really appreciate if you are able to show/help me out to write a macro to automatically print out all “Captures” under Capture set as seen in your image above. I do not really have much experience in writing macros in Catia.
My plan is to drill thru Capture set, one capture at a time, then print each capture and save them to pdf file formats for viewing and future references.
Your help with commands, syntax, loops (if…else….ect) and program sequence is greatly grateful.
Quyen
Hello Emmett,
I am also trying extact out all “Captures” from a set of CATParts and CATProducts to print each capture and save them to pdf file formats for viewing and future references.
I am a new Catia V5 user and normally use Creo3.0.
So any help and guidance for Catia simpleton would be very much appreciated!!
Regards
Steve
Hello,
I’m trying to extract geometrical tolerances text from VBA (type: FTA_NonSemanticGDT). I can’t get anything there: I’ve written a test function to know wich kind of annotation I’m dealing with, but it answers “false” to all tests proposed in the V5 automation help:
HasAControledRadius : False
HasAFreeState : False
HasAMaterialCondition : False
HasAParticularTolElem : False
HasATolerancePerUnitBasisRestrictiveValue : False
HasAnEnvelopCondition : False
HasDimensionLimit : False
IsACompositeTolerance : False
IsADefaultAnnotation : False
IsADimensionPattern : False
IsAProjectedToleranceZone : False
IsAShiftedProfileTolerance : False
IsATangentPlane : False
IsAToleranceUnitBasisValue : False
IsAToleranceZone : False
IsAnAssociatedRefFrame : False
To your knoledge, is there any way to deal with this king of annotation?
Thanks a lot!
Hi,
I have written a macro for creating 3d annotations in CATIA GSD. Now i want that all of those annotations should be of one selective Font,Style and size. Kindly help.Could not find that where to edit that, since its taking the Font,Style and size by default.
Hi Shad,
Is it possible for you to share the vb code? I am currently trying to do the same for all the dimensions and tolerances in my 3d model.
Hi Emmet,
I have enjoyed reading through the scripts and tailoring them to suit my need. I am currently trying to write a macro to pull out Geometric Tolerance information into text. I am stuck similar to Thiery, Jess (above comments). Can you help me out ? Thanks
–
Tj
Hi,
I’m looking for information on how to create a drawing view from a view in 3d (from na Annotation Set). I recorded a macro to register the command sequence (view from 3D > select the view > finish), but id didn’t work.
How can I do this?
Thanks in Advance,
Portolon
Hi,
I am trying to do the same thing. Did you find any solutions?
Please share!
Many thanks,
Marius.
Hello Emmet
I am looking for the VBA action to activate and deactivate the FTA dimensions according to the design configuration. But i am not succeeded. Could you please help me
I have a Catpart containing the FTA annotation sets(Captures,Dimensions and Text)
I would like to deactivate some specific dimension by selection of one parameter in the 3D
Thanks
Venkadesh
Hi, I’m working in a project and my fellow cooworkers are asking me to create a macro to generate the annotation set tree with one boton. Is this possible?
Basically what I need is to create a set of blank captures with standard names.
Thanks in advance!
Hi Emmet,
I am trying to create TPS View on product level but I couldn’t create but I can create on a part. Is there any roundabout to create it?
Hello Everyone!
Is there programmable way to change the scale of the view under AnnotationSet, depending of the geometry size? For example, I want the scale to be 10 if part is 2000mm and above, 5 → if 2000<LL?
Hi Please let me know how to copy the annotation from Part level to Product level
is there any way of getting the name Support view from the capture, I have a document, the “Support view” for the capture is named differently from the capture name.