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: 2,986 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: 2,986 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. 
Sign In or Register to comment.