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

Performance issues #1

Open
nammenam opened this issue Oct 13, 2024 · 1 comment
Open

Performance issues #1

nammenam opened this issue Oct 13, 2024 · 1 comment

Comments

@nammenam
Copy link

Hey, great macro!
it works but it is very laggy for me, I gained some performance by converting to an approximate BSpline. I was thinking that others may also benefit from this. Here is the code I changed

    def run(self):
        # generate coordinates
        # thetaList = [j / self.steps * 2 * pi for j in range(self.steps + 1)]
        thetaList = [rescale_func(j / self.steps, 0.8) for j in range(self.steps + 1)]
        points = []
        # thetaList = [rescale_func(theta, 0.8) for theta in thetaList]
        xList = [epi.x(theta * 2 * pi) for theta in thetaList]
        yList = [epi.y(theta * 2 * pi) for theta in thetaList]
        # add lines to the sketch
        for j in range(self.steps):
            x1, x2 = xList[j:j+2]
            y1, y2 = yList[j:j+2]
            # self.sketch.addGeometry(Part.LineSegment(App.Vector(x1, y1, 0),
            #                             App.Vector(x2, y2, 0)), False)

            points.append(App.Vector(x1,y1,0))
        points.append(points[0]) # to close the loop
        bs = Part.BSplineCurve()
        bs.approximate(points)
        self.sketch.addGeometry(bs)
        # self.sketch.addConstraint(Sketcher.Constraint("Coincident", 0, 1, self.steps - 1, 2))
        self.doc.recompute()
@Widdi97
Copy link
Owner

Widdi97 commented Oct 19, 2024

Good point. I will add it as a kwarg. I also tried this once, but went back to using line segments because my CAM software (EstlCAM) had trouble reading DXF sketches with splines.

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