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
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!
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
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!
it's possible to specify the number of caracter of texte?
ex.: if "parameter" if more than 20 caractere then