Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

OBTAIN CAPTURES' VALUE

Status
Not open for further replies.

Thosnow

Aerospace
Feb 23, 2017
68
CA
Hello All,

I have a VBA code below, which cycles through captures in CATPart 3D Annotation set in a part document as per image below.

How can I obtain value of all captures in the CATPart 3D Annotation set.
Example: when first screen capture "All" displays, it will display string "All" and I want to save this string "All" in a variable as well.
Other similar strings (ie. PART INFORMATION, DESIGN NOTES...etc) should also be obtained, displayed and saved to variables as well.

================= my VBA CODE ===============

Sub CATMain()

MsgBox "Active document must be a part document and captures are expanded " & Chr(13) & "in order to have the macro works properly."

'//// Access the active document
Dim PartDoc As Document
Set PartDoc = CATIA.ActiveDocument
'//// Set PartRoot part from the PartDoc part document
Set PartRoot = PartDoc.Part

'//// Set user's annotation collection = PartRoot annotation sets, which has multiple annotation sets
Set myAnnotCollection = PartRoot.AnnotationSets

' myAnnotCollection.Clear
'//// Get first annotation set from annotation collection, myAnnotCollection
Dim AnnoSet1
Set AnnoSet1 = myAnnotCollection.Item(1)

'//// Get the number of captures in "annotSet1" above
Dim myCaptures, NumberOfCaptures
Set myCaptures = AnnoSet1.Captures '//// Access captures inside the annotation set
NumberOfCaptures = AnnoSet1.Captures.Count

MsgBox "Number of annotation sets in active document is: " & myAnnotCollection.Count & " and number of captures is: " & NumberOfCaptures

'//// Loop through capture collection
Dim j As Integer
For j = 1 To myCaptures.Count

'//// Display the current capture
Set myCaptures = AnnoSet1.Captures.Item(j)

'//// Display the annotated Capture, one-by-one, on the monitor
myCaptures.DisplayCapture
MsgBox "Capture #: " & j

Next
End Sub
============================== my image mentioned above for illustration ============

CATPART_3D_ANNOTATION_hb4wto.jpg


Any help from Ferdo and any of you is greatly appreciated.

Thank you All in advance

Quin
 
Replies continue below

Recommended for you

myCaptures.Name

Eric N.
indocti discant et ament meminisse periti
 
it works. Thank you

Now, i try to compare captured capture values with text string. How could I achieve?

I used If statement to display captures having non "All" or "Change" values as follow

Dim myString
Set myString = myCaptures.Name
If myString <> "All"

[/indent]'//// Display the annotated Capture, one-by-one, on the monitor
myCaptures.DisplayCapture

End If

but it does not work.

Do you have any idea?

Thank you

Quin
 
but it does not work.

so what does it do? what do you expect?

Maybe you're missing a loop like

Code:
'//// Loop through capture collection
Dim j As Integer
Dim myCapture
For j = 1 To AnnoSet1.Captures.Count

'//// Display the next capture
Set myCapture = AnnoSet1.Captures.Item(j)

'//// Display the annotated Capture, one-by-one, on the monitor
if myCapture.Name <> "All" then 
myCapture.DisplayCapture
MsgBox "Display Next capture"
end if

Next



Eric N.
indocti discant et ament meminisse periti
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top