Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- 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.
Finding 90 degree angled vertices among selected lines
eric_ma454
Member Posts: 14 ✭
Hi all,
My name is Eric Ma, and myself and 3 others represent a subteam of AguaClara Cornell dedicated to using Featurescript to model our plants. We just switched to OnShape, and are new to Featurescript, so we'll probably be showing up on the forums much more frequently. We're excited to learn more about the language, and all help would be greatly appreciated!
Our current project involves inserting elbows into a selection of created pipes. This is a modification off of the current Beam feature, which is being used to model pipes. The current feature takes an input of edges, and creates "beams" from the edges. Our goal is to find all the points within the given selection of edges that have a 90 degree vertex, and insert an elbow of a specific size there. Our current issue stems from finding the specific 90 degree points. We have found all adjacent points with qVertexAdjacent, but the issue is we're unsure how to find that the vertices that only have two lines stemming from it at 90 degrees. Any help would be appreciated, on this specific question or on Featurescript in general.
Best,
Eric Ma
AguaClara Cornell
@ethan_keller924
My name is Eric Ma, and myself and 3 others represent a subteam of AguaClara Cornell dedicated to using Featurescript to model our plants. We just switched to OnShape, and are new to Featurescript, so we'll probably be showing up on the forums much more frequently. We're excited to learn more about the language, and all help would be greatly appreciated!
Our current project involves inserting elbows into a selection of created pipes. This is a modification off of the current Beam feature, which is being used to model pipes. The current feature takes an input of edges, and creates "beams" from the edges. Our goal is to find all the points within the given selection of edges that have a 90 degree vertex, and insert an elbow of a specific size there. Our current issue stems from finding the specific 90 degree points. We have found all adjacent points with qVertexAdjacent, but the issue is we're unsure how to find that the vertices that only have two lines stemming from it at 90 degrees. Any help would be appreciated, on this specific question or on Featurescript in general.
Best,
Eric Ma
AguaClara Cornell
@ethan_keller924
0
Comments
You may want to use qWithinRadius if they are sketch lines to find adjacent ones.
Example code (Replace variables in BOLD_ITALICS with your variables:
var perpendicularPointsAndLines = []; var evaluatedVertices = evaluateQuery(context, <b><i>VERTICES</i></b>); for(var vertex in evaluatedVertices){ var vertexPoint = evVertexPoint(context, {"vertex" : vertex }); var lineEdges = evaluateQuery(context, qGeometry(qWithinRadius(<b><i>LINES_FROM_INPUT</i></b>, vertexPoint, TOLERANCE.zeroLength * meter), GeometryType.LINE)); if(size(lineEdges) == 2){ var d1 = evLine(context, {"edge" : lineEdges[0]}).direction; var d2 = evLine(context, {"edge" : lineEdges[1]}).direction; if(perpendicularVectors(d1,d2)) perpendicularPointsAndLines = append(perpendicularPointsAndLines, {"vertex" : vertexPoint,"edges" : lineEdges}); } }IR for AS/NZS 1100
FeatureScript 937; import(path : "onshape/std/geometry.fs", version : "937.0"); annotation { "Feature Type Name" : "FindAngles" } export const myFeature = defineFeature(function(context is Context, id is Id, definition is map) precondition { // Define the parameters of the feature type annotation { "Name" : "Lines or arcs", "Filter" : EntityType.EDGE && (GeometryType.LINE || GeometryType.ARC) } definition.edges is Query; } { var path = constructPath(context, definition.edges); var nLines = size(path.edges); var tangentLines = evPathTangentLines(context, path, range(0,1,nLines)); var angles = []; for (var i = 0; i<nLines-1; i=i+1){ var angle = angleBetween(tangentLines.tangentLines[i].direction, tangentLines.tangentLines[i+1].direction); angles = append(angles, angle); } print("An array of the angle at each of the points along the selected path: "); print(angles); });