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.
how to evaluate extrude direction so it can be used in a transform
owen_sparks
Member, Developers Posts: 2,660 PRO
Hi folks.
Hopefully an easy one this time.
I'm creating a body using an extrude from a sketch.
Having made it I may wish to transform it in the direction of the previous extrude operation.
I can use the qCreatedBy query to grab the body for the entity parameter but am having difficulty evaluating the extrude direction for the "transformDirection" parameter. (If we can't use the extrude direction can we use "normal to the sketch" the extrude was performed with?)
if (definition.SubFlush)
{
transform(context, id + i, {
"entities" : qCreatedBy(id + i + "extrudeNutDown1", EntityType.BODY),
"transformType" : TransformType.TRANSLATION_DISTANCE,
>> Here>> "transformDirection" // Evaluate The direction of the extrude in (id + i + "extrudeNutDown1") ,
"distance" : SubflushExtraDepth * millimeter
});
}
I think this is the last line of fs code preventing this widget working properly so any help appreciated.
Cheers,
Owen S.
Hopefully an easy one this time.
I'm creating a body using an extrude from a sketch.
Having made it I may wish to transform it in the direction of the previous extrude operation.
I can use the qCreatedBy query to grab the body for the entity parameter but am having difficulty evaluating the extrude direction for the "transformDirection" parameter. (If we can't use the extrude direction can we use "normal to the sketch" the extrude was performed with?)
if (definition.SubFlush)
{
transform(context, id + i, {
"entities" : qCreatedBy(id + i + "extrudeNutDown1", EntityType.BODY),
"transformType" : TransformType.TRANSLATION_DISTANCE,
>> Here>> "transformDirection" // Evaluate The direction of the extrude in (id + i + "extrudeNutDown1") ,
"distance" : SubflushExtraDepth * millimeter
});
}
I think this is the last line of fs code preventing this widget working properly so any help appreciated.
Cheers,
Owen S.
Business Systems and Configuration Controller
HWM-Water Ltd
HWM-Water Ltd
Tagged:
0
Best Answers
-
ilya_baran Onshape Employees, Developers, HDM Posts: 1,210You can't ask the extrude direction because the solid (mostly) doesn't remember it (imagine a cube -- it could've been extruded in any of three directions). If you really need it, qCapEntity is a good starting point to look, but that may not be reliable if the caps are not planes perpendicular to the extrude direction.
In reality, if you have the sketch, you most likely want to pass qCreatedBy(sketchId) to evOwnerSketchPlane and take the resulting normal. Or just keep the sketch plane around if you're creating it in the same feature.Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc5 -
lemon1324 Member, Developers Posts: 225 EDUThis is for your nut pocket feature, right? If so, you already know the direction of the extrude, and you don't have to recalculate it from the geometry; just save the direction when you do the extrude, and then pass it to the function that does the sub-flush offsets.
The other option you have is to extrude the nut back from the base of the pocket, and then you wouldn't need to transform it. (Assuming you're creating the nuts dynamically and not simply importing from a library)
Arul Suresh
PhD, Mechanical Engineering, Stanford University5
Answers
In reality, if you have the sketch, you most likely want to pass qCreatedBy(sketchId) to evOwnerSketchPlane and take the resulting normal. Or just keep the sketch plane around if you're creating it in the same feature.
The other option you have is to extrude the nut back from the base of the pocket, and then you wouldn't need to transform it. (Assuming you're creating the nuts dynamically and not simply importing from a library)
PhD, Mechanical Engineering, Stanford University
As ever there are many ways of getting to the same end result, I was missing an obvious one. All useful to learn from so nothing wasted.
Thanks,
Owen S.
HWM-Water Ltd