Showing results for 
Search instead for 
Did you mean: 

How to change all Text fonts, or Text within a rectangle window

Valued Contributor
Valued Contributor


Hello all,

   I'm trying to do two tasks programatically in a DFT.

A. Change the Font and Aspect Ratio of all of the Text in a DFT.

B. Change the Layer of all Text within a rectangle that I define in code.


A1. For objTextBox.Edit.Font, and objTextBox.Edit.AspectRatio, do I have to iterate thru every Text Box?  This would be rather slow as I have thousands to crunch thru and am using late binding in my code. 

Or can I set this at once? Would I need to modify the Text Style to do this or create a new one with the parameters I need? (if so any pointers on this?)

A2. Iterating thru all of  the objTextBox does not handle the Dimensions  and custom properties.  Am I going to have to iterate thru these two seperately as well? 

A3. I need the both the Working Sheets and the Background Sheet, so do I need to iterate thru every Sheet as well?

B1. I'm not clear on creating a Text selection set by rectangular window in code.  Any pointers on code functions to use?

 I'm using SE V20 sp6, and VB .NET Express 2005 sp1. 

Thanks ahead of time for any help and pointers.



Posted by: Dave Bartimus
Post date: 6/11/2008 5:42:10 PM


RE: How to change all Text fonts, or Text within a rectangle window

Valued Contributor
Valued Contributor

I've done something similar however, I needed to loop through all of the objects on the sheet to set other properties.

I don't know a way of setting all of the properties on mass, if you do have to loop thorugh everything then you may as well check if it is within you're rectangle at the same time and change the layer accordingly.


have a look at .drawingobjects to loop through everything on the sheet


Posted by: James Singleton
Post date: 6/12/2008 7:38:30 AM

RE: How to change all Text fonts, or Text within a rectangle window

Valued Contributor
Valued Contributor


I found 3 possible candidates for the .drawingobjects you mentioned using F2 Object Browser.

Which one did you mean?


SolidEdgeDraft.Sheet.DrawingObjects() As SolidEdgeFrameworkSupport.DrawingObjects

SolidEdgeDraft._ISheetAuto.DrawingObjects() As SolidEdgeFrameworkSupport.DrawingObjects



Last, would   objDoc.SelectSet.AddAll()    select EVERYTHING in the entire DFT on EVERY SHEET?

Thanks again.



Posted by: Dave Bartimus
Post date: 6/13/2008 6:49:01 AM

RE: How to change all Text fonts, or Text within a rectangle window

Valued Contributor
Valued Contributor


I spoke to technical support, & you can only change the font of a character style globally or for a dimension style.  You can not change the Aspect Ratio of a character style globally.  It's not exposed to the API.  You have to loop through each  TextBox in a TextBoxes collection.

An enhancement request has been made to expose Aspect Ratio to the API.

Other bad news, you can't simply define an area programmatically to select items within it.

This can only be done interactively with mouse events.  I can't believe it's not

possible, but that was my answer.

An enhancement request has been made for that, too.


Here's my code, that I have used. I left out Balloon an Property Texts.

I hope this helps somebody else out, the way this forum has helped me.  

Dim objApp As SolidEdgeFramework.Application

Dim objDoc As SolidEdgeDraft.DraftDocument

Dim objSheets As SolidEdgeDraft.Sheets

Dim objSheet As SolidEdgeDraft.Sheet

Dim objSectionSheets As SolidEdgeDraft.SectionSheets

Dim objDimStyle As SolidEdgeFrameworkSupport.DimensionStyle

Dim objDimStyles As SolidEdgeFrameworkSupport.DimensionStyles

Dim objTextBox As SolidEdgeFrameworkSupport.TextBox

Dim objTextBoxes As SolidEdgeFrameworkSupport.TextBoxes

Dim objTextEdit As SolidEdgeFrameworkSupport.TextEdit

Dim d As Integer

Dim objDocs As Object


objApp = CreateObject("SolidEdge.Application")   ' Starts Solid Edge

objDocs = objApp.Documents

objDoc = 'Opens a file


'Code to gloablly change font in all dimension styles

objDimStyles = objDoc.DimensionStyles

For Each objDimStyle In objDimStyles                              

    objDimStyle.Font = "Arial"



'Code to change font in Normal Text Style

Dim objCharStyles As Object

objCharStyles = objDoc.TextCharStyles.item("Normal") ' I only needed to change Normal, you could loop thru all instead

objCharStyles.FontName = "Arial"


'Code to loop thru collection of all working sheets and change the Aspect Ratio of each Text Box

'You can loop thru either all sheets, working sheets, or background sheets depending on your need.

'I used Working sheetsin this example

objSectionSheets = objDoc.Sections.WorkingSection.Sheets()

Working_Sheets_Per_Drawing = objSectionSheets.Count    


For d = 1 To Working_Sheets_Per_Drawing

    objSheet = objSectionSheets.Item(d)


    objTextBoxes = objSheet.TextBoxes()

    For Each objTextBox In objTextBoxes

             objTextBox.Edit.AspectRatio = 0.6 'use a double value of your choice






Posted by: Dave Bartimus
Post date: 6/18/2008 5:37:42 PM