Contents of text boxes inside a sketch symbol, how to update font style & size?

Contents of text boxes inside a sketch symbol, how to update font style & size?

A.Acheson
Mentor Mentor
2,359 Views
4 Replies
Message 1 of 5

Contents of text boxes inside a sketch symbol, how to update font style & size?

A.Acheson
Mentor
Mentor

Hi All,

 

I am trying to standardize the sketch symbols in the sketch library. I have a few questions. 

 

  1. How can I change the text style in existing symbol so that it reads from a new style created in the styles library?
  2. Does changing the style in the style library update existing content? In my testing it does not, in this case how are people updating the contents? Manually?
  3. In the ilogic code below I can overwrite the  style from the library by editing the local style of the sketch symbol but this does not affect the text box contents. How to change the textbox contents? To do this manually you need to manually window the text box and then select the font style and font size. 
  4. Is it possible to update the sketch symbols in the library without placing in the drawing? The code below requires each one to be placed in the active sheet. 
'https://forums.autodesk.com/t5/inventor-customization/ilogic-change-sketch-symbol-text-font/td-p/3503878
Dim oApp As Inventor.Application
oApp = ThisApplication
Dim oDoc As DrawingDocument  
oDoc = oApp.ActiveDocument
Dim oSymbol As SketchedSymbol
Dim oSymbols As SketchedSymbols
Dim oSketch As DrawingSketch
Dim oTextBox As Inventor.TextBox
Dim oTextBoxes As TextBoxes
Dim oSymDef As SketchedSymbolDefinition
Dim oStyle As TextStyle

oSymbols = oDoc.ActiveSheet.SketchedSymbols
	For Each oSymbol In oSymbols
		MessageBox.Show(oSymbol.Name, "Title")
		oSymDef = oSymbol.Definition
        oTextBoxes = oSymDef.Sketch.TextBoxes
		'oSymDef.Edit(oSketch)
            For Each oTextBox In oTextBoxes
                oStyle = oTextBox.Style
				oText = oTextBox.Text
				MessageBox.Show(oText, "Title")
				oStyle.Font = "Arial Narrow"
                oStyle.FontSize = 0.16'Font in cm
			
            Next
			'oSymDef.ExitEdit (True)
    Next

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Accepted solutions (3)
2,360 Views
4 Replies
Replies (4)
Message 2 of 5

Michael.Navara
Advisor
Advisor
Accepted solution

You can update text style in SketchedSymbolDefinition

Before execution you need to update style from DesignData

This example swaps text style of TextBox from style named "OldStyle" to "NewStyle" and back. In my test both styles are stored locally in drawing. 

 

Dim oldStyleName As String =  "OldStyle" '"NewStyle" '
Dim newStyleName As String =  "NewStyle" '"OldStyle" '

Dim drw As DrawingDocument = ThisDoc.Document
Dim newStyle As Style = drw.StylesManager.TextStyles(newStyleName)

'ONLY FOR TEST 
Dim oldStyle As Style = drw.StylesManager.TextStyles(oldStyleName)

For Each symDef As SketchedSymbolDefinition In drw.SketchedSymbolDefinitions
	For Each txtBox As Inventor.TextBox In symDef.Sketch.TextBoxes
		If txtBox.Style.Name = oldStyleName Then
			txtBox.Style = newStyle
		Else If txtBox.Style.Name = newStyleName Then
			' ELSE BLOCK FOR TEST ONLY
			txtBox.Style = oldStyle
		End If
	Next
Next

' Update instances
For Each symInstance As SketchedSymbol In drw.ActiveSheet.SketchedSymbols
	symInstance.Position = symInstance.Position
Next

 

Message 3 of 5

WCrihfield
Mentor
Mentor
Accepted solution

   I don't know if you have your sketched symbols library set-up the same way as we do, but if not, I would highly recommend it, for easier management.  We used to keep all our sketched symbols (and their definitions) in our drawing template document, that way they would all be readily available to all new drawings.  After a year or so, I found this to be a mistake.  Now we have established a separate dedicated drawing document that is only used for storing all of our sketched symbol definitions (a great many) and have them arranged in sub-folders (as many as 3 sub-folders deep), under the 'Sketch Symbols' browser folder.  This other drawing document IS our sketched symbol definitions library.  (To set this up, create a new drawing document, save it to a folder just under your project's workspace, then go to Application Options > File tab > Sketch Symbol Library folder > and enter a path to folder where this document can be found.  Now save/copy all your sketch symbol definitions to that drawing document as you would normally or use the 'Save to Symbol Library' method, making sure you specify this document within the dialog.)  Now our main drawing document template doesn't have any sketched symbols in it, and the only sketched symbols present in any of our new drawings are the ones we 'insert' from the sketched symbol library (just as easy as if they were stored locally within the document).

 

   Since all my sketched symbols are all sourced from this one drawing document, any time I want to make any changes or updates, I can do so once, in that one drawing document.  Then I have an iLogic rule to use in all older (pre-existing) drawing documents, which may contain older versions of those sketched symbols, which deletes all unused sketch symbols in the document, and replaces any existing ones that are being used with the same one from the sketched symbol library.

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.

If you want and have time, I would appreciate your Vote(s) for My IDEAS 💡or you can Explore My CONTRIBUTIONS

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 4 of 5

A.Acheson
Mentor
Mentor

@Michael.Navara 

Thanks for that code. Need to test it, does that update the existing text content also to the new style? Manually there is no option to change the text style from the style library once you have started the text in the text box. So hoping that can overcome this limitation. 

@WCrihfield 

Thanks for the heads up, The sketch symbols are all inside a sketch symbol definitions library.., when I started using the symbols I found many post recommending the central storage as it made sense. 

So this is house keeping on the existing contents styles and content in the library.  I am trying to match our Autocad drawing template and Autocad’s Romans font did not work out the same in Inventor.

 

I am trying to change all the symbols in there respective folder to a new style and because I have used the generic note text (ansi) for quiet a few things I didn’t want all that went before to be affected by a change. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 5 of 5

A.Acheson
Mentor
Mentor
Accepted solution

Solved this with figuring out how to do it manually first. Being so long since I tried to standardize text I forgot how to do it/ or missed that day in class years ago. 

https://forums.autodesk.com/t5/inventor-forum/how-to-use-the-format-text-dialog-in-drawings-and-have...

Manually:

In order to get all the text in the text box to be a certain style, I just highlighted the text box in the sketch and cycled the text style in annotate tab. 

Ilogic:

Because I had modified all the text from a style (note ansi) , I just grouped together all the same symbols that had this text style and used @Michael.Navara  code to change the style, on doing so all the text box contents revert back to following the style selected. 

I just need to make up the ilogic rule to update any existing drawings with the library symbol to ensure it is always in sync from the library. 

Is there anyway of knowing if the contents have been changed ? I can see issues like if the symbol is changed locally by editing the definition.  For another post perhaps. 

 

Thanks Everyone👍

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes