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.
Create sketch in middle of part
Lee_Hesketh
Member, Developers Posts: 148 ✭✭✭
Hi all. I have a script where the user selects a face, then using qConvexConnectedFaces twice to select the ends. I have then found the midpoint of each of those faces and used them to find the midpoint of the part. What I need to do is create a plane at that point parallel to the end faces and then create a sketch. How could I do this?
Also, how could I implement the midplane feature from the plane command?
Thanks
Lee Hesketh
Also, how could I implement the midplane feature from the plane command?
Thanks
Lee Hesketh
There are 10 types of people in the world. Those who know binary, those who don't and those who didn't expect base 3!
Tagged:
0
Best Answer
-
jakeramsley Member, Moderator, Onshape Employees, Developers, csevp Posts: 661Hi Lee_Hesketh,
To create a plane, you can use the constructor that takes:plane (origin is Vector, normal is Vector) returns Plane
The origin of your plane is going to be the mid-point that you calculated and the vector should be the normal of the plane to make them parallel. Such that:var planeDef = plane(midPoint, plane1.normal);
From here, I would make an opPlane off of this:<div>opPlane(context, id + "plane", { "plane" : planeDef, "width" : 6 * inch, "height" : 6 * inch });</div><div></div>
Then you want to make a sketch based on this planevar mySketch = newSketch(context, id + "sketch1", {<br><span style="font-family: Flama, sans-serif;"> "sketchPlane" : qCreatedBy(id + "plane", EntityType.FACE)<br></span><span style="font-family: Flama, sans-serif;">});</span>
Since you already have the mid-points, I would use the cPlane command with the cplaneType set to CPlaneType.MID_PLANE.cPlane(context, id, { <br> "entities" : [query of both mid-points], <br> "cplaneType" : CPlaneType.MID_PLANE, <br> "flipAlignment" : false, <br> "width" : 6.0 * inch, <br> "height" : 6.0 * inch <br>});
Jake RamsleyDirector of Quality Engineering & Release Manager onshape.com5
Answers
To create a plane, you can use the constructor that takes: The origin of your plane is going to be the mid-point that you calculated and the vector should be the normal of the plane to make them parallel. Such that: From here, I would make an opPlane off of this:
Then you want to make a sketch based on this plane
Since you already have the mid-points, I would use the cPlane command with the cplaneType set to CPlaneType.MID_PLANE.