Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'MultiPolygon' object has no attribute 'exterior' #6

Open
schriftgestalt opened this issue Mar 11, 2020 · 6 comments
Open

Comments

@schriftgestalt
Copy link

I get this error when I run this script inside Glyphs (python 3.8)

from beziers.point import Point
from beziers.path import BezierPath
from beziers.cubicbezier import CubicBezier, Line


def loadPath(gPath):
	bSegs = []
	for gSeg in gPath.segments:
		if gSeg.countOfPoints() == 2:
			p0 = gSeg[0]
			p1 = gSeg[1]
			bSeg = Line(Point(p0.x, p0.y), Point(p1.x, p1.y))
		else:
			p0 = gSeg[0]
			p1 = gSeg[1]
			p2 = gSeg[2]
			p3 = gSeg[3]
			bSeg = CubicBezier(Point(p0.x, p0.y), Point(p1.x, p1.y), Point(p2.x, p2.y), Point(p3.x, p3.y))
		bSegs.append(bSeg)
	bPath = BezierPath.fromSegments(bSegs)
	bPath.closed = gPath.closed
	return bPath

brush = loadPath(Font.glyphs["_brush"].layers[0].shapes[0])
print(brush)
path = loadPath(Layer.shapes[0])
path.closed = False
path.addExtremes()
path.drawWithBrush(brush, 300, 3, 0.12)
print(path.activeRepresentation.segments)
@simoncozens
Copy link
Owner

I will take a look at this. By the way, you shouldn't need the loadPath function. You should be able to do:

path = BezierPath()
path.activeRepresentation = GSPathRepresentation(path, brush)

@simoncozens
Copy link
Owner

Could you just try increasing the pathSmoothness and brushSmoothness values in your path.drawWithBrush call? If that fixes it, I will try to make it work out the correct value automatically.

@schriftgestalt
Copy link
Author

I doubled all values and it took much longer but produced the same result.

@simoncozens
Copy link
Owner

OK. Can you give me a test case - simple brush and path that causes it?

@schriftgestalt
Copy link
Author

DrawBrushTest.glyphs.zip

from beziers.point import Point
from beziers.path import BezierPath
from beziers.cubicbezier import CubicBezier, Line


def loadPath(gPath):
	bSegs = []
	for gSeg in gPath.segments:
		if gSeg.countOfPoints() == 2:
			p0 = gSeg[0]
			p1 = gSeg[1]
			bSeg = Line(Point(p0.x, p0.y), Point(p1.x, p1.y))
		else:
			p0 = gSeg[0]
			p1 = gSeg[1]
			p2 = gSeg[2]
			p3 = gSeg[3]
			bSeg = CubicBezier(Point(p0.x, p0.y), Point(p1.x, p1.y), Point(p2.x, p2.y), Point(p3.x, p3.y))
		bSegs.append(bSeg)
	bPath = BezierPath.fromSegments(bSegs)
	bPath.closed = gPath.closed
	return bPath

brush = loadPath(Font.glyphs["_brush"].layers[0].shapes[0])
print(brush)
path = loadPath(Layer.shapes[0])
path.closed = False
path.addExtremes()
path.drawWithBrush(brush, 300, 3, 0.12)
print(path.activeRepresentation.segments)

@schriftgestalt
Copy link
Author

Open the "A" in and run the script from the macro window.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants