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


Creating annotations in CATIA V5 parallel to screen via script

Creating annotations in CATIA V5 parallel to screen via script

Creating annotations in CATIA V5 parallel to screen via script

Hi All,

I am currently trying to create annotations in CATIA V5 via a script - I have managed to do normal annotations see script below however I am trying to get the annotation which is created to be parallel to screen?

There is a button in the FTA toolbar which does this - however I need it in script.

Anyone got any ideas?

(I've tried to record a macro however it doesn't pick up annotation settings/properties)


Script so far:

set opart=GetPartFromObject(oParam1)

Set part1 = opart

Set annotationSets1 = part1.AnnotationSets

Set annotationSet1 = annotationSets1.Add("ISO_3D")

Set userSurfaces1 = part1.UserSurfaces

Set userSurface1 = userSurfaces1.Generate(oPoint)
'Above is the point

Set viewFactory1 = annotationSet1.TPSViewFactory
Set view1 =viewFactory1.CreateView(oPlane,1)

Set annotationFactory1 = annotationSet1.AnnotationFactory

Set annotation1 = annotationFactory1.CreateEvoluateText(userSurface1,50, 50, 50, True)
annotation1.text.Get2dAnnot.ActivateFrame catRectangle
annotation1.text.Get2dAnnot.FrameType = catRectangle
annotation1.Text.Get2dAnnot.SetFontName 0, 0, "Arial (TrueType)"
annotation1.Text.Get2dAnnot.SetFontSize 0, 0, CDbl("5.0")
annotation1.TransfertToView view1

oList.valuelist.Add annotation1.Text

Dim LResult1 As Long
LResult1 = Len (oParam1.Name) +4

annotation1.Text.Text = oParam1.Name & " = "
annotation1.Text.Get2dAnnot.InsertVariable LResult1 , 0, oParam1


annotation1.Name = oParam1.Name

Set annotationSet1 = annotationSets1.Item("Annotation Set.1")

End Sub

RE: Creating annotations in CATIA V5 parallel to screen via script

Hi RumSam!

I had the same exact problem. Finally, I managed to write annotations parallel to screen via macros by using CATIA StartCommand and the proper command, "Text Parallel To Screen". Then I used SendKeys function, but with a workaround to avoid the error message regarding lack of permissions and making the CPU wait some milisecs just to give CATIA time to process the sent keys. It's all a bit tricky but it worked for me. I copy the code below.

Hope it is helpfull to you, regards!

'-- CODE!-----------------------------------------------------------------------------
Sub AddAnnnotationsWithKeys(iHB As HybridBody, iHSIndex As Long, iText As String)

'-- Where iHSIndex is the index of the Hybrid shape which the annotation will be attached to and iHB is the Part Hybrid body where it is.---------------
Dim partDocument1 As PartDocument
Dim part1 As Part

Dim selection1 As Selection
Dim skObject As Object
'-- skObject is created only to use SendKeys function without any failure-------------

Dim newAnnot As Annotation
Dim annotationSet1 As AnnotationSet

Dim timeNoF
Dim lTimeIni As Date

Set partDocument1 = CATIA.ActiveDocument
Set part1 = partDocument1.Part

'-- Target surface is selected and then the annotation command is called---------------
Set selection1 = partDocument1.Selection
selection1.Add iHB.HybridShapes.Item(iHSIndex)
CATIA.StartCommand "Text Parallel To Screen"
CATIA.RefreshDisplay = True

'-- A generic text is sent just to create the annotation-------------------------------
Set skObject = CreateObject("wscript.shell")
skObject.SendKeys "text", True

'-- It is necesary to wait around 100 or 200 msecs to give CATIA enough time before "pressing" ENTER-----------
'-- If condition was added just for safety, in order to avoid infinite loops-----------------------------------
lTimeIni = Now
timeNoF = Timer
If Now > (lTimeIni + "00:00:05") Then
Exit Sub
End If
Loop Until Timer > timeNoF + 0.2

skObject.SendKeys "{ENTER}", True

CATIA.RefreshDisplay = True

'-- Annotation parameters are finally set as desired.---------------------------------
Set annotationSet1 = part1.AnnotationSets.Item(1)
Set newAnnot = annotationSet1.Annotations.Item(annotationSet1.Annotations.Count)

newAnnot.text.text = iText
newAnnot.text.Get2dAnnot.SetFontSize 0, 0, 2.7

'-- ;););););););););););););););)

End Sub

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!


eBook - Efficient and Effective Production Support with 3D Printed Jigs and Fixtures
Jigs and fixtures offer manufacturers a reliable process for delivering accurate, high-quality outcomes, whether for a specific part or feature, or for consistency across multiples of parts. Although the methodologies and materials for producing jigs and fixtures have evolved beyond the conventional metal tooling of years past, their position as a manufacturing staple remains constant due to the benefits they offer. Download Now
Overcoming Cutting Tool Challenges in Aerospace Machining
Aerospace manufacturing has always been on the cutting edge, from materials to production techniques. However, these two aspects of aerospace machining can conflict, as manufacturers strive to maintain machining efficiency with new materials by using new methods and cutting tools. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close