Message 1 of 3
Transfer/Copy DrawingStyle from one Drawing to another (w/o Styleslib!)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I need to transfer a PartslistStyle from one idw to another. Using the UI you could export/import a .styxml.
As far as I know the API doesn't support working with .styxml.
What I tried:
DrawingDocument targetIDW = invApp.ActiveDocument as DrawingDocument;
DrawingStylesManager targetStylesMgr = targetIDW.StylesManager;
DrawingDocument sourceIDW = invApp.Documents.Open(
@"C:\Users\xxx\yyy.idw",
false) as DrawingDocument;
PartsListStyle partsListStyleSource;
PartsListStyle partsListStyleTarget;
partsListStyleSource = sourceIDW.StylesManager.PartsListStyles["Bauteilliste Bauteil"];
try
{
partsListStyleTarget = targetStylesMgr.PartsListStyles[partsListStyleSource.Name];
partsListStyleTarget.Delete();
}
catch
{ }
// First attempt
partsListStyleTarget = targetStylesMgr.PartsListStyles[1].Copy(partsListStyleSource.Name) as PartsListStyle;
partsListStyleTarget = partsListStyleSource;
// Second attempt
ObjectCollection replacedStyles = invApp.TransientObjects.CreateObjectCollection();
replacedStyles.Add(partsListStyleTarget);
targetStylesMgr.ReplaceStyles(replacedStyles, partsListStyleSource as Style);
Both attempts do nothing, there is no exception thrown, nor is the style updated.
I there a solution?
Thanks,
Christoph
Edit: Don't ask why I don't save to library / update from library. The customers lib is *?%!&#. 😉