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!

Switch/Enable annotation set on/off

Status
Not open for further replies.

Thosnow

Aerospace
Feb 23, 2017
68
CA
Hello All,

I can turn the annotation captures on/off but not able to figure out how to switch/enable annotation set on and off with a VBA/VBScript code such as you use CATIA with mouse-right click on the annotation set itself?

Please see image below to understand my question.

SWITCH_ANNOTATION_aic5qq.jpg


Please help if you can.

Thank you in advance

Quin
 
Replies continue below

Recommended for you

Thank you Ferdo. I will try your way and let you know.

Ah....for ENOVIA/DMU license only), ENOVIA does not have Command "Annotation Set Switch On/Switch Off", but it only has "3D visualization" command button (I see from command tip if you hover the mouse cursor on the command button). See image below for more info.

Capture_gtk5au.jpg


What is the right syntax for the macro or CATIA Command to switch/enable annotation set on/off?

Thank you again

Quin
 
Hi Ferdo, Follow the first thread above and your guidance, below is my VBA code but it seems not working properly.

After running below VBA code, no annotation or captures. However, if I left click (one time with the mouse) on the "CATPart 3D Annotations", the annotation appear successfully.

1) What does it mean? Do I miss something? It seems the screen needs to be refreshed after running the code in order to see the captures/annotations. Does it relate to CATIA.RefreshDisplay command at all and how to use this command?
2) How can I emulate the mouse-right click to trigger command: CATIA.StartCommand ("Annotation Set Switch On/Switch Off")?

-------------------- VBA CODE -----------------------

Option Explicit

Sub CATMain()

'//// Returns or sets the application ability to display file alerts. "True" is the default
CATIA.DisplayFileAlerts = False

'//// Access the active document
Dim PartDoc As Document
Set PartDoc = CATIA.ActiveDocument
'//// Set PartRoot part from the PartDoc part document
Dim PartRoot
Set PartRoot = PartDoc.Part

'//// Set user's annotation collection = PartRoot annotation sets, which has multiple annotation sets
Dim myAnnotCollection
Set myAnnotCollection = PartRoot.AnnotationSets

' myAnnotCollection.Clear
'//// Get first annotation set from annotation collection, myAnnotCollection
Dim AnnoSet1
Set AnnoSet1 = myAnnotCollection.Item(1)

'//// Search oSelection set for actual name of the Annotation Set.
'//// Common name is "CATPart 3D Annotations" but it may be different name
MsgBox AnnoSet1.Name '//// Display actual name of the annotation set

' oSelection.Search ("Name = AnnoSet1.Name, all") need this ???

'//// Enable CATPart annotation set
CATIA.StartCommand "Annotation Set Switch On/Switch Off"

End Sub

Thank you

Quin
 
Hi,

Not all commands are available in different workbenches. First you need to switch to the right workbench then apply what I said. Do not simply copy/paste code, this will not help you. Think before do something...

Read some examples (even if they are related to somehow similar subjects and not exactly currently yours), try to record first some manual actions (maybe, but not always, they will be recorded) and not at last, read carefully documentation and samples. As I said, you need to select first "CATPart 3D Annotations" searching by name or by type or by user selection then launch the command.

And by the way, nobody will create a CATPart to test what you are trying to do, is always better to have a sample CATPart in order to test code.

Regards
Fernando

- Romania
- EU
 
Hi Ferdo,

"...you need to select first "CATPart 3D Annotations" searching by name or by type or by user selection then launch the command." This is what I got the annotation set'name displayed at the code line: MsgBox AnnoSet1.Name in my VBA code above.

The code displays name of annotation set successfully but I am not quite sure how to relate name of the annotation set to CATIA.StartCommand "Annotation Set Switch On/Switch Off".

Any help is much appreciated.

Quyen
 
when you put your mouse over the icon of a function, the catia name of that function is displayed at the bottom of the screen. use that name in the startcommand line

Eric N.
indocti discant et ament meminisse periti
 
Hi Itsmyjob,

Yes, hovering the mouse cursor on the CATPart 3D Annotations and it displays "CATPart 3D Annotations". So,
here is my command: CATIA.StartCommand ("CATPart 3D Annotations") and CATIA says unknown command.

In fact, CATIA.StartCommand ("Annotation Set Switch On/Switch Off") works, but somehow the annotated captures do not show up on the screen. I need to physically left-click "CATPart 3D Annotations" on the spec tree and then the annotation appear.

What is your suggestion?

QUin
 
did you select the object in the tree before you start the commandline?

Eric N.
indocti discant et ament meminisse periti
 
In my VBA code below, does this line of code mean I pick the object in the tree "AnnoSet1.Name"?
If not, what could the code/syntax be to pick up the object?

-----------------------

Option Explicit

Sub CATMain()

'//// Returns or sets the application ability to display file alerts. "True" is the default
CATIA.DisplayFileAlerts = False

'//// Access the active document
Dim PartDoc As Document
Set PartDoc = CATIA.ActiveDocument
'//// Set PartRoot part from the PartDoc part document
Dim PartRoot
Set PartRoot = PartDoc.Part

'//// Set user's annotation collection = PartRoot annotation sets, which has multiple annotation sets
Dim myAnnotCollection
Set myAnnotCollection = PartRoot.AnnotationSets

' myAnnotCollection.Clear
'//// Get first annotation set from annotation collection, myAnnotCollection
Dim AnnoSet1
Set AnnoSet1 = myAnnotCollection.Item(1)

'//// Search oSelection set for actual name of the Annotation Set.
'//// Common name is "CATPart 3D Annotations" but it may be different name
MsgBox AnnoSet1.Name '//// Display actual name of the annotation set

'//// Enable CATPart annotation set
CATIA.StartCommand "Annotation Set Switch On/Switch Off"

End Sub

Thanks for your help

Quin
 
check Selection examples in v5automation.chm

Eric N.
indocti discant et ament meminisse periti
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top