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.

Untrim?

S1monS1mon Member Posts: 3,155 PRO
Is there a custom FeatureScript, or some way to do the equivalent of Solidworks Untrim? Right now you can use move boundary to enlarge a surface, and even fill in holes in the surface, but it will often rebuild the control grid in weird ways.

Despite it being clear that the original surface definition is there, I don't see a way to retrieve it using the built in Onshape features.

Here's a surface (from an imported model) with control grid and curvature combs shown:

Here's that surface with Move boundary:

I'm also showing a copy of the original, just to show how weird the new parameterization is relative to where the original surface was, and you can also see that the new surface definition is even more than twice the size of the surface which is visible. 
Tagged:

Comments

  • Jacob_CorderJacob_Corder Member Posts: 137 PRO
    edited February 2023
    to fill the holes in there are 2 ways.

    fill the holes using fill, then use replaceFace on the new face and replace with the outer face. if that fails, delete the new face with heal option.

    if that fails then you can create patches from the original face using this

    annotation { "Feature Type Name" : "Remove Inner Loops" }
    export const removeInnerLoops = defineFeature(function(context is Context, id is Id, definition is map)
        precondition
        {
            annotation { "Name" : "Face", "Filter" : EntityType.FACE, "MaxNumberOfPicks" : 1 }
            definition.face is Query;
            
        }
        {
            var ownerBdy = makeRobustQuery(context, qOwnerBody(definition.face));
            var bsData = evApproximateBSplineSurface(context, {
                   "face" : definition.face
            });  
            var succeeded =false;
            if(bsData.innerLoopBSplineCurves is array)
            {
                for(var n=0;n<size(bsData.innerLoopBSplineCurves);n+=1)
                {
                    opCreateBSplineSurface(context, id+"innerLoops" + n + "create", {
                            "bSplineSurface" : bsData.bSplineSurface,
                            "boundaryBSplineCurves":bsData.innerLoopBSplineCurves[n]
                    });
                    
                }
                try
                {
                    
              
                    opBoolean(context, id+"mergeFaces", {
                            "tools" : qUnion(ownerBdy,qCreatedBy(id, EntityType.BODY)),
                            "operationType" : BooleanOperationType.UNION
                    });
                }
                if(isQueryEmpty(context, qCreatedBy(id, EntityType.BODY)) )
                {            
                    return;
                }
                else
                {
                    opDeleteBodies(context, id+"deleteFailedMerges", {
                            "entities" : qCreatedBy(id, EntityType.BODY)
                    });
                     
                }
            }
              
            opCreateBSplineSurface(context,id + "bsSurface",{"bSplineSurface":bsData.bSplineSurface,"boundaryBSplineCurves":bsData.boundaryBSplineCurves});
            opDeleteFace(context, id+"deleteFace", {
                    "deleteFaces" : definition.face,
                    "includeFillet" : false,
                    "capVoid" : false,
                    "leaveOpen" : true
            });
             
            opBoolean(context, id+"joinFace", {
                    "tools" : qUnion(ownerBdy,qCreatedBy(id+"bsSurface", EntityType.BODY)),
                    "operationType" : BooleanOperationType.UNION
            });
           
        });
    the code will attempt to patch. if that fails it recreates the face without inner loops.


    To extend the surface to its full extent, is tough if you just want one edge. To do the full surface just call
    </code>var bsData = evApproximateBSplineSurface(context, {</pre><pre class="CodeBlock"><code>               "face" : definition.face
            });  
    opCreateBSplineSurface(context,id + "bsSurface",{"bSplineSurface":bsData.bSplineSurface});
    



      The boundary bSplineCurves can be tricky. I am working to get that for you now. I will add it later when i figure it out.

  • S1monS1mon Member Posts: 3,155 PRO
    @Jacob_Corder

    Thanks for the FS code. I was hoping this would be much more straightforward. I was assuming that, at least in FS, there would be a few lines of code to create a copy of an existing surface without all the boundary curves. I'm sure you're familiar with Solidworks' Untrim command. I would think doing the Onshape equivalent of SWX Untrim 100% would be just a matter of throwing away the trim curves. 
  • Jacob_CorderJacob_Corder Member Posts: 137 PRO
    @S1mon
    annotation { "Feature Type Name" : "Base Surface" }
    export const baseSurface = defineFeature(function(context is Context, id is Id, definition is map)
        precondition
        {
            annotation { "Name" : "Face", "Filter" : EntityType.FACE, "MaxNumberOfPicks" : 1 }
            definition.face is Query;
            
        }
        {        
            var bsData = evApproximateBSplineSurface(context, {
                   "face" : definition.face
            });  
            opCreateBSplineSurface(context, id, {                        "bSplineSurface" : bsData.bSplineSurface,
                    });
    });this will extract the full underlying surface.  If the face is a bspline surface then evApproximateBSplineSurface still returns the true non approximated surface. If it is revolved, then for some reason onshape does approximate it still without using the underlying revolve bspline curve. 
  • jelte_steur814jelte_steur814 Member Posts: 273 PRO
    edited January 14

    I had the intention to create a feature like this and first had a look if someone else hadn't created it yet.

    I stumbled upon this thread and used a little of the code as inspiration. thanks @Jacob_Corder

    I decided to include 'approximate' as an option because the underlying precise bSpline data is also available and will also allow untrimming a bigger outside boundary

    its far from complete in error-proofing, debug options, feedback etc, so not worth publishing yet, but i thought i'd share it here anyway:

    https://cad.onshape.com/documents/cfb4cc57fbc7d3a530c8f72e/w/a26ba85592584022b7b1cd90/e/49aed5fa3f79a8c2d586a811?renderMode=0&uiState=678646f65ef9d246809085fc

    for other surfaceTypes than bSpline surfaces, the code would need to use other create functions.

    for some those are available, (like sphere), but not for all. so I'm not sure if that is going to work out to allow recreation without approximation. Moreover trimming to the outer boundary is going to be tricky i think (for the 'inner loop only' option.

  • jelte_steur814jelte_steur814 Member Posts: 273 PRO

    thanks for sharing.

    similar in that it works for B-spline surfaces and else approximates. But Greg has hardcoded that into the feature wich is better than what I have.

    I also have an 'extract face' FS which just separates a face from a body. That is closer to the nomenclature i'm used to with other CAD software.

    So i think untrim would be a better term?

  • S1monS1mon Member Posts: 3,155 PRO

    I guess "untrim" makes sense if the surface ID stays same and it doesn’t create a new surface. Greg’s "extract" feature creates a new surface from a surface or solid face.

    Ideally "untrimming" or "extracting" could be done with one feature, with an appropriate option. I'd also like to see Solidworks' optional capability to extend the untrimmed surface. Also, an option to remove or leave internal holes in the surface would be great.

    For even more extra credit, a refit-trim type tool which would rebuild a four sided trimmed surface to be untrimmed would be useful.

  • martin_kopplowmartin_kopplow Member Posts: 639 PRO

    Yes. Creating a new surface is nice, though it kind of breaks the chain. A feature which keeps the ID and continuity in the design process would sure be perferable, especially if we could go back when needed and untrim another side or remove or restore another internal edge.

    I've been working with Spaceclaum for quite some time, an there, it was one tool that simply removed all trims when applied to a face (you got to hit it in the middle) and removed trim of one edge, extending adjacent edges when applied to that edge (you had to click on the portion of the edge you wanted to untrim).

    There also was the 'Pull' tool that had an interesting functionality: You'd pull on a trimmed edge to gradually pull it back to it's untrimmed state in the first go. Pulling on the untrimmed edge another time would extend (extrapolate) it gradually as far as mathematically possible. That was very useful and very intuitive at that.

Sign In or Register to comment.