<?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: Import existing table style file (.styxml) from code in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/import-existing-table-style-file-styxml-from-code/m-p/7440516#M97334</link>
    <description>&lt;P&gt;I dont believe it's possible. Closest potential route I could think is using some control definition if available.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's not really one of autodesk supported workflows to be loading styles individually; it should either be set up in a library, or be fine with whatever was in the template when it was originally created.&lt;/P&gt;</description>
    <pubDate>Fri, 06 Oct 2017 16:15:26 GMT</pubDate>
    <dc:creator>MechMachineMan</dc:creator>
    <dc:date>2017-10-06T16:15:26Z</dc:date>
    <item>
      <title>Import existing table style file (.styxml) from code</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/import-existing-table-style-file-styxml-from-code/m-p/7440317#M97333</link>
      <description>&lt;P&gt;Hi folks,&lt;BR /&gt;&lt;BR /&gt;Let's say we have a previously saved Table style file called "FOO.styxml".&lt;BR /&gt;&lt;BR /&gt;With an IDW document open in Inventor and a table created and selected, how can we programmatically import that Table style file?&lt;BR /&gt;&lt;BR /&gt;Doing it manually from the Edit Table Style dialog and clicking the Import button does it.&amp;nbsp; So how can we do that in code?&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;--Jeff&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2017 15:18:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/import-existing-table-style-file-styxml-from-code/m-p/7440317#M97333</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-10-06T15:18:24Z</dc:date>
    </item>
    <item>
      <title>Re: Import existing table style file (.styxml) from code</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/import-existing-table-style-file-styxml-from-code/m-p/7440516#M97334</link>
      <description>&lt;P&gt;I dont believe it's possible. Closest potential route I could think is using some control definition if available.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's not really one of autodesk supported workflows to be loading styles individually; it should either be set up in a library, or be fine with whatever was in the template when it was originally created.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2017 16:15:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/import-existing-table-style-file-styxml-from-code/m-p/7440516#M97334</guid>
      <dc:creator>MechMachineMan</dc:creator>
      <dc:date>2017-10-06T16:15:26Z</dc:date>
    </item>
    <item>
      <title>Re: Import existing table style file (.styxml) from code</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/import-existing-table-style-file-styxml-from-code/m-p/7440534#M97335</link>
      <description>&lt;P&gt;Thank you for your reply, Justin.&amp;nbsp; And please forgive my ignorance on this style subject.&amp;nbsp; Perhaps you would be able to add some more insight on these items...&lt;BR /&gt;&lt;BR /&gt;1.) In my current effort, I expect the client already has their custom table style configured on their systems.&amp;nbsp; Is there anything special I need to do to ensure that the CustomTables objects I am creating in code take on whatever table style would normally be applied if they created the tables manually through the regular Inventor UI?&lt;BR /&gt;&lt;BR /&gt;2.) I have some examples of their tables in an IDW file.&amp;nbsp; So far, I have exported that table style from the drawing and imported it into my Inventor style settings.&amp;nbsp; But what would I need to do to get that table style to be the default table style for new tables on my system?&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;--Jeff&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2017 16:24:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/import-existing-table-style-file-styxml-from-code/m-p/7440534#M97335</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-10-06T16:24:31Z</dc:date>
    </item>
    <item>
      <title>Re: Import existing table style file (.styxml) from code</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/import-existing-table-style-file-styxml-from-code/m-p/7440623#M97336</link>
      <description>&lt;P&gt;Style is stored in 3 places: Style Library, Template and File.&lt;/P&gt;&lt;P&gt;All 3 could be different.&lt;/P&gt;&lt;P&gt;When user create a file from template, style is pull from template if style is store in it and different then library.&lt;/P&gt;&lt;P&gt;Once the file is created, user could modify style and it'll be in that file only.&lt;/P&gt;&lt;P&gt;If you import style into that file, it'll be in that file only.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So you could import the style and save the file as a template to create new file with that style.&amp;nbsp; You don't need to change the style library.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2017 17:05:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/import-existing-table-style-file-styxml-from-code/m-p/7440623#M97336</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-10-06T17:05:05Z</dc:date>
    </item>
    <item>
      <title>Re: Import existing table style file (.styxml) from code</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/import-existing-table-style-file-styxml-from-code/m-p/7440630#M97337</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;me again, it would be a useful feature and already requested more than once: &lt;A href="https://forums.autodesk.com/t5/inventor-ideas/import-styles-styxml-files-via-ilogic/idi-p/5595898" target="_blank"&gt;1&lt;/A&gt;, &lt;A href="https://forums.autodesk.com/t5/inventor-ideas/import-styxml-files-using-ilogic/idi-p/5241839" target="_blank"&gt;2&lt;/A&gt;, &lt;A href="https://forums.autodesk.com/t5/inventor-customization/api-for-import-the-revision-table-style-to-inventor-drawing-file/td-p/6446976" target="_blank"&gt;...&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I workarounded it making methods to copy styles between two documents, not all the styles yet and the tableStyle is one of those missing to me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyway, if you work with&amp;nbsp;Local style, the methods you need should be something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;''' &amp;lt;summary&amp;gt;
