• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    .NET

    Reply
    Contributor
    Posts: 22
    Registered: ‎11-13-2006

    Copy Displayset

    57 Views, 0 Replies
    05-23-2012 02:23 PM

    We're trying to copy the Displayset but having trouble. Has anyone been able to get this to work?  Here's a snippet of one attempt:

     

        Public Shared Sub CopyMEPDisplaySet2(ByVal FileDB As Database, ByVal SourceDB As Database)
            Using acTrans As Transaction = FileDB.TransactionManager.StartTransaction()
                Dim dds1 As New Autodesk.Aec.DatabaseServices.DictionaryDisplaySet(FileDB, True)
                Dim dds2 As New Autodesk.Aec.DatabaseServices.DictionaryDisplaySet(SourceDB, True)
                For Each OID As ObjectId In dds1.Records
                    Dim ds As Autodesk.Aec.DatabaseServices.DisplaySet = TryCast(acTrans.GetObject(OID, OpenMode.ForRead, True, True), Autodesk.Aec.DatabaseServices.DisplaySet)
                    If ds IsNot Nothing Then
                        Dim dssID As ObjectId = dds2.GetAt(ds.Name)
                        If dssID.IsNull = False Then
                            Dim dss As Autodesk.Aec.DatabaseServices.DisplaySet = TryCast(dssID.GetObject(OpenMode.ForRead, True, True), Autodesk.Aec.DatabaseServices.DisplaySet)
                            ds.UpgradeOpen()
                            ds.CopyFrom(dss)
                            ds.DowngradeOpen()
                        End If
                    End If
                Next
    
                acTrans.Commit()
            End Using
        End Sub

     This fails to successfully copy.  Here's a couple other attempts:

     

        Public Shared Sub CopyMEPDisplaySet1(ByVal FileDB As Database, ByVal SourceDB As Database)
            Using acTrans As Transaction = FileDB.TransactionManager.StartTransaction()
                Dim dds1 As New Autodesk.Aec.DatabaseServices.DictionaryDisplaySet(FileDB, True)
                Dim dds2 As New Autodesk.Aec.DatabaseServices.DictionaryDisplaySet(SourceDB, True)
    
                dds1.CopyFrom(dds2)
    
                acTrans.Commit()
            End Using
        End Sub
    
    
        Public Shared Sub CopyMEPDisplaySet3(ByVal FileDB As Database, ByVal SourceDB As Database)
            Dim objColIDS As New ObjectIdCollection()
            Using acTrans As Transaction = FileDB.TransactionManager.StartTransaction()
                Dim dds1 As New Autodesk.Aec.DatabaseServices.DictionaryDisplaySet(FileDB, True)
                Dim dds2 As New Autodesk.Aec.DatabaseServices.DictionaryDisplaySet(SourceDB, True)
                For Each OID As ObjectId In dds2.Records
                    objColIDS.Add(OID)
                Next
    
                Dim helpme As New Autodesk.Aec.ApplicationServices.Utility.CloningHelper
                '  uncomment one of these if you want to have a behavior other than default (i.e., overwrite). 
                'helpme.MergeType = Autodesk.Aec.OmfSamples.DictionaryRecordMergeBehavior.Unique; // rename 
                helpme.MergeType = Autodesk.Aec.ApplicationServices.Utility.DictionaryRecordMergeBehavior.Overwrite
                ' no overrite + add overlapping ones as anonymous name (probably internal use only.)  
                'helpme.MergeType = Autodesk.Aec.OmfSamples.DictionaryRecordMergeBehavior.Normal; // no overrite.  
                '  finally call clone. 
                helpme.UseTransactions = True
                helpme.IncludeDefaultDisplaySystem = True
                helpme.OverwriteDependentAutoCADObjects = True
    
                helpme.Clone(SourceDB, FileDB, objColIDS, dds1.GetRXClass, True)
    
                acTrans.Commit()
            End Using
        End Sub

     

    Craig

     

    Please use plain text.