Inventor Customization

Inventor Customization

Reply
*Expert Elite*
Inv_kaos
Posts: 728
Registered: ‎07-26-2007
Message 1 of 7 (861 Views)

iLogic Change Sketch Symbol Text Font

861 Views, 6 Replies
06-17-2012 10:22 PM

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
*Expert Elite*
jdkriek
Posts: 528
Registered: ‎03-29-2007
Message 2 of 7 (829 Views)

Re: iLogic Change Sketch Symbol Text Font

06-19-2012 08:51 AM 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

Autodesk Inventor Certified Expert
Microsoft Certified Application Developer
_____________________________________________________
Did I help you? Please choose Accept as Solution or Kudos below
*Expert Elite*
jdkriek
Posts: 528
Registered: ‎03-29-2007
Message 3 of 7 (820 Views)

Re: iLogic Change Sketch Symbol Text Font

06-19-2012 09:32 AM 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

Autodesk Inventor Certified Expert
Microsoft Certified Application Developer
_____________________________________________________
Did I help you? Please choose Accept as Solution or Kudos below
*Expert Elite*
Inv_kaos
Posts: 728
Registered: ‎07-26-2007
Message 4 of 7 (800 Views)

Re: iLogic Change Sketch Symbol Text Font

06-19-2012 06:25 PM 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
*Expert Elite*
jdkriek
Posts: 528
Registered: ‎03-29-2007
Message 5 of 7 (790 Views)

Re: iLogic Change Sketch Symbol Text Font

06-20-2012 06:54 AM 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

Autodesk Inventor Certified Expert
Microsoft Certified Application Developer
_____________________________________________________
Did I help you? Please choose Accept as Solution or Kudos below
*Expert Elite*
Inv_kaos
Posts: 728
Registered: ‎07-26-2007
Message 6 of 7 (777 Views)

Re: iLogic Change Sketch Symbol Text Font

06-21-2012 09:52 PM 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
Distinguished Contributor
sergelachance
Posts: 175
Registered: ‎04-30-2012
Message 7 of 7 (500 Views)

Re: iLogic Change Sketch Symbol Text Font

02-01-2013 02:57 AM 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

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.