Hi all,
Does anyone know of a way to automate the import of Style Definition files into the style and standard manager in the drawing environment? If not is there some other way to do it?
I've had a good look at using VBA, but i can't see anything that would appear to help.
Cheers
I am not sure if this is what you are looking for at all, but it will update the current styles to match what is in the styles manager. If you are looking for something other than this please give a little more detail on what you are importing the styles from etc. This is what I have as VB.NETcode
Public Sub Update_Styles() If ThisApplication.ActiveDocumentType = _ DocumentTypeEnum.kDrawingDocumentObject Then Dim oDwg As DrawingDocument = ThisApplication.ActiveDocument For Each oStyle As Style In oDwg.StylesManager.Styles If Not oStyle.UpToDate Then ' do not update what is up-to-date! oStyle.UpdateFromGlobal() ' udate the style End If Next End If End Sub
Mike,
Thanks for the suggestion, unfortunately it's not what I'm after, and I had to make some changes to get it to work on my system (shown below for reference of others).
Public Sub Update_Styles() If ThisApplication.ActiveDocumentType = _ DocumentTypeEnum.kDrawingDocumentObject Then Dim oDwg As DrawingDocument = ThisApplication.ActiveDocument For Each oStyle As Style In oDwg.StylesManager.Styles If Not oStyle.UpToDate Then ' do not update what is up-to-date! oStyle.UpdateFromGlobal() ' udate the style End If Next End If End Sub
What I'm trying to do is import from a .styxml file... see image below for description via piccy.
Hope this helps.
Thanks again for the assistance so far.
Regards
Gerrard
Gerrard
I could not help but notice that the styles library is read only in your project from the picture in your post, perhaps this is something that you want, but if you go to the project and change the "Use Styles Library" from read only to yes and then after you have finished add the style that you have imported to the library with the save button you will then be able to simplify the operation by either the code I provided or with the update button on the other file that need the same data added to them. This will also automatically add the styles to any new documents created.
Mike,
Thanks for pointing that out, but our stlye library is 'read only' for a reason. We have an office of 20+ designers each required to output drawings to strict company standards, allowing designers to make changes to the style library has in the past cost time and money in revising drawings to meet standards.
We're not having any troubles manually importing the .styxml file into a single .idw, and the action of importing automatically updates, so there's no problem there. The problem is importing it into several .idw files, that is hugely tedious.
Cheers
As far as I know importing styles from styxml files is not possible in the current API.