Subscribe to this thread
Home - General / All posts - script failing at dwg.Paste
philw
96 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

8,410 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


8,259 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


8,259 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-2017 Manifold Software Limited. All rights reserved.