Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iLogic Change Sketch Symbol Text Font

6 REPLIES 6
Reply
Message 1 of 7
Inv_kaos
2593 Views, 6 Replies

iLogic Change Sketch Symbol Text Font

Hi All,

 

My iLogic ability is quite limited outside of what I use regularly, hopefully someone can help?

 

I am trying to change the font style in every text definition in all my sketch symbols in one go. Actually I have started it based on only a selection set but I would be happy with just all symbols too. Below is where I got to, I am stuck on the For Each line to cover each text box in the symbol. Some of the other syntax may not be right either but I can't test it all the way through.

 

Dim oDoc As DrawingDocument: oDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet: oSheet = oDoc.ActiveSheet

Dim i As Long
Dim oSymDef As SketchedSymbolDefinition: oSymDef = oDoc.SketchedSymbolDefinitions.Item(i)

Dim oText As TextBoxes

For i = 1 To oDoc.SelectSet.Count

For Each oText In ............

oSymDef.TextBoxes.Item(i).FormattedText ="<StyleOverride Font='ARIAL'>...< /StyleOverride>"

Next

Next

InventorVb.DocumentUpdate()

 

Also the XML style override is not complete if this is the only way to achieve this result.

 

Cheers,

Stew

Please mark as "Accept as Solution" if it answers your question or "Kudos" if you found it useful.
---------------------------------------------------------------------------------------------------------------------
Stew, AICP
Inventor Professional 2013, Autodesk Simulation Multiphysics 2013
Windows 7 x64 Core i7 32GB Ram FX2000
6 REPLIES 6
Message 2 of 7
jdkriek
in reply to: Inv_kaos

You were missing For Each oTextBox In oTextBoxes (Or similar) but that doesn't fix your code.

 

Should looks something like this...

 

Dim oApp As 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 TextBox
Dim oTextBoxes As TextBoxes
Dim oSymDef As SketchedSymbolDefinition
oSymbols = oDoc.ActiveSheet.SketchedSymbols
    For Each oSymbol In oSymbols
        oSymDef = oSymbol.Definition
        oSymDef.Edit(oSketch)
        oTextBoxes = oSymDef.Sketch.TextBoxes
            For Each oTextBox In oTextBoxes
                oTextBox.FormattedText = "<StyleOverride Font='ARIAL'>...</StyleOverride>"
            Next
        oSymDef.ExitEdit()
    Next

 

You might also look into changing the elements of the text directly?

 

oTextBox.Style.Font = "Arial"
oTextBox.Style.FontSize = 10

 

Hope this helps!

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 3 of 7
jdkriek
in reply to: jdkriek

Here's an example using the TextStyle - I like this method better

 

Dim oApp As 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 TextBox
Dim oTextBoxes As TextBoxes
Dim oSymDef As SketchedSymbolDefinition
Dim oStyle As TextStyle
oSymbols = oDoc.ActiveSheet.SketchedSymbols
	For Each oSymbol In oSymbols
		oSymDef = oSymbol.Definition
        oTextBoxes = oSymDef.Sketch.TextBoxes
            For Each oTextBox In oTextBoxes
                oStyle = oTextBox.Style
                oStyle.Font = "Chiller"
                oStyle.FontSize = 10
            Next
    Next

 

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 4 of 7
Inv_kaos
in reply to: jdkriek

Thanks Jon, One problem so far is if the sketch symbol geometry & text has been copied in from AutoCAD I can manually change the font just the same but the code doesn't seem to affect it. Also for Geometry Text there is no change. For everything else this works well. When iLogic was first released free for Inventor there was information in the help files for the Object Library (limited but better than nothing). Is there any way to look up this information now? Otherwise it seems like I have to guess the correct syntax for my code if I can't find a very similar example. Basically there is no intellisense for iLogic so what other options is there for the user? Cheers.
Please mark as "Accept as Solution" if it answers your question or "Kudos" if you found it useful.
---------------------------------------------------------------------------------------------------------------------
Stew, AICP
Inventor Professional 2013, Autodesk Simulation Multiphysics 2013
Windows 7 x64 Core i7 32GB Ram FX2000
Message 5 of 7
jdkriek
in reply to: Inv_kaos

It depends on how the AutoCAD text was brought in. Normally I edit the text box in AutoCAD and copy it directly from there, then create a text box in Inventor and paste it directly into it. If it was brought in any other way, then unfortunately that "text" isn't really text, it's rasterized so to speak and can't be changed like normal text at least programmatically.

 

About coding: iLogic is essentially VB.NET, so I write all my code in VBA (which has intellisense). All you need to do most of the time is change the syntax a little and boom you have iLogic working. Here's a quick example.

 

VBA

 

Public Sub VBA()
    Dim oApp As Application
    Set oApp = ThisApplication
End Sub

 

iLogic (VB.NET)

 

Dim oApp As Application: oApp = ThisApplication

 

iLogic also has the ability to run straight VBA if you don't feel like converting it.

Just check the box under options when you edit the rule.

 

Hope this helps!

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 6 of 7
Inv_kaos
in reply to: jdkriek

These are all weld details that have been copied from AutoCAD (lines, dimensions & text), we have not copied just the text in one go. It still works fine like most text brought in from ACAD but I guess we will just have to modify it all manually. Thanks for the help. I have been working in Visual Studio a bit recently but need more practice. Even though it is simplified VB.NET I still see more parallels with VBA.
Please mark as "Accept as Solution" if it answers your question or "Kudos" if you found it useful.
---------------------------------------------------------------------------------------------------------------------
Stew, AICP
Inventor Professional 2013, Autodesk Simulation Multiphysics 2013
Windows 7 x64 Core i7 32GB Ram FX2000
Message 7 of 7
ChristinaForest
in reply to: Inv_kaos

it's possible to specify the number of caracter of texte?

 

ex.: if "parameter" if more than 20 caractere then

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report