How to replace all frames in a page with another one

Previous topic - Next topic

Pumpkin

I used scribus to make some figures composed of smaller ones like this:

SSSSSSSSSSSSSS
S
S
S
SSSSSSSSSSSSS
S
S
S
SSSSSSSSSSSSSS

The only difference is instead of letter S, I used small figures I drew with curves. Now I'd like to replace them all with another figure. In other words, I'd like to compose the bit letter E with a new figure but at the exact same locations. Is there anyway to do it quickly rather than manually compare the locate them?
Thank you!

Nermander

It sounds as if the way you did it there is no easy way to do this.

I would maybe have tried to use pattern fill or maybe text on a path, but that means you should have done it from the start.

a.l.e

you can probably do that with a simple script.

if you want to really replace the drawings (and not create a second figure with a different drawing) you can use symbols (symbols are scrapbook elements that are linked to the original item)

a.l.e

this script does what you want:

- copy the new item
- select all the old items
- run the script

items = []
for i in range(n):
    items.append(scribus.getSelectedObject(i))

for item in items:
    pos = scribus.getPosition(item)
    dx, dy = pos
    scribus.pasteObject()
    new_item = scribus.getSelectedObject()
    pos = scribus.getPosition(new_item)
    dx, dy = dx - pos[0], dy - pos[1]
    scribus.moveObject(dx, dy, new_item)
    scribus.deleteObject(item)


here is a downloadable version of a full script:

https://raw.githubusercontent.com/aoloe/scribus-script-collection/master/replace-all-selected-items.py/replace-all-selected-items.py

Pumpkin

Thank you so much! I'm new to Scribus and have never thought of using scripts to do anything. I need to take a look at how to use it but thank you so much for the script!

Pumpkin

Quote from: a.l.e on September 14, 2020, 10:39:11 AM
this script does what you want:

- copy the new item
- select all the old items
- run the script

items = []
for i in range(n):
    items.append(scribus.getSelectedObject(i))

for item in items:
    pos = scribus.getPosition(item)
    dx, dy = pos
    scribus.pasteObject()
    new_item = scribus.getSelectedObject()
    pos = scribus.getPosition(new_item)
    dx, dy = dx - pos[0], dy - pos[1]
    scribus.moveObject(dx, dy, new_item)
    scribus.deleteObject(item)


here is a downloadable version of a full script:

https://raw.githubusercontent.com/aoloe/scribus-script-collection/master/replace-all-selected-items.py/replace-all-selected-items.py




Hi a.l.e, I tried run the script the way you said, and there is an error message said 'module' object has no attribute 'pastObject'. Do you have any idea what could be the reason?
Thank you!

a.l.e

yes, you probably need scribus 1.5.5 or 1.5.6svn for pasteObject().

1.5 versions are mostly compatible with each other.

but you cannot edit with scribus 1.4 documents that you have modified with scribus 1.5...

Pumpkin

Quote from: a.l.e on September 14, 2020, 05:48:58 PM
yes, you probably need scribus 1.5.5 or 1.5.6svn for pasteObject().

1.5 versions are mostly compatible with each other.

but you cannot edit with scribus 1.4 documents that you have modified with scribus 1.5...



It worked perfectly! Thank you so much!!!