''' Copy TextStyle. i.e. set all object's properties with setter.
''' &amp;lt;/summary&amp;gt;
''' &amp;lt;remarks&amp;gt;Useful to copy style between different documents&amp;lt;/remarks&amp;gt;
Public Sub CopyTextStyles(ByRef replaceStyle As TextStyle, withStyle As TextStyle)
	If replaceStyle Is Nothing OrElse withStyle Is Nothing Then
		Return
	End If

	replaceStyle.Bold = withStyle.Bold
	replaceStyle.Color = withStyle.Color
	replaceStyle.Comments = withStyle.Comments
	replaceStyle.Font = withStyle.Font
	replaceStyle.FontSize = withStyle.FontSize
	replaceStyle.HorizontalJustification = withStyle.HorizontalJustification
	replaceStyle.Italic = withStyle.Italic
	replaceStyle.LineSpacing = withStyle.LineSpacing
	replaceStyle.LineSpacingType = withStyle.LineSpacingType
	replaceStyle.Name = withStyle.Name
	replaceStyle.Rotation = withStyle.Rotation
	replaceStyle.Underline = withStyle.Underline
	replaceStyle.VerticalJustification = withStyle.VerticalJustification
	replaceStyle.WidthScale = withStyle.WidthScale
End Sub&lt;/PRE&gt;&lt;PRE&gt;Public Sub CopyCustomTableStyles(ByRef replaceStyle As TableStyle, withStyle As TableStyle)         
   
	Dim replaceStyleManager As DrawingStylesManager = replaceStyle._Parent
  
  
	' TODO: Copy all CustomTable properties with setter like HeadingPlacement, ... 
	
  
	' For the properties that are theirself a style like DataTextStyle, HeaderTextStyle, ... 
	' you have to make sure that requested style is defined in this document, if not you have to had it
	' Check the existence in this document of the textStyle referenced by withStyle
	Dim tsDefined As Boolean = False
	For Each textStyle As TextStyle In replaceStyleManager.TextStyles
		If textStyle.Name = withStyle.DataTextStyle.Name Then
			tsDefined = True
			Exit For
		End If
	Next

	If Not tsDefined Then
		For Each textStyle As TextStyle In replaceStyleManager.TextStyles
			If textStyle.StyleLocation &amp;lt;&amp;gt; StyleLocationEnum.kLibraryStyleLocation Then
				' Create textStyle starting from the first non library located textStyle
				Dim newts As TextStyle = textStyle.Copy(withStyle.DataTextStyle.Name)
				CopyTextStyles(newts, withStyle.DataTextStyle)
				Exit For
			End If
		Next
	End If

	replaceStyle.DataTextStyle = withStyle.DataTextStyle
	
end Sub&lt;/PRE&gt;&lt;P&gt;And call the last one like this:&lt;/P&gt;&lt;PRE&gt;Dim newTemplateIdw As DrawingDocument = ActiveInventorApplication.Documents.Open(newTemplateIdwPath, False)

Dim curDrwDoc As DrawingDocument = ActiveInventorApplication.ActiveDocument

           Dim withSts As TableStyle = newTemplateIdw.StylesManager.TableStyles.Item("tableStyleName")

            For Each tableStyle As TableStyle In curDrwDoc.StylesManager.TableStyles
                If tableStyle .StyleLocation &amp;lt;&amp;gt; StyleLocationEnum.kLibraryStyleLocation Then
                    If tableStyle .Name = "tableStyleName"Then
                        CopyCustomTableStyles(tableStyle , withSts)
                        Exit For
                    End If
                End If
            Next&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2017 17:12:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/import-existing-table-style-file-styxml-from-code/m-p/7440630#M97337</guid>
      <dc:creator>CattabianiI</dc:creator>
      <dc:date>2017-10-06T17:12:22Z</dc:date>
    </item>
    <item>
      <title>Re: Import existing table style file (.styxml) from code</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/import-existing-table-style-file-styxml-from-code/m-p/7440641#M97338</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;SPAN&gt;Frederick.&amp;nbsp; Thanks for your reply.&lt;BR /&gt;&lt;BR /&gt;In my case, I am not creating the file from my add-in.&amp;nbsp; The user has already created the IDW file before they use my add-in to create the CustomTable object.&amp;nbsp; I just want to make sure that the CustomTable object uses the style that is needed.&amp;nbsp; So that probably rules out the template approach for me.&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;As far as the document, I had tried just affecting the document from code, but that did not work out for me...&lt;BR /&gt;&lt;A href="https://forums.autodesk.com/t5/inventor-customization/why-don-t-customtable-text-styles-affect-their-respective-areas/td-p/7417235" target="_blank"&gt;https://forums.autodesk.com/t5/inventor-customization/why-don-t-customtable-text-styles-affect-their-respective-areas/td-p/7417235&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;So that leaves a library - would it be effective to use a library setting?&amp;nbsp; Could I import the existing style into a library and then apply that style from the library using code from my add-in?&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;--Jeff&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2017 17:16:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/import-existing-table-style-file-styxml-from-code/m-p/7440641#M97338</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-10-06T17:16:37Z</dc:date>
    </item>
    <item>
      <title>Re: Import existing table style file (.styxml) from code</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/import-existing-table-style-file-styxml-from-code/m-p/7440644#M97339</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;Isacco,&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;Thank you for your reply.&amp;nbsp; Interesting.&amp;nbsp; I will try this as soon as I get a chance.&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;--Jeff&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2017 17:17:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/import-existing-table-style-file-styxml-from-code/m-p/7440644#M97339</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-10-06T17:17:55Z</dc:date>
    </item>
    <item>
      <title>Re: Import existing table style file (.styxml) from code</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/import-existing-table-style-file-styxml-from-code/m-p/7440705#M97340</link>
      <description>&lt;P&gt;Its not simple.&lt;/P&gt;&lt;P&gt;Table Style use other styles like Note Text, Dimension, Layer and maybe other.&amp;nbsp; You'll need to copy all of them to get it to work properly.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2017 17:44:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/import-existing-table-style-file-styxml-from-code/m-p/7440705#M97340</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-10-06T17:44:24Z</dc:date>
    </item>
    <item>
      <title>Re: Import existing table style file (.styxml) from code</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/import-existing-table-style-file-styxml-from-code/m-p/7440722#M97341</link>
      <description>&lt;P&gt;Hi Frederick,&lt;BR /&gt;&lt;BR /&gt;That's why exporting the Table style seemed so convenient - it is self-contained and brings with it any related styles that it uses.&amp;nbsp; But if I cannot import it via code, then it's not much use to me in this instance.&lt;BR /&gt;&lt;BR /&gt;It seems like there ought to at least be some way to not disturb whatever the system style preferences already are.&amp;nbsp; If the user creates a table with the UI, it uses some configured style.&amp;nbsp; Is there a way to create a table in code and somehow stipulate that you do not intend to override any styles from whatever the system's configured table style is already set at?&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;--Jeff&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2017 17:51:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/import-existing-table-style-file-styxml-from-code/m-p/7440722#M97341</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-10-06T17:51:13Z</dc:date>
    </item>
    <item>
      <title>Re: Import existing table style file (.styxml) from code</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/import-existing-table-style-file-styxml-from-code/m-p/7441371#M97342</link>
      <description>&lt;P&gt;Hi Jeff,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I guess it seems through the method posted above there may be some way of copying the styles over through code. Would be interested in trying it out.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As for your other thread, it looks like the code would be effectively trying to change all of the styles that are used directly.&lt;/P&gt;
&lt;P&gt;ie; Custom Table is place, uses "Default" as style. That previous thread CHANGED 'Default'.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you instead use&lt;/P&gt;
&lt;PRE&gt;customTable.Style&lt;/PRE&gt;
&lt;P&gt;you would be able to change the styles used from "Default" to "Some Custom Style".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The way you set up what style is used by default is pretty interesting. It's defined by whatever is selected under the 'ACTIVE Object Defaults Style' as listed under the 'ACTIVE Standard'.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A further 2 ways of accomplishing the copying of styles would be to OPEN a template file and copy styles over from that live style (be warned that there may be some hoops to jump through if overwriting a style with a different style of the same name), or by having the style saved in the library and using the 'Style Update' feature to pull the library styles into the local document.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best of luck,&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2017 22:55:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/import-existing-table-style-file-styxml-from-code/m-p/7441371#M97342</guid>
      <dc:creator>MechMachineMan</dc:creator>
      <dc:date>2017-10-06T22:55:24Z</dc:date>
    </item>
  </channel>
</rss>

