
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
When I use the following code to clone dynamic blocks to a different drawing database, the blocks in the destination drawing are either invisible or their geometry is black where the color is set by layer (block geometry with explicit color assigned is drawn correctly). I've confirmed that the layers the source blocks are assigned to in the source drawing exist and have the same color in the destination drawing prior to cloning.
Here is the code responsible for cloning the blocks:
Using maps As New IdMapping() Dim cloned As Boolean = False Dim clones As New ObjectIdCollection() Using lock As DocumentLock = destDocument.LockDocument() Using srcTran As Transaction = sourceDocument.TransactionManager.StartTransaction() Using destTran As Transaction = destDocument.TransactionManager.StartTransaction() Try sourceDocument.Database.WblockCloneObjects(sourceObjs, destDocument.Database.CurrentSpaceId, maps, DuplicateRecordCloning.Replace, False) For Each clId As IdPair In maps If clId.IsPrimary AndAlso clId.IsCloned Then clones.Add(clId.Value) Next destTran.Commit() cloned = True Catch ex As System.Exception destTran.Abort() cloned = False End Try End Using End Using End Using
Here is the result in the destination drawing:
Here is what the blocks should look like:
The color is defined in the layer these blocks are assigned to. If I save the drawing containing the cloned blocks, close it, then open it, the color is correct. Also, sometimes the blocks in the destination drawing are completely invisible until I select them, then they have the same black geometry issue after selection.
I've tried regen and UpdateScreen to no effect. However, if I use the LAYER command and freeze/unfreeze the layers these blocks are assigned to, their color is rendered correctly after. I'm sorry if my terminology is off; I do not use AutoCAD, I've just been developing plugins.
Thanks in advance for any advice,
Kevin
Solved! Go to Solution.