Continue to Site

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!

How to Hide Annotations Under a View?

Status
Not open for further replies.

ntweisen

Mechanical
Jul 12, 2010
94
US
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
 
Replies continue below

Recommended for you

Something like below (you need to adapt, of course)

Code:
Language="VBSCRIPT"
 
Sub CATMain()
 
Dim partDocument1 As Document
Set partDocument1 = CATIA.ActiveDocument
 
Dim selection1 As Selection
Set selection1 = partDocument1.Selection
 
selection1.Search "CATTPSSearch.CATFTAElement.Visibility=Visible,all"
 
Dim selection2 As Selection
Set selection2 = partDocument1.Selection
 
Dim visPropertySet1 As VisPropertySet
Set visPropertySet1 = selection2.VisProperties
 
visPropertySet1.SetShow 1
selection2.Clear 
 
End Sub

Regards
Fernando

 
Thanks Ferdo! I adapted to my code and that part works perfectly. My final question is how do you edit an existing Capture? Typically I would double-click a capture, hide or show the annotations under the views as needed, then click "Exit from capture" (like you're exiting a sketch) and it will save the shown/hidden state. There doesn't appear to be an OpenEdition/CloseEdition like with sketcher and DisplayCapture only displays it. Is it possible to enter or edit an existing Capture in a CATPart with a macro?
 
When I manually select a capture then type c:Activate into the input box it successfully activates the Capture and I can also type c:Exit fhe Capture to exit it too. However, I can't get this to work in a macro. Here's an example of something I tried:

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?
 
So just a few days ago I could type c:Activate into the power input box and it would activate the selected geometry but for some reason that is not working anymore. Any idea why it suddenly stopped working? I never got send keys to work in my code either.
 
I never got Sendkeys to work with CATScript but I did get this to work in VBA:

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?
 
Hi,

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

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top