AutoCAD Architecture Customization

AutoCAD Architecture Customization

Reply
Contributor
jsebclark_SDG
Posts: 18
Registered: ‎10-12-2009
Message 1 of 10 (1,068 Views)

Copy ACA Styles with DotNet (.NET)

1068 Views, 9 Replies
04-26-2010 10:26 AM
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
Distinguished Contributor
ted.evans
Posts: 150
Registered: ‎11-05-2002
Message 2 of 10 (1,068 Views)

Re: Copy ACA Styles with DotNet (.NET)

04-26-2010 10:34 AM in reply to: jsebclark_SDG
This can be done through Style Manger, they are under Architectural Objects
Contributor
jsebclark_SDG
Posts: 18
Registered: ‎10-12-2009
Message 3 of 10 (1,068 Views)

Re: Copy ACA Styles with DotNet (.NET)

04-27-2010 10:19 AM in reply to: jsebclark_SDG
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
Contributor
jamie.michael.hill
Posts: 20
Registered: ‎01-26-2009
Message 4 of 10 (1,068 Views)

Re: Copy ACA Styles with DotNet (.NET)

04-27-2010 02:03 PM in reply to: jsebclark_SDG
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.
*Doug Broad
Message 5 of 10 (1,068 Views)

Re: Copy ACA Styles with DotNet (.NET)

04-27-2010 07:10 PM 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
Contributor
jsebclark_SDG
Posts: 18
Registered: ‎10-12-2009
Message 6 of 10 (1,068 Views)

Re: Copy ACA Styles with DotNet (.NET)

04-28-2010 08:30 AM in reply to: jsebclark_SDG
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
*Jeff
Message 7 of 10 (1,068 Views)

Re: Copy ACA Styles with DotNet (.NET)

04-29-2010 12:43 AM 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
Contributor
jsebclark_SDG
Posts: 18
Registered: ‎10-12-2009
Message 8 of 10 (1,068 Views)

Re: Copy ACA Styles with DotNet (.NET)

04-29-2010 10:23 AM in reply to: jsebclark_SDG
Thanks. That was exactly what I was looking for.
*Doug Broad
Message 9 of 10 (1,068 Views)

Re: Copy ACA Styles with DotNet (.NET)

04-30-2010 01:03 PM 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
Contributor
s.jabs
Posts: 12
Registered: ‎08-15-2007
Message 10 of 10 (1,068 Views)

Re: Copy ACA Styles with DotNet (.NET)

05-05-2010 08:53 AM 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.
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.