Generate Complicated Sketch Profile Faster

Generate Complicated Sketch Profile Faster

Joshua.mursic
Advocate Advocate
453 Views
3 Replies
Message 1 of 4

Generate Complicated Sketch Profile Faster

Joshua.mursic
Advocate
Advocate

Hey everyone, I have a collection of points that are very densely packed and define an organic profile. I import them in an build the profile using this method.

sketch.arePointsShown = False
sketch.areProfilesShown = False
sketch.isComputeDeferred = True
sketch.sketchCurves.sketchFittedSplines.add(pointArray)
sketch.isComputeDeferred = False

You can see the results below. (This is a 3D sketch)

Joshuamursic_0-1682098143008.png

 

This works great and all, but understandably, this take a while for fusion to build. I am wondering if anyone out there has any creative method to increase the import speed by either reducing the point density like checking if points are close to colinear or since the points are so close together, would drawing straight lines between them be a lot faster?

 

0 Likes
Accepted solutions (2)
454 Views
3 Replies
Replies (3)
Message 2 of 4

BrianEkins
Mentor
Mentor
Accepted solution

Besides simplifying your data, I don't know of anything to make it faster. I think creating lines will not be any faster, and the result will be unwieldy too. There aren't any tools in the Fusion API to help in the simplification. I wish there was a command to fit a spline to given tolerance, but there isn't. You could do something simple and use every other or every third point and see how that helps.

 

You can write some code yourself that steps through the points, checking the angle each point makes with the previous two, and removing points that are close to colinear.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 3 of 4

kandennti
Mentor
Mentor
Accepted solution

Hi @Joshua.mursic .

 

I have previously used a module called NURBS-Python (geomdl) to draw NurbsCurve3D on a sketch.

https://github.com/orbingol/NURBS-Python 

As I recall, it is not dependent on any other module.


In this example, it is 2D, but it was possible to create a 3D NurbsCurve based on the passing coordinate values.

https://nurbs-python.readthedocs.io/en/5.x/fitting.html#approximation 


This is how I used it.

from geomdl import fitting

・・・
        ary = [(p.x, p.y, p.z) for p in points]

        crv = fitting.interpolate_curve(ary, 3)

        pnt3D: adsk.core.Point3D = adsk.core.Point3D
        controlPoints = [pnt3D.create(c[0], c[1], c[2]) for c in crv.ctrlpts]
        degree = crv.degree
        knots = crv.knotvector
        isPeriodic = crv.rational

        return adsk.core.NurbsCurve3D.createNonRational(
            controlPoints,
            degree,
            knots, 
            isPeriodic
        )
・・・

"Points" is a list of adsk.core.Point3D and "crv" is a 3D B-Spline Curve from geomdl.


I did not try it, but the delta method here may lighten the splines.

https://nurbs-python.readthedocs.io/en/5.x/module_bspline.html#geomdl.BSpline.Curve.delta 


I don't know if using this will save time, but it might be worth a try.

0 Likes
Message 4 of 4

Joshua.mursic
Advocate
Advocate

Thank you for all the suggestions everyone. Ill ty them out and see if I can improve the results

0 Likes