<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: ilogic to load a style in templates automatically in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-to-load-a-style-in-templates-automatically/m-p/9720801#M58749</link>
    <description>&lt;P&gt;Are you wanting to copy styled from the currently active drawing document back to the template drawing documents?&lt;/P&gt;&lt;P&gt;If so, do you want these styles to be added into the global repository (style library), so that all older drawings can have access to it, or do you want the new styles to just be local within the template files afterwords?&amp;nbsp; Do you want these new styles to be set as the default ones to be used for when you create new items of that type from those template files?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 31 Aug 2020 12:53:48 GMT</pubDate>
    <dc:creator>WCrihfield</dc:creator>
    <dc:date>2020-08-31T12:53:48Z</dc:date>
    <item>
      <title>ilogic to load a style in templates automatically</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-to-load-a-style-in-templates-automatically/m-p/9717091#M58746</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I work with different templates at a time. I want to know if there are any ilogic so that I can automatically load a style onto all the templates I have so that I don't have to each time go to style editor to change the style.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anas.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Aug 2020 11:46:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-to-load-a-style-in-templates-automatically/m-p/9717091#M58746</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-08-28T11:46:05Z</dc:date>
    </item>
    <item>
      <title>Re: ilogic to load a style in templates automatically</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-to-load-a-style-in-templates-automatically/m-p/9717276#M58747</link>
      <description>&lt;P&gt;Can you be a little more specific?&amp;nbsp; Are you talking about multiple drawing templates only, multiple part templates only, multiple assembly templates only, or a mix of drawing, part, &amp;amp; assembly templates?&amp;nbsp; What all specific kinds of styles are you talking about?&amp;nbsp; How would you want to specify which Styles you want to add into the Template files (manually enter them into the code somehow, or use an InputBox to allow you to enter the styles names and types, etc.)?&amp;nbsp; The code wold need to know what type of style it is, before it can add it into the template file.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Aug 2020 13:16:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-to-load-a-style-in-templates-automatically/m-p/9717276#M58747</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2020-08-28T13:16:20Z</dc:date>
    </item>
    <item>
      <title>Re: ilogic to load a style in templates automatically</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-to-load-a-style-in-templates-automatically/m-p/9720180#M58748</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I am talking about drawing templates only. I want to enter the style name directly in the ilogic , the input box also will work just fine.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Aug 2020 05:29:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-to-load-a-style-in-templates-automatically/m-p/9720180#M58748</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-08-31T05:29:56Z</dc:date>
    </item>
    <item>
      <title>Re: ilogic to load a style in templates automatically</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-to-load-a-style-in-templates-automatically/m-p/9720801#M58749</link>
      <description>&lt;P&gt;Are you wanting to copy styled from the currently active drawing document back to the template drawing documents?&lt;/P&gt;&lt;P&gt;If so, do you want these styles to be added into the global repository (style library), so that all older drawings can have access to it, or do you want the new styles to just be local within the template files afterwords?&amp;nbsp; Do you want these new styles to be set as the default ones to be used for when you create new items of that type from those template files?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Aug 2020 12:53:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-to-load-a-style-in-templates-automatically/m-p/9720801#M58749</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2020-08-31T12:53:48Z</dc:date>
    </item>
    <item>
      <title>Re: ilogic to load a style in templates automatically</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-to-load-a-style-in-templates-automatically/m-p/9720970#M58750</link>
      <description>&lt;P&gt;Hi @Anonymous&amp;nbsp;&lt;/P&gt;&lt;P&gt;Are you looking for something like this?&lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="color: #ff0000;"&gt;Dim&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;oDoc&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;As&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;DrawingDocument&lt;/SPAN&gt; = &lt;SPAN style="color: #800080;"&gt;ThisDoc&lt;/SPAN&gt;.&lt;SPAN style="color: #800080;"&gt;Document&lt;/SPAN&gt;
