Home -
General /
All posts - script failing at dwg.Paste
philw101 post(s) |
I have tried two different scripts to combine multiple drawings into a single drawing and both fail at the line where the drawing data is pasted into the merged/combined drawing (i.e. the "dwg.Paste" line below): For Each cmp In Comps If cmp.Type = ComponentDrawing And cmp.Name <> dwg.Name Then cmp.Copy dwg.Paste End If The error just states the line number and no other details. Any ideas?
|
|
Focus on the first line. Subsequent lines undermine it. The ComponentSet which the loop depends on is changed within the loop (by Paste). Can’t do that! (By the way, if you could do that, it would be chaos. Possibly an infinite loop, possibly worse.)
|
|
Pasting into an existing component does not change the component set of the document. It is pasting into the document that does (by creating new components).
|
|
It's probably something related to the data. The code fragment looks fine and a model script on model data seems to work fine as well, see attached. I'd Application.MessageBox the name of the drawing you copy from just before doing copy / paste, then see which specific drawing fails to copy / paste, then try repeating the copy / paste from that drawing using the UI. Attachments: copy-paste-merge-8.map
|