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!

Annotation Set Switch On/Off Issue

Status
Not open for further replies.

jzecha

Aerospace
Jan 20, 2016
235
US
Is there a way to just turn all the Annotation Sets On in a model?
Or search the model for only Turned Off Annotation Sets?

Instead of this code:
CATIA.StartCommand ("Annotation Set Switch On/Switch Off")

I have a model with a few annotation sets already on when you load it but most of them are off.

So when I run the code above, it turns the already "ON" Annotations to "OFF", but turns the "OFF" Annotations to "ON".
 
Replies continue below

Recommended for you

Try running a search/selection code with this.

Code:
Set visProp = sel1.VisProperties

Set visProp = visProp.Parent

visProp.SetShow 1 '1 = hide, 0 = show
 
That code only un-hides the annotation sets.

Any more ideas?

Here is my existing VBA Code that I am trying to impliment turning on all Annotation Sets and Unhiding all of them.

Code:
Private Sub btnGD_And_T_Click()

Dim oTopDoc As Document
Dim oTopProd As ProductDocument
Set oTopDoc = CATIA.ActiveDocument
Set oCurrentProd = oTopDoc.Product

Dim Selection1_As_Selection
Set Selection1 = oTopDoc.selection

'TURN ANNOTATION SETS ON/OFF
'Selection1.Search "CATTPSSearch.CATTPSSet,all"
'CATIA.StartCommand ("Annotation Set Switch On/Switch Off")

Selection1.Search "CATTPSSearch.CATFTAElement,all"
Set VisPropertySet1 = Selection1.VisProperties
If (optHIDE.Value = True) Then
        VisPropertySet1.SetShow 1
        
ElseIf (optSHOW.Value = True) Then
        VisPropertySet1.SetShow 0
        
End If

Selection1.Clear

Selection1.Search "(Name=*PMI* & CATPrtSearch.OpenBodyFeature),all"
Selection1.Search "Name=*PMI* & CATPrtSearch.OpenBodyFeature,all"
Set VisPropertySet1 = Selection1.VisProperties
If (optHIDE.Value = True) Then
        VisPropertySet1.SetShow 1
        
ElseIf (optSHOW.Value = True) Then
       VisPropertySet1.SetShow 0
        
End If

Selection1.Clear

'TURN OFF VIEW PLANES
Selection1.Search "CATTPSSearch.CATTPSView,all"
Set VisPropertySet1 = Selection1.VisProperties
        VisPropertySet1.SetShow 1

Selection1.Clear

End Sub
 
So, I think I found a solution. I used "getitem", but maybe you can find a better method than using the objects name.

Code:
Sub CATMain()

Dim partDocument1 As PartDocument
Set partDocument1 = CATIA.ActiveDocument

Dim annoset As AnnotationSet
Set annoset = partDocument1.Part.AnnotationSets.GetItem("Annotation Set.1")

annoset.SwitchOn = True

'annoset.SwitchOn = False

End Sub
 
So, continuing with LucasC suggestion;if you have more than one annotation set, loop thru them...
dim myAnnotSet as AnnotationSet
for each myAnnotSet in partDocument1.Part.AnnotationSets
myAnnotSet.SwitchOn = True​
next

regards,
LWolf
 
This seems to work exactly how I want, except only at a part level.

I am working with a large assembly that has Annotation Sets at the Part level and Assembly Level.

I am not the greatest at code writing, so any direction is greatly appreciated.
After some digging in the CAA V5 Visual Basic help.chm file, I found the code I think that adapts this to the product level.


Set ProductDoc = CATIA.ActiveDocument
Set AnnotationSets = ProductDoc.Product.GetTechnologicalObject("CATAnnotationSets")

But when I try to add part of LWolf's code to the end, I get "Run Time Error '438' Object doesn't support this property or method" with the following line:
AnnotationSets.SwitchOn = True

My first thought is that this new code is grabbing all the Annotation sets, but the code line that fails only works on one line at a time?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top