×
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 change the Dimension Text 's Font Size and Name through macro

How to change the Dimension Text 's Font Size and Name through macro

How to change the Dimension Text 's Font Size and Name through macro

(OP)
Hi,

Could some body let me know how to change the drawing dimension text font size and name.

Thanks in advance,
Maddy

RE: How to change the Dimension Text 's Font Size and Name through macro

Hi

CODE --> CATScript

' Purpose: Macro will change all text greater then 2 into 10 in an active CATIA drawing
' Usage:   1 - A CATDrawing must be active with some dimensions on it   
'          2 - Run macro 
' Author: ferdo (Disclaimer: You use this code at your own risk) 
' ======================================================
Sub CATMain()

Set drawingDocument1 = CATIA.ActiveDocument
Set Sheets = drawingDocument1.Sheets
Set activeSheet = Sheets.ActiveSheet
Set views = activeSheet.Views

For i=1 to views.Count

if i <> 2 then
Set view = views.Item(i)
Set texts = view.Texts
For j=1 to texts.Count
Set text = texts.Item(j)
text.SetFontSize 0,0,10.0  'change all text greater then 2 into 10
Next
End if
Next

End Sub 

Regards
Fernando

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

RE: How to change the Dimension Text 's Font Size and Name through macro

Or even better

CODE --> CATScript

' Purpose: Macro will change text in an active CATIA drawing according to your inputs
' Usage:   1 - A CATDrawing must be active with some dimensions on it   
'          2 - Run macro 
' Author: ferdo (Disclaimer: You use this code at your own risk) 
' ======================================================

Sub CATMain()

Set drawingDocument1 = CATIA.ActiveDocument
Set Sheets = drawingDocument1.Sheets
Set activeSheet = Sheets.ActiveSheet
Set views = activeSheet.Views

Dim myFontSize As Double
myFontSize = "10"
myFontSize = InputBox ("Please enter a font size.", "Enter Font Size", myFontSize)

Dim myFontName As Double
myFontName = "Courier"
myFontName = InputBox ("Please enter a font name.", "Enter Font Name", myFontName)

For i=1 to views.Count
if i <> 2 then
Set view = views.Item(i)
Set texts = view.Texts
For j=1 to texts.Count
Set text = texts.Item(j)
text.SetFontSize 0,0,myFontSize
text.SetFontName 0,0, "myFontName"
Next
End if
Next

End Sub 

Regards
Fernando

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

RE: How to change the Dimension Text 's Font Size and Name through macro

(OP)
Hi,

I'll try to loop through as you said above.
Still one doubt and thought to get the same clarified.

Do the text in dimension should be considered as a text and accessed separately?

I tried to do this but didn't succeeded.
For dc = 1 To oDims.Count ' Dimension loop
Set oMyDimension = oDims.Item(dc)
Set oDimText = oMyDimension.GetValue
oDimText.SetFontName 0, 0, "Courrier 10 BT"
oDimText.SetFontSize 0, 0, 10
Next

Regards,
Maddy

RE: How to change the Dimension Text 's Font Size and Name through macro

(OP)
Tried to display all the text.
But while doing so i'm not getting any dimension text displayed at all.

RE: How to change the Dimension Text 's Font Size and Name through macro

You mean you want something like this?

CODE --> CATScript

Sub CATMain()

Set drawingDocument1 = CATIA.ActiveDocument
Set Sheets = drawingDocument1.Sheets
Set activeSheet = Sheets.ActiveSheet
Set views = activeSheet.Views

Dim selection1 As Selection
Set selection1 = drawingDocument1.Selection

selection1.Search "CATDrwSearch.DrwDimension,all"

For i=1 to selection1.count
	Set Dimension = selection1.Item(i).Value
	MsgBox Dimension.GetValue.Value
Next
End Sub 

Regards
Fernando

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

RE: How to change the Dimension Text 's Font Size and Name through macro

(OP)
Yes,

Exactly, That's what i want to change the height and name.

RE: How to change the Dimension Text 's Font Size and Name through macro

(OP)
Hi Guys,

Could you please help me on this.

Regards,
Maddy



RE: How to change the Dimension Text 's Font Size and Name through macro

Hi,

I'm afraid there is no solution for what you want (sorry for misunderstanding in the beginning of the thread). If you will put the code from last CATScript in catvba and use the "watch" for Dimension, you will see there is no reference for FontName or FontSize.

Many things are not exposed in drafting workbench for common automation...and I'm afraid this is one of them.

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