How to Hide Annotations Under a View?
How to Hide Annotations Under a View?
(OP)
Hello. I'm trying to hide/unhide annotations under a specific View in a CATPart. I can count the total number of views but am not able to change a View's name. I can find the specific View using Search but am not sure if there is a way to access the annotations listed under that view. Attached is a pic of my spec tree and below is code I've written so far. Any ideas, is this even possible?
Sub CATMain()
Set PartDoc = CATIA.ActiveDocument
Set Part = PartDoc.Part
Set oAnnotationSets = Part.AnnotationSets
msgbox "Number of annotation sets: " & oannotationSets.Count
Dim AnnoSet1 As AnnotationSet
Set AnnoSet1 = oAnnotationSets.Item(1)
numViews=AnnoSet1.TPSViews.Count
msgbox "Number of views is: "& numViews
Dim sSelection As Selection
Set sSelection = CATIA.ActiveDocument.Selection
sSelection.Add oAnnotationSets.Item(1)
sSelection.Search "Name=REAR VIEW,sel"
Dim iCount As Integer
iCount2 = sSelection.Count
msgbox "Number of views found is "&icount2
Dim visPropertySet1 As VisPropertySet
Set visPropertySet1 = sSelection.VisProperties
visPropertySet1.SetShow 0
End Sub
Sub CATMain()
Set PartDoc = CATIA.ActiveDocument
Set Part = PartDoc.Part
Set oAnnotationSets = Part.AnnotationSets
msgbox "Number of annotation sets: " & oannotationSets.Count
Dim AnnoSet1 As AnnotationSet
Set AnnoSet1 = oAnnotationSets.Item(1)
numViews=AnnoSet1.TPSViews.Count
msgbox "Number of views is: "& numViews
Dim sSelection As Selection
Set sSelection = CATIA.ActiveDocument.Selection
sSelection.Add oAnnotationSets.Item(1)
sSelection.Search "Name=REAR VIEW,sel"
Dim iCount As Integer
iCount2 = sSelection.Count
msgbox "Number of views found is "&icount2
Dim visPropertySet1 As VisPropertySet
Set visPropertySet1 = sSelection.VisProperties
visPropertySet1.SetShow 0
End Sub





RE: How to Hide Annotations Under a View?
I believe you need to search in FTA workbench for Functional Tolerancing & Annotation Element for attribute Visibility = Hidden and after that launch the command Hide/Show.
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: How to Hide Annotations Under a View?
http://excelspreadsheetshelp.blogspot.com - http://scripting4v5.com
RE: How to Hide Annotations Under a View?
CODE --> CATScript
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: How to Hide Annotations Under a View?
RE: How to Hide Annotations Under a View?
Could be also another way but I didn't check in Autonmation chm file.
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: How to Hide Annotations Under a View?
Dim sSel As Selection
Set sSel=CATIA.ActiveDocument.Selection
Dim sSelEl As SelectedElement
Set sSelEl=sSel.Item(1)
Dim sActSel As Selection
Set sActSel=CATIA.ActiveDocument.Selection
sActSel.Clear
sActSel.Add sSelEl.Value
Dim WSShell
Set WSShell=CreateObject("WScript.Shell")
WSShell.SendKeys "c:Activate", True
Am I doing something wrong or will it simply not work this way?
RE: How to Hide Annotations Under a View?
Now I don't have CATIA to try, maybe tommorow.
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: How to Hide Annotations Under a View?
RE: How to Hide Annotations Under a View?
CATIA.RefreshDisplay = True
AppActivate "CATIA V5"
SendKeys "c:Activate" + Chr(13), True
Application.Wait Now + TimeValue("00:00:05")
The weird thing is it only activates the selected feature when I run the program from the VBA editor. It does not work when you start from Tools>Macro>Macros or if you create an icon for it. Any ideas why?
RE: How to Hide Annotations Under a View?
Yes, in CATScript is not working, is working only if you create a vbs file with sendkeys commands and in CATScript you call that vbs file.
Interesting, should work...workaround...create CATScript to call catvba...I'm curios if is working. Or set a bigger time and place the wait command also after AppActivate "CATIA V5" ? Sorry, I didn't see your code and I don't have a sample file to test...
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...