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 set normal direction for a hole?
nikolas_engelhard
Member Posts: 5 ✭
Hey!
I'm trying to start with Feature Script and as first task tried to make a simple cylindrical hole. I let the user select a vertex on a surface, create a skect, draw a circle and then want to extrude a hole. My problem is currently the value for "oppositeDirection". How can I set this value (or the normal) so that the hole is created in the correct direction (aka within the object?)
My project is here (FS Hole just creates a Hole, the other Script should later add a hole for a nut)
https://cad.onshape.com/documents/6ce9fea6c453d84514e40287/w/85a62743a478dd09df2ba77d/e/c6922fdc600fcf2d5382534c
To test my Script, I create two rectangles on the top plane and extruded them in opposite directions (inside positive and negative z-space). I have to use different values for "oppositeDirection" to make the two holes.
In the current version, the user can set a flag ("invert normal') but of course this should not be the case in the final version.
Nikolas
I'm trying to start with Feature Script and as first task tried to make a simple cylindrical hole. I let the user select a vertex on a surface, create a skect, draw a circle and then want to extrude a hole. My problem is currently the value for "oppositeDirection". How can I set this value (or the normal) so that the hole is created in the correct direction (aka within the object?)
My project is here (FS Hole just creates a Hole, the other Script should later add a hole for a nut)
https://cad.onshape.com/documents/6ce9fea6c453d84514e40287/w/85a62743a478dd09df2ba77d/e/c6922fdc600fcf2d5382534c
To test my Script, I create two rectangles on the top plane and extruded them in opposite directions (inside positive and negative z-space). I have to use different values for "oppositeDirection" to make the two holes.
In the current version, the user can set a flag ("invert normal') but of course this should not be the case in the final version.
Nikolas
Tagged:
0
Comments
So looking at your code, you could try something like this:
"Editing Logic Function" for the feature, which is executed during feature editing and can initialize some feature parameters based on simple analysis. e.g. flip of up-to-face extrude is computed by shouldFlipExtrudeDirection() function in extrude.fs, flip of hole direction - by holeScopeFlipHeuristicsCall in hole.fs . This way in simple case editing logic method guesses right and when it does not, the user can override its decision.
More here: https://cad.onshape.com/FsDoc/uispec.html#editing-logic-function
You are calling 'extrude' with a 'direction' parameter. You'll notice that there is no 'direction' parameter in the 'extrude' documentation:
https://cad.onshape.com/FsDoc/library.html#extrude-Context-Id-map
This is because extrude uses evOwnerSketchPlane internally on its 'entities' input to find the direction.
If you would like to manually specify the extrude direction, you can use opExtrude instead (but this function will not allow you to do the 'operationType' work you are trying to do, so I think 'extrude' is probably the right call to use):
https://cad.onshape.com/FsDoc/library.html#opExtrude-Context-Id-map
I think what you'll want to do is something like the following:
chadstoltzfus@premiercb.com