Beams feature problems

MBartlett21
MBartlett21 Member, OS Professional, Developers Posts: 2,064 ✭✭✭✭✭
The beams feature won't take projected curves as input.
Is there any reason for this?
mb - draftsman - also FS author: View FeatureScripts
IR for AS/NZS 1100

Best Answers

  • MBartlett21
    MBartlett21 Member, OS Professional, Developers Posts: 2,064 ✭✭✭✭✭
    Answer ✓
    @NeilCooke
    I have now fixed the problem.
    I replaced this line of code
    </code>loopPlane = evPlane(context, { "face" : qGeometry(qEdgeAdjacent(firstEdge, EntityType.FACE), GeometryType.PLANE) });</pre><div><a rel="nofollow" href="https://forum.onshape.com/discussion/comment/38753#"></a></div><br>with this block of code<br><pre class="CodeBlock"><code>
            try
            {
                // this will be two faces so just have to return the first
                loopPlane = evPlane(context, { "face" : qGeometry(qEdgeAdjacent(firstEdge, EntityType.FACE), GeometryType.PLANE) });
            }
            catch
            {
                const lineResult = evAxis(context, { "axis" : firstEdge });
                definition.axis = lineResult;
    
                var baseNormal = perpendicularVector(lineResult.direction);
                var normal = rotationMatrix3d(lineResult.direction, 0 * degree) * baseNormal;
    
                return plane(lineResult.origin, normal, lineResult.direction);
            }
    It now works fine.




    mb - draftsman - also FS author: View FeatureScripts
    IR for AS/NZS 1100
  • tim_doctor
    tim_doctor Member Posts: 1 ✭✭
    edited May 2021 Answer ✓
    @NeilCooke

    Bumping this old thread because I'm having the exact same issue described above using v18 of the Beams Feature. I have a Projected Curve between two straight lines. Beam feature fails and seems to not like using a projected curve as an input. Obviously, I don't really know how to read FeatureScript code to figure this out for myself. Has @MBartlett21 's solution not been rolled in to the official version of the Beam Feature?

    Here's a dummy model showing what I'm looking at. Beams works with sketch entities, but doesn't like the projected curve... even though it's a line. What am I missing?


  • NeilCooke
    NeilCooke Moderator, Onshape Employees Posts: 6,126 image
    Answer ✓
    @tim_doctor - I must admit I don't recall seeing this code (sorry @MBartlett21) - I've added it (without QA) to V19
    Senior Director, Technical Services, EMEA