&lt;SPAN style="color: #ff0000;"&gt;Dim&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;oList&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;As&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;New&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;List&lt;/SPAN&gt;(&lt;SPAN style="color: #ff0000;"&gt;Of&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;String&lt;/SPAN&gt;)
&lt;SPAN style="color: #ff0000;"&gt;For&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;Each&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;oStyle&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;As&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;DrawingStandardStyle&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;In&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;oDoc&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;StylesManager&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;StandardStyles&lt;/SPAN&gt;
&lt;SPAN style="color: #800000;"&gt;oList&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;Add&lt;/SPAN&gt;(&lt;SPAN style="color: #800000;"&gt;oStyle&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;Name&lt;/SPAN&gt;)
&lt;SPAN style="color: #ff0000;"&gt;Next&lt;/SPAN&gt;
&lt;SPAN style="color: #ff0000;"&gt;Dim&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;oStyleName&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;As&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;String&lt;/SPAN&gt; = &lt;SPAN style="color: #800080;"&gt;InputListBox&lt;/SPAN&gt;(&lt;SPAN style="color: #008080;"&gt;"Select Style"&lt;/SPAN&gt;, &lt;SPAN style="color: #800000;"&gt;oList&lt;/SPAN&gt;, &lt;SPAN style="color: #800000;"&gt;oList&lt;/SPAN&gt;(0))
&lt;SPAN style="color: #800000;"&gt;oDoc&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;StylesManager&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;ActiveStandardStyle&lt;/SPAN&gt; = &lt;SPAN style="color: #800000;"&gt;oDoc&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;StylesManager&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;StandardStyles&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;Item&lt;/SPAN&gt;(&lt;SPAN style="color: #800000;"&gt;oStyleName&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;P&gt;You can have the rule trigger on new document in your drawing template &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Aug 2020 14:17:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-to-load-a-style-in-templates-automatically/m-p/9720970#M58750</guid>
      <dc:creator>JhoelForshav</dc:creator>
      <dc:date>2020-08-31T14:17:35Z</dc:date>
    </item>
    <item>
      <title>Re: ilogic to load a style in templates automatically</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-to-load-a-style-in-templates-automatically/m-p/9721183#M58751</link>
      <description>&lt;P&gt;Here's some code to:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;allow you to enter a name into an InputBox&lt;/LI&gt;&lt;LI&gt;searches all styles within the active document for a style by that name to get the Style object&lt;/LI&gt;&lt;LI&gt;Saves that style to the global repository (style library)&lt;/LI&gt;&lt;LI&gt;Finds all drawing template files within the current projects templates location&lt;/LI&gt;&lt;LI&gt;Opens each one, then searches for a style by that name within it, then checks to see if it is located globally, locally, or both.&lt;UL&gt;&lt;LI&gt;If it is located globally only, it creates a local copy of it within the template file&lt;/LI&gt;&lt;LI&gt;If it is located either locally or both, it lets you know and asks you if you want to replace the existing local one within the template.&lt;UL&gt;&lt;LI&gt;If yes, it replaces it with the one from your current document.&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;Saves, then closes the template document&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;With several checks in there to help eliminate possible error messages.&lt;/P&gt;&lt;P&gt;See if this will work for you.&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Dim oDDoc As DrawingDocument = ThisDrawing.Document

'Get Style name from user
Enter :
Dim oStyleName As String = InputBox("Enter the Name of the Style you want to copy to the Templates.", "STYLE NAME")
If oStyleName = "" Then
	oAns = MsgBox("Nothing was entered. Try again?", vbYesNo + vbQuestion, "NO ENTRY")
	If oAns = vbYes Then GoTo Enter Else Return
End If

'Search for this style in the local drawing document, to get the actual Style object (early check)
Dim oFound As Boolean = False
Dim oStyle As Style
For Each oDStyle As Style In oDDoc.StylesManager.Styles
	If oDStyle.Name = oStyleName Or oDStyle.InternalName = oStyleName Then
		oFound = True
		oStyle = oDStyle
		oStyle.SaveToGlobal
	End If
Next
If oFound = False Then
	oTryAgain = MsgBox("No Style was found with that name. Try again?", vbYesNo + vbQuestion, "STYLE NOT FOUND")
	If oTryAgain = vbYes Then GoTo Enter Else Return
End If

'Get all the Drawing Template files
Dim oTPath As String = ThisApplication.DesignProjectManager.ActiveDesignProject.TemplatesPath
Dim oFileNames() As String = System.IO.Directory.GetFiles(oTPath, "*.idw", IO.SearchOption.TopDirectoryOnly)
'Check if multiple template files were found.
If oFileNames.Length = 0 Then  'it did not find any
	MsgBox("No template files were found matching your search criteria. Exiting.", vbOKOnly, "NOTHING FOUND")
	Return
ElseIf oFileNames.Length &amp;gt; 0 Then  'it found some
	a = InputListBox("There were " &amp;amp; oFileNames.Length &amp;amp; " files found matching your search criteria." &amp;amp; vbCrLf &amp;amp; "Here is the list:", oFileNames)
End If

'Open each drawing template file as a drawing document, then copy specified style library styles to local.
Dim oFName As String
Dim oTDDoc As DrawingDocument
Dim oTStyle As Style
For Each oFName In oFileNames
	oTDDoc = ThisApplication.Documents.Open(oFName, False)
	For Each oTStyle In oTDDoc.StylesManager.Styles
		If oTStyle.Name = oStyleName Or oTStyle.InternalName = oStyleName Then
			If oTStyle.StyleLocation = StyleLocationEnum.kLibraryStyleLocation Then
				oTStyle.ConvertToLocal
			ElseIf oTStyle.StyleLocation = StyleLocationEnum.kBothStyleLocation Or _
				oTStyle.StyleLocation = StyleLocationEnum.kLocalStyleLocation Then
				oReplace = MsgBox("That style already exists locally within this template file." &amp;amp; vbCrLf &amp;amp; _
				"Do you want to replace the existing one?", vbYesNo + vbQuestion, "STYLE EXISTS")
				If oReplace = vbYes Then
					Dim oTSCol As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
					oTSCol.Add(oTStyle)
					oTDDoc.StylesManager.ReplaceStyles(oTSCol, oStyle, True) 'True purges old version
				End If
			End If
		End If
	Next
	oTDDoc.Save
	oTDDoc.Close
Next&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Aug 2020 15:40:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-to-load-a-style-in-templates-automatically/m-p/9721183#M58751</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2020-08-31T15:40:06Z</dc:date>
    </item>
  </channel>
</rss>

