0

I have small problem, does anyone know how to change position of existing dimensions and Notes in Part/Product using short macro.

I will shortly describe what I want to do and what kind of problem I have.

  1. I have simple model (let say rectangle)
  2. Inside this model I have dimensions and annotations created in FTA.
  3. Next step is to drastically change position of this model (base model in point 0,0,0 and I want tochange it position to 150,10000,80 + rotation)
  4. during this change some dimensions and annotations (Theirs position in 3D) are not fully following after geometry.

Because of that I would like to have simple macro to create new position of my dimensions and annotations after part update.

I have performed some simple tests code bellow

What I have noticed, when I set new position of the text:

  1. Theoretically text change position but in 3D it stays in old position.
  2. When edit my text by double click on it and then click OK my text translates to new position which was set in macro earlier. The same situation is when I would like to change frame of the text or content (I had AAA and I would like to have BBB), it's changes only when I open Text editor.

    Set part1 = CATIA.ActiveDocument
    Set Selection = part1.Selection
    Set VisPropertySet = Selection.VisProperties
    
    Selection.Search ("name='Text.1',all")
    
    ' get selected annotation here
    Dim anAnnotation As Annotation
    Set anAnnotation = CATIA.ActiveDocument.Selection.Item(1).Value
    
    ' get annotation on the DrawingText interface
    Dim txtAnnotation As DrawingText
    Set txtAnnotation = anAnnotation.Text.Get2dAnnot()
    
    ' get TPS view that contains annotation on the DrawingView interface
    Dim vwTPSView As DrawingView
    Set vwTPSView = txtAnnotation.Parent.Parent
    
    ' get coordinates on a view
    Dim dX ' as Double
    txtAnnotation.X = 0
     txtAnnotation.Y = 30
    
    txtAnnotation.FrameType = catEllipse
    
    part1.Update
    
    End Sub
    
dadler
  • 145
  • 12
Sebastian
  • 29
  • 9

1 Answers1

0

Generally using Part.Update refreshes the annotation's position and text but you can also use:

Dim anAnnotation As Annotation
'Code here
anAnnotation.ModifyVisu 'This should work for both Texts and Dimensions

But if the above method does not work, you can try reseting the text on the annotation (It will work only for texts, and not for dimensions)

Dim vwTPSView As DrawingView
'Code here
vwTPSView.Text = vwTPSView.Text

Be carefull with this last methos though. If your text has any parameters or variables inside it, replacing the text will clear it.

Quima
  • 894
  • 11
  • 21
  • Thank you, I have tried first method only for isolated text and it works. Also I have tried for text with leader and positioning doesn't work, but at this moment I don't have more time to check if I did any mistake in code. I will check it tomorrow. – Sebastian Feb 08 '18 at 15:38