Subscribe to this thread
Home - General / All posts - script failing at dwg.Paste
philw
101 post(s)
#25-Jun-18 06:42

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?

tjhb
10,094 post(s)
#25-Jun-18 06:56

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.)

adamw


10,447 post(s)
#25-Jun-18 15:30

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).

adamw


10,447 post(s)
#25-Jun-18 15:34

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

Manifold User Community Use Agreement Copyright (C) 2007-2021 Manifold Software Limited. All rights reserved.