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

Line thickness doesn't seem to work #3

Open
baxelrod-bdai opened this issue Sep 2, 2012 · 0 comments
Open

Line thickness doesn't seem to work #3

baxelrod-bdai opened this issue Sep 2, 2012 · 0 comments

Comments

@baxelrod-bdai
Copy link

I would like to draw lines with some thickness so that i can raster them with a laser cutter. I tried two things:

d.append(sdxf.Line(points=[(1,0,0),(1,1,0)], thickness=0.5))
d.append(sdxf.Line(points=[(2,0,0),(2,1,0)], lineWeight=0.5))

Both displayed as standard thin lines in my dxf viewer. So i wrote an "extras" class that simply draws a rectangular solid for the line:

class ThickLine(Solid):
    """Use a 'Solid' to make a thick line"""
    def __init__(self, points, width, **common):
        _Entity.__init__(self, **common)
        dx = float(points[1][0]-points[0][0])
        dy = float(points[1][1]-points[0][1])
        L = math.sqrt(dx*dx + dy*dy)
        a = (points[0][0] - dy * (width / 2.0) / L, points[0][1] + dx * (width / 2.0) / L)
        b = (points[1][0] - dy * (width / 2.0) / L, points[1][1] + dx * (width / 2.0) / L)
        c = (points[1][0] + dy * (width / 2.0) / L, points[1][1] - dx * (width / 2.0) / L)
        d = (points[0][0] + dy * (width / 2.0) / L, points[0][1] - dx * (width / 2.0) / L)
        self.points = [a, b, c, d]

And here is some test code:

d.append(sdxf.ThickLine(points=[(0,1,0),(3,3,0)], width=0.25, color=1))
d.append(sdxf.ThickLine(points=[(1,1,0),(2,1,0)], width=0.1, color=2))
d.append(sdxf.ThickLine(points=[(0,3,0),(0,3.5,0)], width=2, color=3))
d.append(sdxf.ThickLine(points=[(0.5,0.5,0),(0.25,0,0)], width=0.15, color=4))
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

1 participant