Author Topic: WBlockCloneObjects() on polylines from an XREF?  (Read 1665 times)

0 Members and 1 Guest are viewing this topic.

Steve Hill

  • Mosquito
  • Posts: 5
WBlockCloneObjects() on polylines from an XREF?
« on: July 23, 2020, 09:05:11 PM »
Has anyone had success in using WBlockCloneObjects() on polylines from an XREF?

Essentially I am copying polylines from an XREF and using WBlockCloneObjects() to place in the host database. This works fine. However, if I then manually explode the polylines, all of the subentities disappear.

If I try to programmatically explode the polylines I get eWrongDatabase.

What am I doing wrong?

I'm basically using the code from the Autodesk link below, just on polyline object.

http://docs.autodesk.com/ACD/2011/ESP/filesMDG/WS1a9193826455f5ff2566ffd511ff6f8c7ca-3f78.htm

I'm using the PromptForNestedEntity which returns properly, then pass into this as newCloneColl

Code: [Select]
Using docLock As DocumentLock = destDoc.LockDocument
                Using tr As Transaction = destDb.TransactionManager.StartTransaction()
                    Try
                        tr.TransactionManager.QueueForGraphicsFlush()
                        destDb.WblockCloneObjects(newCloneColl, destDb.CurrentSpaceId, idMap, DuplicateRecordCloning.Ignore, False)

                        tr.Commit()
                    Catch ex As System.Exception
                        destEd.WriteMessage(vbLf & "Error during NCOPY: " & ex.Message)
                    End Try
                End Using
            End Using


Again, this works fine until you explode the polyline object.


 

Steve Hill

  • Mosquito
  • Posts: 5
Re: WBlockCloneObjects() on polylines from an XREF?
« Reply #1 on: July 24, 2020, 10:21:57 AM »
No takers? Really need some help on this one... not sure what I'm doing wrong.

Posted more code here on forum post.

https://forums.autodesk.com/t5/net/wblockcloneobjects-on-polylines-works-until-polylines-are/m-p/9651862/highlight/false#M66365

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: WBlockCloneObjects() on polylines from an XREF?
« Reply #2 on: July 24, 2020, 04:25:35 PM »
The polylines are being cloned with the Xref layer name. Since a database resident object cannot be on an Xref layer it gets removed when exploding. An Audit places the pline on the Audit_Bad_Layer and then it can be exploded. The key is to set the layer for the cloned object t a valid layer.

Steve Hill

  • Mosquito
  • Posts: 5
Re: WBlockCloneObjects() on polylines from an XREF?
« Reply #3 on: July 24, 2020, 04:56:22 PM »
Thanks Jeff!

Brilliant. Did not occur to me why that was happening. I find it bizarre as Lines and Arcs, no issue. Polylines worked fine until exploded, or the XREF was detached. Man, thanks a ton! :beer:

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: WBlockCloneObjects() on polylines from an XREF?
« Reply #4 on: July 24, 2020, 05:09:36 PM »
Steve, note that all objects cloned from an Xref would have the same issue. The Layer needs to be set to a current DB layer, else you will get the eWrongDataBase during an Audit and the layer will be changed to the Audit_Bad_Layer. You only noticed when exploding the polyline because AutoCAD caught the issue.