Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. Be respectful, on topic and if you see a problem, Flag it.

If you would like to contact our Community Manager personally, feel free to send a private message or an email.

Any plans to expose bSplineSurface and bSplineCurve from evSurfaceDefinition and evCurveDefinition?

Jacob_CorderJacob_Corder Member Posts: 126 PRO
I am wondering if there are plans to expose the geometry data of non primitives to us. I really need the bSplineCurve definition and bSplineCurve definitions from evSurfaceDefinition and evCurveDefinition.
Returning {surfaceType : OTHER} is not really all that helpful. 


Best Answers

Answers

  • Jacob_CorderJacob_Corder Member Posts: 126 PRO
    @ilya_baran
    good to know.  so,  in the next year? earlier? later?
  • Jacob_CorderJacob_Corder Member Posts: 126 PRO
    @ilya_baran Really?????   You can not believe how excited I am right now.  I hope it's not a teaser. I am going to bSpline everything!!!!! :) 
     
  • S1monS1mon Member Posts: 2,321 PRO
    NIce!


    FEATURESCRIPT EVALUATION IMPROVEMENTS

    In this release, evSurfaceDefinition and evCurveDefinition now return b-spline surfaces and curves respectively. There is also a new function named evApproximateBSplineCurve that will approximate any curve as a b-spline. Both of these updates give you more flexibility in capturing existing geometry for use in Custom Features.
  • Jacob_CorderJacob_Corder Member Posts: 126 PRO
    edited February 2022
    I can confirm that the onshape return from evCurveDefinition does in fact return an exact bSplineCurve. I wrote a  featurescript to import step file text and create b spline curves from it. the results from evCurveDefinition are 100% exactly the same. This is a huge improvement to the environment. Onshape you are awesome!!!

    Thank you so much for your constant updates and upgrades. This allows us developers to do anything that we can possibly want without contaminating surfaces and curves with over approximation which leads to faster models and faster downstream operations. 


    Also. the time to get the definition is less than 1 ms which is AMAZING for the b splines I tested. 

    I have not yet tested evApproximateBSplineCurve yet 
  • S1monS1mon Member Posts: 2,321 PRO
    @ilya_baran
    I'm playing with evCurveDefinition using my own simple custom FeatureScript, and I don't understand why I'm getting a response of "curveType" : "OTHER" from many of the edges. 

    1. Edge of Loft (from a 2D sketch using sketcher splines) = "SPLINE"
    2. Edge of Freeform spline ( @Evan_Reese ) = "SPLINE"
    3. Edge of Loft (the edge created by a guide curve from the above Freeform spline) = "OTHER"
    4. Edge of Fillet (created by filleting the lofted part) = "OTHER"
    5. Face curve ( again, @Evan_Reese ) = "SPLINE"
    6. Bridging curve = "SPLINE"

    What I can get to work is:

            if (c["curveType"] != "SPLINE")
            {
                c = evApproximateBSplineCurve(context, {
                            "edge" : definition.curve,
                            "tolerance" : definition.tolerance
                        });
            }

    What I'm starting to guess is that "OTHER" is NURBS not b-spline, because I'm seeing either weights (in the case of converting an arc) or non-rational knot values. I still don't understand why case #3 isn't just a Bézier.

    It would be really nice if evApproximateBSplineCurve had an option for forceBezier.

  • Jacob_CorderJacob_Corder Member Posts: 126 PRO
    edited February 2022
    @S1mon
    Force bezier would not likely work as the degree would rise above onshapes max degree which is think is 17, but i cant remember. Which means the number of points cannot exceed 18 (i think)

    the return from evCurveDefinition may return a line, circle or any other primitive shapes also so check for those. you might be working with a circle.
    Are you setting evCurveDefinition returnBSplinesAsOther to true? If so, set it to false.

    I have been able to extract basically everything i have tested so far. Most of the stuff i am extracting are wire body edges or intersection curves between faces created by opBoolean or opSplitFace.

    Be careful of the approximator. I have had returns of 800 control points for a 60mm spline. 
  • Jacob_CorderJacob_Corder Member Posts: 126 PRO
    edited February 2022
    @S1mon

    You are getting a "spline" from a briding curve??  a Bridging Curve is literally a b spline curve. it is however a bezier curve with the knots being auto created but still, that makes no sense.
    3D fit splines with start and end magnitude are exactly cubic b splines where the start and end derivative are the first and 2nd control points. but those derivatives are calculated on the server. The Arrows of the fit spline feature, at the base, is actually the first control point of the created b spline curve so fitsplines should always return a bspline curve with control point count of vertex count + 1 for start derivative, end derivative, match curvature at start and end. 
    evCurveDefinition(context, {
                        "edge" : orderedEdges[p],
                        "returnBSplinesAsOther":false
                });
    should return a b spline curve for briding curves, fit splines and any other wire body spline i would assume. 

    edges generated from lofts are likely not going to be any of these and need approximation as they are trimming curves where the 2 untrimmed b spline surfaces merge and are split. Also, there are 2 curves for each two sided edge, and neither of them are exactly the same as each other most of the time.  Even if those edges were created from a guide, it does not mean that that guide is even used to separate them perfectly. I have noticed variations of very small but still exist for loft face edges and the guides that were used.

    any edge between any face unless a primative like line arc circle conic, is likely going to be an approximated b spline curve. 

    I hope i am not just rambling on here, these are the results of m findings so far. 
  • S1monS1mon Member Posts: 2,321 PRO
    @Jacob_Corder

    My main goal is to figure out how to enable more class-a style of working. Practices seem to be evolving, but traditionally most automotive class-a surfacing is done with single span Bézier surfaces. I'm trying to figure out what I can to reduce the complexity out of the default tools in Onshape.

    Yes, Bridging curve is a single span b-spline - which is equivalent to a Bézier. evCurveDefinition returns this as "curveType" : "SPLINE". The control points seem to match the Bridging curve, but I need to confirm.
     
    With a true arc/circle, evCurveDefinition piped through evApproximateBSplineCurve is giving a weighted b-spline in order to get what looks to be an exact match. From what I know, this is why we have NURBS in the first place is to be able to modify the weights and get all the conic sections exactly.

    In many of the use cases I'm planning, I would like the option to get a Bézier, even at the expense of slight approximation errors. The idea being to use sweep/loft/offset to build the design intent, but with heavy splines - then rebuild them with lighter/cleaner Béziers.

    I understand that in general, a two sided edge can have two non-equal trim curves, but I was hoping that with simple clean Béziers, the edge of the surfaces would be the guide curve. I've seen stuff in Solidworks where the surfaces get slightly overbuilt and then trimmed back for some reason (e.g. revolve does this), so perhaps this is something Parasolid is doing.
  • Jacob_CorderJacob_Corder Member Posts: 126 PRO
    edited February 2022
    @S1mon

    I am getting b spline curves from onshape for bridging curves. I am even getting a bezier curve back from a bridging curve.


    I think i know what is happening.

    You are just checking the curveType.

    Do this

    If(c is BSplineCurve)
    {
        it returns a b spline curve with curveType as another field. 
    }

    this is my sample and it returns b spline curves on all wire bodies that are not extracted from edges
    var data = evCurveDefinition(context, {
                                "edge" : qEntityFilter(entities[p], EntityType.EDGE),
                                "returnBSplinesAsOther":false
                        });
                         
                            if(data is BSplineCurve)
                            {
                                println("Got true bs curve Good job onshape");
                            }
                            else
                            {
                                println("Getting approx b spline curve");
                                data = evApproximateBSplineCurve(context, {
                                    "edge" : qEntityFilter(entities[p], EntityType.EDGE)
                                });
                            }
                         
                         
  • Jacob_CorderJacob_Corder Member Posts: 126 PRO
    @S1mon
    Did my last comment I left fix your issue getting the b-spline curve from evCurveDefinition?
  • S1monS1mon Member Posts: 2,321 PRO
    @Jacob_Corder

    Yes. This helped. Thanks.
Sign In or Register to comment.