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.

Beams feature problems

MBartlett21MBartlett21 Member Posts: 1,523 EDU
The beams feature won't take projected curves as input.
Is there any reason for this?
MB - I make FeatureScripts: view FS (My FS's have "Official" beside them)

Best Answer

  • MBartlett21MBartlett21 Posts: 1,523 EDU
    Accepted Answer
    @NeilCooke
    I have now fixed the problem.
    I replaced this line of code
    loopPlane = evPlane(context, { "face" : qGeometry(qEdgeAdjacent(firstEdge, EntityType.FACE), GeometryType.PLANE) });

    with this block of 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 - I make FeatureScripts: view FS (My FS's have "Official" beside them)

Answers

  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 2,075
    It is probably a spline
    Neil Cooke, Director of Technical Marketing, Onshape Inc.
  • MBartlett21MBartlett21 Member Posts: 1,523 EDU
    @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 - I make FeatureScripts: view FS (My FS's have "Official" beside them)
  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 2,075
    Without looking at the code maybe I restricted selection to sketch entities and model edges. 
    Neil Cooke, Director of Technical Marketing, Onshape Inc.
  • MBartlett21MBartlett21 Member Posts: 1,523 EDU
    @NeilCooke

    The filter is: EntityType.EDGE && (GeometryType.LINE || GeometryType.ARC)
    I don't think that would be a problem 
    MB - I make FeatureScripts: view FS (My FS's have "Official" beside them)
  • MBartlett21MBartlett21 Member Posts: 1,523 EDU
    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 - I make FeatureScripts: view FS (My FS's have "Official" beside them)
  • MBartlett21MBartlett21 Member Posts: 1,523 EDU
    Accepted Answer
    @NeilCooke
    I have now fixed the problem.
    I replaced this line of code
    loopPlane = evPlane(context, { "face" : qGeometry(qEdgeAdjacent(firstEdge, EntityType.FACE), GeometryType.PLANE) });

    with this block of 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 - I make FeatureScripts: view FS (My FS's have "Official" beside them)
Sign In or Register to comment.