AutoCAD Architecture Customization
Welcome to Autodesk’s AutoCAD Architecture Customization Forums. Share your knowledge, ask questions, and explore popular AutoCAD Architecture Customization topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Copy ACA Styles with DotNet (.NET)

9 REPLIES 9
Reply
Message 1 of 10
jsebclark_SDG
1509 Views, 9 Replies

Copy ACA Styles with DotNet (.NET)

I was wondering what the best way to copy ACA styles from one drawing to another drawing is using DotNet (.NET). I am very familiar with VB.Net but any solution would be helpful. I just want to be able to copy a cleanup group style out of one drawing and put it into another drawing.

Thanks,

Jonathan
9 REPLIES 9
Message 2 of 10
ted.evans
in reply to: jsebclark_SDG

This can be done through Style Manger, they are under Architectural Objects
Message 3 of 10

Thank you for your response.

What I am trying to do is automate the importing of specific styles from a designated standard style. I know how to do this manually by using the style manager. I was wondering if there is a way to do this programmatically so that I could create a command that would import the correct styles automatically and I wouldn't need to use the style manager.

Thanks,

Jonathan
Message 4 of 10

Hello Jonathan-

Let's start off, by my saying that I've written a total of "0" lines of VB.NET code. However, I've started doing the homework, to do so. I can tell you that you are going to have to dig into the API structure, but try AecArchMgd.dll as a start.
Message 5 of 10
Anonymous
in reply to: jsebclark_SDG

Isn't that what project standards are supposed to accomplish?

wrote in message news:6381380@discussion.autodesk.com...
Thank you for your response.

What I am trying to do is automate the importing of specific styles from a
designated standard style. I know how to do this manually by using the
style manager. I was wondering if there is a way to do this
programmatically so that I could create a command that would import the
correct styles automatically and I wouldn't need to use the style manager.

Thanks,

Jonathan
Message 6 of 10

Isn't that what project standards are supposed to accomplish?



That's what I thought too, but that isn't the case. Project standards just make sure that if you have an existing style in a project drawing that it is current with the same style in the project standards. Thus if I have 6 Walls styles in the project standards and only 2 styles in the project drawing, project standards only checks updates the two styles that exist in the project drawing and doesn't import any styles that exist in the project standards but not in the project drawing.



So, in short, project standards doesn't accomplish what I am trying to do. They do work for making sure that existing styles are current. This is how project standards was designed to function and I believe that it was designed correctly. Edited by: jsebclark_SDG on Apr 28, 2010 8:30 AM
Message 7 of 10
Anonymous
in reply to: jsebclark_SDG

Try CloningHelper Class in the assembly "AecUiBaseMgd.dll".
It can be used to copy AecDbObject from external DWG to the current
Database.

дÈëÏûÏ¢ÐÂÎÅ:6380564@discussion.autodesk.com...
I was wondering what the best way to copy ACA styles from one drawing to
another drawing is using DotNet (.NET). I am very familiar with VB.Net but
any solution would be helpful. I just want to be able to copy a cleanup
group style out of one drawing and put it into another drawing.

Thanks,

Jonathan
Message 8 of 10

Thanks. That was exactly what I was looking for.
Message 9 of 10
Anonymous
in reply to: jsebclark_SDG

Aren't you using project tool palettes? As soon as you create a new wall
style, you make the project wall style available by putting it on a project
tool palette, not by programming the disbursement of wall styles. Then if a
level needs it, you pick it from the project tool palette.


wrote in message news:6382076@discussion.autodesk.com...
Isn't that what project standards are supposed to accomplish?

That's what I thought too, but that isn't the case. Project standards just
make sure that if you have an existing style in a project drawing that it is
current with the same style in the project standards. Thus if I have 6 Walls
styles in the project standards and only 2 styles in the project drawing,
project standards only checks updates the two styles that exist in the
project drawing and doesn't import any styles that exist in the project
standards but not in the project drawing.

So, in short, project standards doesn't accomplish what I am trying to do.
They do work for making sure that existing styles are current. This is how
project standards was designed to function and I believe that it was
designed correctly. Edited by: jsebclark_SDG on Apr 28, 2010 8:30 AM
Message 10 of 10
s.jabs
in reply to: jsebclark_SDG

Here's some code I found useful to copy Layer Standards, Property Set Definitions, or Display Properties that should be applicable to your needs (it works with anything that can be contained in a Dictionary object):

