×
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

How to Hide Annotations Under a View?

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

RE: How to Hide Annotations Under a View?

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

CODE --> CATScript

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

https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...

RE: How to Hide Annotations Under a View?

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

RE: How to Hide Annotations Under a View?

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

RE: How to Hide Annotations Under a View?

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

RE: How to Hide Annotations Under a View?

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

RE: How to Hide Annotations Under a View?

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

https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...

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