×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

OBTAIN CAPTURES' VALUE

OBTAIN CAPTURES' VALUE

OBTAIN CAPTURES' VALUE

(OP)
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 ============



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

Thank you All in advance

Quin

RE: OBTAIN CAPTURES' VALUE

myCaptures.Name

Eric N.
indocti discant et ament meminisse periti

RE: OBTAIN CAPTURES' VALUE

(OP)
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

RE: OBTAIN CAPTURES' VALUE

Quote:

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources