Remane Text style text to text_ and replace it with Text with ilogic

Remane Text style text to text_ and replace it with Text with ilogic

Darkforce_the_ilogic_guy
Advisor Advisor
198 Views
2 Replies
Message 1 of 3

Remane Text style text to text_ and replace it with Text with ilogic

Darkforce_the_ilogic_guy
Advisor
Advisor

Remane Text style text to text_ and replace it with Text with ilogic?

 

I have this problem , that some style wouldn´t update.  but for some unknow reason if I rename a style call text  and then replace this style with Text that seems to create it self. It can now update almost all of the style except this style.. Still have no idear how to fix this one. but I have a other post for that one.

 

 

can you help

 

 

Darkforce_the_ilogic_guy_0-1727270201997.png

 

0 Likes
199 Views
2 Replies
Replies (2)
Message 2 of 3

bradeneuropeArthur
Mentor
Mentor
You will need to change it in the Stylelibrary first, with the stylelibrarymanager found under the Autodesk Programs.

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 3

WCrihfield
Mentor
Mentor

Hi @Darkforce_the_ilogic_guy.  I tend to agree that there does not appear to be a 'one size fits all' type of Inventor API routine that can magically fix all possible 'style' related issues by code.  It seems like we still can not do everything that we can do manually, within that Styles & Standards dialog, by code yet.

 

I also have a pesky style like that in one of my drawing templates that exists in both places, and seems like it will never fully update properly, so that both are in sync with each other, for some reason.  I have read lots of posts about this issue over the years, and have tried lots of things in my attempts to eliminate that message about it, but it just seems like nothing I do works.  All sheet formats have been deleted.  All sketch symbol definitions have been deleted.  All border definitions except the 'main' one have been deleted.  All title block definitions have been deleted except the 'main' one.  I had those only two remaining border/title block definition sketches open/active while performing the global 'update from style library' actions, and have done those update steps outside of those sketches.  When using the main 'Purge' tool in the Manage tab > Styles & Standards panel, there is nothing in the list to purge.  Still that one style remains in the list every time when using that main Update tool in that same panel.  There are only two 'Standard' styles that are considered 'local' within the Styles & Standards editor dialog, and the one that is not 'active' will not allow me to 'purge' it, even though as far as I can determine, I can not find anything in this entire document that is 'dependent' on it or 'using' it.  Even some of the 'local' styles that only exist within that 'non-active' standard style, will not allow me the option to purge them, for some reason.

 

However, I will still share an example code below that sounds like it is at least trying to do the process you described in your original post here.  It will only run when a drawing is active.  It then attempts to find an existing TextStyle named "text" (to be renamed, and replaced), and one named "Text" (to replace the other one with).  If it can not find either one, it will write something to the iLogic Log window about it, then exit the rule.  It will then try to rename the TextStyle named "text" to "text_", and if that fails, it will also report it, then exit the rule.  It will the try to replace the TextStyle named "text_" with the TextStyle named "Text".  If that works, it will then try to update the drawing.  I have not tested this rule yet myself, because I do not want to mess with any of my TextStyles.

Sub Main
	Dim oInvApp As Inventor.Application = ThisApplication
	Dim oDDoc As DrawingDocument = TryCast(ThisDoc.Document, Inventor.DrawingDocument)
	If oDDoc Is Nothing Then Return
	Dim oDSMgr As DrawingStylesManager = oDDoc.StylesManager
	Dim oTSs As TextStylesEnumerator = oDSMgr.TextStyles
	Dim sOrigTS_Name As String = "text"
	Dim sRenameTo As String = "text_"
	Dim sReplacementTS_Name As String = "Text"
	Dim oOrigTS, oReplacementTS As TextStyle
	Try : oOrigTS = oTSs.Item(sOrigTS_Name) : Catch : End Try
	If oOrigTS Is Nothing Then
		Logger.Debug("Could not find existing TextStye named " & sOrigTS_Name)
		Return
	End If
	Try : oReplacementTS = oTSs.Item(sReplacementTS_Name) : Catch : End Try
	If oReplacementTS Is Nothing Then
		Logger.Debug("Could not find existing TextStye named " & sReplacementTS_Name)
		Return
	End If
	Try
		oOrigTS.Name = sRenameTo
		Logger.Info("Renamed TextStyle '" & sOrigTS_Name & " to '" & sRenameTo & "'.")
	Catch
		Logger.Error("Error renaming TextStyle '" & sOrigTS_Name & " to '" & sRenameTo & "'!")
		Return
	End Try
	Dim oToBeReplaced As ObjectCollection = oInvApp.TransientObjects.CreateObjectCollection
	oToBeReplaced.Add(oOrigTS)
	Try
		oDSMgr.ReplaceStyles(oToBeReplaced, oReplacementTS, PurgeReplacedStyles = True)
	Catch
		Logger.Error("Error replacing TextStyle '" & sRenameTo & " with '" & sReplacementTS_Name & "'!")
		Return
	End Try
	oDDoc.Update2(True)
	'oDDoc.Save()
End Sub

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

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes