Continue to Site

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!

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

Status
Not open for further replies.

Maddy02

Mechanical
Feb 14, 2013
114
IN
Hi,

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

Thanks in advance,
Maddy
 
Replies continue below

Recommended for you

Hi

Code:
' 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

 
Or even better

Code:
' 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

 
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
 
Tried to display all the text.
But while doing so i'm not getting any dimension text displayed at all.
 
You mean you want something like this?

Code:
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

 
Yes,

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

Could you please help me on this.

Regards,
Maddy



 
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

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top