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.

"Face Curves" in Featurescript?

S1monS1mon Member Posts: 883 PRO
In Solidworks, and countless other CAD tools it's easy to create curves on surfaces based on U-V. They're useful for creating patterns of 3D curves with similar styles, trimming surfaces, or just diagnosing the quality of the surface. Note that these are vaguely similar to the edges created by Onshape's "move boundary" when it's trimming the surface, but those are trying to move things in a offset fashion, not in a U or V direction.

This screenshot shows an arbitrary surface with a 5 x 5 pattern of curves in Solidworks. You can also do it based on position - either a selected point, or percentages. I'd like to have this basic functionality in Onshape. It seems like something which shouldn't be too hard to do with FeatureScript, but I haven't written any yet. While it would be great if someone else would just write this for me, I was hoping for some pointers on the following:
  1. Is it possible and relatively straightforward to create curves in FeatureScript?
  2. Are there any example FeatureScripts which do anything similar?


Comments

  • Evan_ReeseEvan_Reese Member Posts: 1,420 PRO
    I have no idea, but I'd use this! Mostly just to eval and understand my surfaces, but maybe occasionally to actually use a face curve in a model.
    Evan Reese / Principal and Industrial Designer with Ovyl
    Website: ovyl.io
  • mahirmahir Member, Developers Posts: 1,213 ✭✭✭✭✭
    Agreed. Something similar to Catia's parallel curve feature would be nice for generating construction curves.
  • S1monS1mon Member Posts: 883 PRO
    So oddly enough there's some FeatureScript documentation which references "opCreateCurvesOnFace". I can't find the documentation for that.

    The enum types here seem to correspond to the functionality that's in Solidworks perhaps because it's what the Parasolid kernel provides. Is Onshape working on the feature I'm trying to create? What is the reason for the asterix in this line: "Specifies type of curve on face. *" ?


  • Jacob_CorderJacob_Corder Member Posts: 65 PRO
    Look up sculptFace.
    This will generate splines in the U V Directions of a face. it does not however, give you the splines relative to an edge or parallel to an edge, I Actually need what you posted.  If i figure anything out, i will definitely share it.
  • S1monS1mon Member Posts: 883 PRO
    @Jacob_Corder Thanks! 

    Also thanks to @maximilian_schommer for creating sculptFace.

    I managed to sift through sculptFace and even though I don't really understand what I did, I was able to copy the bits which created the splines and leave behind all the rest. What is interesting is that it's clearly not extracting the isoparameters, but instead making approximate splines based on sampling the face (or something like that). If the U or V count is too low, the curves don't follow the surface. In any case I have more work to do, but I was able to get something to happen.




  • Jacob_CorderJacob_Corder Member Posts: 65 PRO
    @S1mon
     you are correct. the tolerance in the faces is basically from the U V grid.  I  have found that the curves can be very bad because they are created using opfitspline.

    I need this opCreateCurvesOnFace feature like last month.

    I am working on cracking it but it may be tough. maybe onshape can help. hopefully.

  • Jacob_CorderJacob_Corder Member Posts: 65 PRO
    @S1mon

    Here is what i discovered so far. 

    the feature works, however, i cannot find a way for it to use a guide on the edge to control the U V Parameters instead of using the basic underlying U V directions of the surface.

    FeatureScript 1324;
    import(path : "onshape/std/geometry.fs", version : "1324.0");

    export enum FaceCurveCreationType
    {
        annotation{"Name":"Primary Direction"}
        DIR1_ISO,
        annotation{"Name":"Secondary Direction"}
        DIR2_ISO,
         annotation{"Name":"Primary Direction equal Spaced"}
        DIR1_AUTO_SPACED_ISO,
        annotation{"Name":"Secondary Direction equal Spaced"}
        DIR2_AUTO_SPACED_ISO
    }


    annotation { "Feature Type Name" : "UV ParallelCurves" }
    export const uvParallelCurvesOnFace = defineFeature(function(context is Context, id is Id, definition is map)
        precondition
        {
            annotation { "Name" : "Curve Definition", "Item name" : "Curve Definition", "Item label template" : "#creationType" }
            definition.curveDefinition is array;
            for (var cDef in definition.curveDefinition)
            {
                annotation { "Name" : "Face", "Filter" : EntityType.FACE, "MaxNumberOfPicks" : 1 }
                cDef.face is Query;
                annotation { "Name" : "Curve Creation Type" }
                cDef.creationType is FaceCurveCreationType;
                if(cDef.creationType==FaceCurveCreationType.DIR1_AUTO_SPACED_ISO || cDef.creationType==FaceCurveCreationType.DIR2_AUTO_SPACED_ISO)
                {
                    annotation { "Name" : "Number of Curves" }
                    isInteger(cDef.nCurves, POSITIVE_COUNT_BOUNDS);                
                }
                else
                { 
                    annotation { "Name" : "parameter" }
                    isReal(cDef.param,POSITIVE_REAL_BOUNDS);
                }            
            }         
        }
        {
            
            for(var i =0;i<size(definition.curveDefinition);i+=1)
            {
                if(definition.curveDefinition[i].creationType == FaceCurveCreationType.DIR1_ISO || definition.curveDefinition[i].creationType== FaceCurveCreationType.DIR2_ISO)
                {
                    definition.curveDefinition[i].parameters = [definition.curveDefinition[i].param];               
                    definition.curveDefinition[i].names = ["curve1"];
                }
                else
                {
                    definition.curveDefinition[i].names = makeArray(definition.curveDefinition[i].nCurves, "Name");
                    for(var j =0;j<definition.curveDefinition[i].nCurves;j+=1)
                    {
                        definition.curveDefinition[i].names[j] = "curve"~i~j;
                    }
                }
            }
            try
            {
                @opCreateCurvesOnFace(context, id,definition); 
            }
           catch (error)
           {
               println(error);
           }       
        });

  • maximilian_schommermaximilian_schommer Member Posts: 32 ✭✭
    So one possibility to get a "parallel to edge" feature, is to sample a given edge, and extract what the UV parameters are of that edge. Then, we need to interpolate the parameters to some other UV bound in order to make the "parallel" edges (which wouldn't really be parallel, since that's not possible with nonlinear curves anyways).

    Another possibility is to use the tangent edges along the edge we want to make parallel lines for, and we move in direction perpendicular to the sampled tangent lines, and then find the UV parameters of that new curve when projected on the surface, and then iterate on that process. It would take a bit more computation since it is an iterative solution, but satisfies the idea of "parallel" a lot more.


  • ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 1,120
    Today's release has some useful functionality here (thanks to @elif)https://cad.onshape.com/FsDoc/library.html#opCreateCurvesOnFace-Context-Id-map
    Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc
  • S1monS1mon Member Posts: 883 PRO
    edited August 2020
    Excellent! I'll have to work on turning this into a useful user-facing featurescript.... Unless someone else at Onshape is planning to do this soon?
  • ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 1,120
    I'm not aware of such a project.  This is functionality we needed for some ongoing development work we're doing (you found traces of it), but when we saw the requests here, Elif decided to package it up and release it.
    Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc
  • MBartlett21MBartlett21 Member, OS Professional, Developers Posts: 2,010 EDU
    @ilya_baran
    Is the development related to beams by any chance? >:)

    That gives me an idea to improve the length measurement on mine...
    mb - draughtsman - also FS author: View FeatureScripts
  • S1monS1mon Member Posts: 883 PRO
    @Evan_Reese
    Did this FeatureScript get lost when you converted to Enterprise?

    I'm also looking for a good examples of how to group a bunch of curves into a composite feature. I remember your version doing that. Is that right?
  • Evan_ReeseEvan_Reese Member Posts: 1,420 PRO
    yep, and I must have missed it in getting things public again. It should be available now. Yes it optionally makes them all into a composite part. For a more general compositing tool you should also look at Composite Selected by @monroe_weber_shirk
    Evan Reese / Principal and Industrial Designer with Ovyl
    Website: ovyl.io
  • S1monS1mon Member Posts: 883 PRO
    @Evan_Reese
    Thanks for making FaceCurve public again.

    I'm having issues with the composite part of the code. I'm trying to do an upgrade of the dihedral angle featurescript (I'll share this soon when I get it working), and I basically copied your code for the composite option. At first I thought I had copied it in a way which wasn't working in my code, but it seems like there's something buggy about it in your FaceCurve FeatureScript as well.

    If "Create composite" is turned off in FaceCurves, it works, if it's turned on, the curves will preview correctly when you first toggle "Create composite" on while editing the feature, but when you complete the feature, they disappear. There's still a composite part in the instance list, and hovering over it shows that there are curves in it, but they seem invisible.

    I've found in my code that if I switch closed to false, it works, but that's really defeating the purpose for me.

    This seams like it might even be a bug in Onshape.
  • Evan_ReeseEvan_Reese Member Posts: 1,420 PRO
    Hmm. It was definitely working before. V6 works. I just checked, and it works up until this automatic update, but not after, so something must have changed on Onshape's side. I wonder if you could get it working by just importing a different version of featurescript.
     

    Evan Reese / Principal and Industrial Designer with Ovyl
    Website: ovyl.io
  • S1monS1mon Member Posts: 883 PRO
    @Evan_Reese
    I reported the disappearing closed composite part issue to support. We'll see what's up...
  • S1monS1mon Member Posts: 883 PRO
    @Evan_Reese @lougallo
    In less than a week, Onshape fixed the bug and pushed an update live. This is one reason why I like Onshape.

    "Onshape has been updated to address your ticket:

    "Closed Composite Curves are Invisible"

    This update ( 1.141.3231.2875ac2d443e ) has been pushed to cad.onshape.com and is live for all users of Onshape. This should address the issue with wire bodies not showing up in closed composites."
  • Evan_ReeseEvan_Reese Member Posts: 1,420 PRO
    S1mon said:
    @Evan_Reese @lougallo
    In less than a week, Onshape fixed the bug and pushed an update live. This is one reason why I like Onshape.

    "Onshape has been updated to address your ticket:

    "Closed Composite Curves are Invisible"

    This update ( 1.141.3231.2875ac2d443e ) has been pushed to cad.onshape.com and is live for all users of Onshape. This should address the issue with wire bodies not showing up in closed composites."
    I absolutely agree!
    Evan Reese / Principal and Industrial Designer with Ovyl
    Website: ovyl.io
Sign In or Register to comment.