Answers

  • NeilCooke
    NeilCooke Moderator, Onshape Employees Posts: 6,126 image
    It is probably a spline
    Senior Director, Technical Services, EMEA
  • MBartlett21
    MBartlett21 Member, OS Professional, Developers Posts: 2,064 ✭✭✭✭✭
    @NeilCooke

    I created it by making a projected curve between two straight lines.

    If I create a plane, then make a sketch on it and project those lines into the sketch, the Beam feature works fine like that.
    mb - draftsman - also FS author: View FeatureScripts
    IR for AS/NZS 1100
  • NeilCooke
    NeilCooke Moderator, Onshape Employees Posts: 6,126 image
    Without looking at the code maybe I restricted selection to sketch entities and model edges. 
    Senior Director, Technical Services, EMEA
  • MBartlett21
    MBartlett21 Member, OS Professional, Developers Posts: 2,064 ✭✭✭✭✭
    @NeilCooke

    The filter is: EntityType.EDGE && (GeometryType.LINE || GeometryType.ARC)
    I don't think that would be a problem 
    mb - draftsman - also FS author: View FeatureScripts
    IR for AS/NZS 1100
  • MBartlett21
    MBartlett21 Member, OS Professional, Developers Posts: 2,064 ✭✭✭✭✭
    edited March 2018
    @NeilCooke

    I copied it here and it is this section of code that is having a problem:
    function getPlane(context is Context, definition is map, edgeLoop is array) returns Plane
    {
        const firstEdge = qNthElement(definition.edges, edgeLoop[0].edge);
        
        var loopPlane;
        
        try 
        {
            // check if the first entity is a sketch edge, if not check for solid or surface edge
            loopPlane = evOwnerSketchPlane(context, { "entity" : firstEdge });
        }
        catch
        {
            // this will be two faces so just have to return the first
            loopPlane = evPlane(context, { "face" : qGeometry(qEdgeAdjacent(firstEdge, EntityType.FACE), GeometryType.PLANE) });
    
            if (size(edgeLoop) > 1)
            {
                const point1 = edgeLoop[0].vertex[0].origin;
                const point2 = edgeLoop[0].vertex[1].origin;
                var point3;
                var normal;
                var success = false;
    
                for (var i = 1; i < 2; i += 1)
                {
                    for (var j = 0; j < 2; j += 1)
                    {
                        point3 = edgeLoop[i].vertex[j].origin;
                        normal = cross(point3 - point1, point2 - point1);
                        if (norm(normal).value > TOLERANCE.zeroLength)
                        {
                            success = true;
                            break;
                        }
                    }
                    if (success)
                        break;
                }
                loopPlane = plane(point1, normalize(normal), normalize(point2 - point1));
            }
        }
    
        return loopPlane;
    }
    
    
    
    This specifically is the line of code throwing the error:
    
    loopPlane = evPlane(context, { "face" : qGeometry(qEdgeAdjacent(firstEdge, EntityType.FACE), GeometryType.PLANE) });
    mb - draftsman - also FS author: View FeatureScripts
    IR for AS/NZS 1100
  • MBartlett21
    MBartlett21 Member, OS Professional, Developers Posts: 2,064 ✭✭✭✭✭
    Answer ✓
    @NeilCooke
    I have now fixed the problem.
    I replaced this line of code
    </code>loopPlane = evPlane(context, { "face" : qGeometry(qEdgeAdjacent(firstEdge, EntityType.FACE), GeometryType.PLANE) });</pre><div><a rel="nofollow" href="https://forum.onshape.com/discussion/comment/38753#"></a></div><br>with this block of code<br><pre class="CodeBlock"><code>
            try
            {
                // this will be two faces so just have to return the first
                loopPlane = evPlane(context, { "face" : qGeometry(qEdgeAdjacent(firstEdge, EntityType.FACE), GeometryType.PLANE) });
            }
            catch
            {
                const lineResult = evAxis(context, { "axis" : firstEdge });
                definition.axis = lineResult;
    
                var baseNormal = perpendicularVector(lineResult.direction);
                var normal = rotationMatrix3d(lineResult.direction, 0 * degree) * baseNormal;
    
                return plane(lineResult.origin, normal, lineResult.direction);
            }
    It now works fine.




    mb - draftsman - also FS author: View FeatureScripts
    IR for AS/NZS 1100
  • tim_doctor
    tim_doctor Member Posts: 1 ✭✭
    edited May 2021 Answer ✓
    @NeilCooke

    Bumping this old thread because I'm having the exact same issue described above using v18 of the Beams Feature. I have a Projected Curve between two straight lines. Beam feature fails and seems to not like using a projected curve as an input. Obviously, I don't really know how to read FeatureScript code to figure this out for myself. Has @MBartlett21 's solution not been rolled in to the official version of the Beam Feature?

    Here's a dummy model showing what I'm looking at. Beams works with sketch entities, but doesn't like the projected curve... even though it's a line. What am I missing?


  • NeilCooke
    NeilCooke Moderator, Onshape Employees Posts: 6,126 image
    Answer ✓
    @tim_doctor - I must admit I don't recall seeing this code (sorry @MBartlett21) - I've added it (without QA) to V19
    Senior Director, Technical Services, EMEA
  • CBowers
    CBowers Member Posts: 50 PRO
    @NeilCooke I'm having an issue with ends of beams being automatically coped if the trimming beam is projected along a curved path and the trimmed beam is of the same size or larger. Is this something that can be easily fixed? Having to use a workaround where I use replace face for the tops and bottoms of the beams needing trimmed, but it's kind of tedious.
    In this picture the bottom dark grey beam is along a curved path. The diagonal light blue beam is automatically coped and I can't choose to have it do anything else. These are HSS 8x8x1/4.
  • NeilCooke
    NeilCooke Moderator, Onshape Employees Posts: 6,126 image
    @CBowers - it is a major change to get this to work and I'm fairly confident that if I fix this, it will break other things. I'll have a think if there is a better way I can do it, but in the meantime your method is the best/only way.
    Senior Director, Technical Services, EMEA