Combine Polygons - Not working?

Previous topic - Next topic

Zinal

Hello!

I'm having a bit of problem creating a script that can create a can create gradient text from a TextFrame. I know how to do it manually, but for some reason it doesn't work through a script.

Manual steps:
1. Right-click on the text-frame and choosing "Convert to" -> "Outlines".
2. Right-click the new group and choose "Ungroup".
3. Choose "Item" -> "Path Tools" -> "Combine Polygons" from the top menu.
The above steps allows me to apply a gradient fill on the whole text-frame.

I'm in the process of creating a simple script to automate these steps, but I'm running into a problem with the combinePolygons() method.

Here is the entire script:
import scribus

def makeOutlined():
    items = scribus.getPageItems()
    itemsBefore = []
    for item in items:
        itemsBefore.append(item[0])
    scribus.outlineText()
    for item in scribus.getPageItems():
        if not item[0] in itemsBefore:
            return item[0]
    return None

def ungroup(name):
    items = scribus.getPageItems()
    itemsBefore = []
    for item in items:
        itemsBefore.append(item[0])
    scribus.unGroupObjects(name)
    groupedItems = []
    for item in scribus.getPageItems():
        if not item[0] in itemsBefore:
            groupedItems.append(item[0])
    return groupedItems

def combine(items):
    items2 = scribus.getPageItems()
    itemsBefore = []
    for item in items2:
        itemsBefore.append(item[0])
    scribus.deselectAll()
    for name in items:
        scribus.selectObject(name)
    scribus.combinePolygons()
    for item in scribus.getPageItems():
        if not item[0] in itemsBefore:
            return item[0]
    return None

outlinedItem = makeOutlined()
items = ungroup(outlinedItem)
grouped = combine(items)

The error I'm getting is this:
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "<console>", line 9, in combine
scribus.WrongFrameTypeError: Selection must contain only shapes or bezier curves.

I've verified that the selection only contains the ungrouped shapes (Polygons)..

Is combinePolygons() bugged?

a.l.e

yes, from my testing, combinePolygons() seems indeed not to work correctly:

- create a simple text frame
- convert to outlines
- ungroup
- in the script console run "scribus.combinePolygons()": i get the same error as you
- trigger the path tools' "combine polygons": it works.

would you mind opening a ticket in https://bugs.scribus.net?

Zinal

I opened a ticket. Also managed to track down why the error occurred!
Should be a quick fix since it's only an if statement that is wrong.