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.
Featurescript. Create a record of edges vs solid bodies.
Alex_Pitt
Member Posts: 65 PRO
Can the keys in a map be edges? And can the corresponding value in the map be a Solid Body? (I know that Arrays can contain Solid Bodies.) I want to create a record (whether it's a map or an array) that links an edge to a body. So Edge1 belongs to SolidBody1, Edge2 belongs to SolidBody2, Edge3, belongs to SolidBody3 etc.
I want my feature to do the following: The user selects some solid bodies (parts) and then some edges. It sorts out which edges belong to what parts and then moves each part along its associated selected edge (spacial translation, distance given by the length of the edge). Sounds pointless I know, but it's a stepping stone for something more useful.
I want my feature to do the following: The user selects some solid bodies (parts) and then some edges. It sorts out which edges belong to what parts and then moves each part along its associated selected edge (spacial translation, distance given by the length of the edge). Sounds pointless I know, but it's a stepping stone for something more useful.
Tagged:
0
Answers
To sort which selected edges belong to which bodies, you could get all the edges of a body then qIntersect it with your selected edge.
(Although I am using an evaluated query to fill the array. Maybe it's filling the array with strings to represent each body. I will press on. )
____________
var bodyArray = [];
______________
Also, Konst_Sh posted this answer this morning.
In the body of the script, I've put my picked bodies into one array and my picked edges in another, so that there's a definite order.
The hope is to use "for loops" working through the bodies one by one to reorder the edge array to correspond with the body array, to finish with EdgeArray[0] owned by BodyArray[0], EdgeArray[1] owned by BodyArray[1] etc. If no edges have been picked for a particular body, then a "flag" value will be placed in that position of the EdgeArray. If 2 or more edges have been picked for a single body, then one edge only is "chosen" and the others discarded. There's still a long way to go with this!