Hello,
I have made a routine to WblockClone PropertySets between drawings...
When i use the routine i am getting a "Exception: eInvalidInput" on the commandline and the PropertySet is Not Cloned to the drawing.
What is wrong here?
Sub WblockPropsets(ByVal SourceDrawing As String, ByVal PropsetName As String)
' Connect to Current Drawing
Dim MyDWG As Autodesk.AutoCAD.ApplicationServices.Document = _ Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim MyDB As Autodesk.AutoCAD.DatabaseServices.Database = MyDWG.Database
Dim MyTransMan As Autodesk.AutoCAD.DatabaseServices.TransactionManager = MyDWG.TransactionManager
' Connect to Source Drawing
Using SrcDB As Autodesk.AutoCAD.DatabaseServices.Database = New Autodesk.AutoCAD.DatabaseServices.Database(False, True)
' Read Source Drawing
SrcDB.ReadDwgFile(SourceDrawing, IO.FileShare.ReadWrite, True, "")
' Start Transactions
Dim SrcTransMan As Autodesk.AutoCAD.DatabaseServices.TransactionManager = SrcDB.TransactionManager
Using SrcTrans As Autodesk.AutoCAD.DatabaseServices.Transaction = SrcTransMan.StartTransaction,
MyTrans As Autodesk.AutoCAD.DatabaseServices.Transaction = MyTransMan.StartTransaction
' Open de source PropSet Dictionary...
Dim SrcPropsetDict As New DictionaryPropertySetDefinitions(SrcDB)
' Open de destination PropSet Dictionary and get de Dictionary ID...
Dim DestPropsetDict As New DictionaryPropertySetDefinitions(MyDB)
Dim DestPropsetDictID = DestPropsetDict.DictionaryId
Dim MyPropSetColl As New Autodesk.AutoCAD.DatabaseServices.ObjectIdCollection ' Colection that Stores the Entities ID
' Get the collection of MvBlocks...
' Loop entities in Source Dictionary
For Each ObjID In SrcPropsetDict.Records
Dim PropSet As PropertySetDefinition = SrcTrans.GetObject(ObjID, OpenMode.ForRead)
If PropSet.Name = PropsetName Then
MyPropSetColl.Add(ObjID)
End If
Next
' WblockClone the Source Entitys
Dim myMap As New Autodesk.AutoCAD.DatabaseServices.IdMapping
MyDB.WblockCloneObjects(MyPropSetColl, DestPropsetDictID, myMap, Autodesk.AutoCAD.DatabaseServices.DuplicateRecordCloning.Replace, False)
' Commit, Close and Dispose Transactions
MyTrans.Commit()
SrcTrans.Commit()
End Using
End Using
End Sub