Hi @c_hoppen. You code looks like C#, which I'm not fluent in, but I think I understand what you are trying to do. I think that both attempts share the same flaw...you can't set a resource that is local to one document as the value of something in another document. You were partially on the right track though in your first attempt. You would basically need to recreate that PartsListStyle within the 'target' document, since copying it directly to another document is not an option, and uploading/downloading is also not an option. The tricky part of recreating the exact same style in another document is that all the same 'sub-styles' need to also be available in the 'target' document, or it might not work. Such as what to set as the values of the PartsListStyle's ColumnHeaderTextStyle, DataTextStyle, TitleTextStyle in the 'target' document. You could probably just make your code a lot more robust, and attempt to copy those over first, then the PartsListStyle, but you get the point. Below is a quickie attempt at this process in an iLogic rule (vb.net, not C#.net). The file path & style names are just quick generic examples here.
Sub Main
Dim oTargetIDW As DrawingDocument = ThisApplication.ActiveDocument
Dim oSourceIDW As DrawingDocument = ThisApplication.Documents.Open("C:\Temp\MyIDW.idw")
Dim oPLSName As String = "MyPListStyle1"
Dim oSourcePLS As PartsListStyle = oSourceIDW.StylesManager.PartsListStyles.Item(oPLSName)
Dim oTargetPLS As PartsListStyle = Nothing
Try
oTargetPLS = oTargetIDW.StylesManager.PartsListStyles.Item(oPLSName)
Catch
oTargetPLS = oTargetIDW.StylesManager.PartsListStyles.Item(1).Copy(oPLSName)
oTargetPLS.ColumnHeaderTextStyle = oSourcePLS.ColumnHeaderTextStyle
oTargetPLS.Comments = oSourcePLS.Comments
oTargetPLS.DataTextStyle = oSourcePLS.DataTextStyle
oTargetPLS.HeadingGap = oSourcePLS.HeadingGap
oTargetPLS.HeadingPlacement = oSourcePLS.HeadingPlacement
oTargetPLS.RowGap = oSourcePLS.RowGap
oTargetPLS.RowLineSpacing = oSourcePLS.RowLineSpacing
oTargetPLS.ShowTitle = oSourcePLS.ShowTitle
oTargetPLS.TableDirection = oSourcePLS.TableDirection
oTargetPLS.Title = oSourcePLS.Title
oTargetPLS.TitleTextStyle = oSourcePLS.TitleTextStyle
End Try
oTargetIDW.Update2(True)
'oTargetIDW.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

(Not an Autodesk Employee)