{code}
' copies the specified dictionary from the source document into the destination document
' overwrites any existing values it finds in the destination document
Protected Friend Shared Function CloneDictionary(ByVal dbAcad As Database, ByVal strSource As String, ByVal strDictionary As String, Optional ByVal strItem As String = Nothing, Optional ByVal blnIncludeDefaults As Boolean = False) As Boolean
Dim blnReturn As Boolean
Dim dbSource As Database = New Database(False, True)
Dim edCmdLine As Editor = AcApp.Application.DocumentManager.MdiActiveDocument.Editor

If Not File.Exists(strSource) Then
edCmdLine.WriteMessage(vbLf & "Cannot find Dictionary """ & strDictionary & """ at " & strSource)
Return False
End If

' check if the source drawing is the same as the destination drawing
If String.Compare(strSource, dbAcad.Filename, True) = 0 Then
Return False
End If

Try
' read the source drawing in as a "side" database
dbSource.ReadDwgFile(strSource, FileShare.Read, True, "")

Dim oicSource As ObjectIdCollection = New ObjectIdCollection()
Dim rxcItem As RXClass = Nothing

Using trSource As Transaction = dbSource.TransactionManager.StartTransaction()
Dim dicNOD As DBDictionary = DirectCast(trSource.GetObject(dbSource.NamedObjectsDictionaryId, OpenMode.ForRead, False, False), DBDictionary)
Dim dicSource As DBDictionary = DirectCast(trSource.GetObject(dicNOD.GetAt(strDictionary), OpenMode.ForRead, False, False), DBDictionary)
Dim deItem As DBDictionaryEntry

For Each deItem In dicSource
' if no dictionary entry is specified, load them all
If String.IsNullOrEmpty(strItem) Then
oicSource.Add(deItem.Value)
Else ' if a dictionary entry is specified, only load the specified entry
If deItem.Key = strItem Then
oicSource.Add(deItem.Value)
End If
End If
Next

' if any items have been added to the collection, get the RXClass and clone the items
If oicSource.Count > 0 Then
Dim objItem As DBObject = trSource.GetObject(oicSource.Item(0), OpenMode.ForRead)

' get a valid RXClass
rxcItem = objItem.GetRXClass()

Dim clhAcad As CloningHelper = New CloningHelper()
clhAcad.MergeType = DictionaryRecordMergeBehavior.Overwrite
clhAcad.UseTransactions = False
clhAcad.OverwriteDependentAutoCADObjects = True
clhAcad.IncludeDefaultDisplaySystem = blnIncludeDefaults

' make sure the Id's are from individual items (and not the Id of the dictionary itself)
' all entries should be of the same RXClass type, which is typically true for an AEC dictionary
clhAcad.Clone(dbSource, dbAcad, oicSource, rxcItem, True)
blnReturn = True
Else
blnReturn = False
End If

trSource.Commit()
End Using

Catch ex As Exception
blnReturn = False
Finally
If Not dbSource Is Nothing AndAlso Not dbSource.IsDisposed Then
dbSource.Dispose()
End If
End Try

Return blnReturn
End Function
{code}

A sample implementation would be:
{code}
' imports specified layer key standard from specified file into current database
Protected Friend Shared Function LoadLayerStandard(ByVal dbAcad As Database) As Boolean
Dim blnReturn As Boolean
Dim strLayerKeyStandard As String = "AIA (256 Color)"
Dim strLayerKeyStandardFile As String = "X:\Support\ACD-A 2011\Layers\AecLayerStd.dwg"

blnReturn = CloneDictionary(dbAcad, strLayerKeyStandardFile, "AEC_LAYERKEY_STYLES")

Using trAcad As Transaction = dbAcad.TransactionManager.StartTransaction()
Dim dicLayerKey As DictionaryLayerKeyStyle = New DictionaryLayerKeyStyle(dbAcad)
Dim dsvAcad As DrawingSetupVariables

dsvAcad = DirectCast(trAcad.GetObject(DrawingSetupVariables.GetInstance(dbAcad, True), OpenMode.ForWrite), DrawingSetupVariables)
dsvAcad.AlwaysUpdateLayerKeyStyle = True
dsvAcad.LayerFile = strLayerKeyStandardFile
dsvAcad.LayerStandard = strLayerKeyStandard
dsvAcad.SaveAsDefault()

trAcad.Commit()
End Using

Return blnReturn
End Function
{code}

I found, in the case of the LayerKeyStandard, that you need to programatically set a Layer Key Override then reset it in order to copy all the override values.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost