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 Alternative Extrude Command, using as many OOTB elements as possible.
Jonathan_Hutchinson
Member Posts: 91 PRO
I have created an extrude command which just deals in segmented side cylinders. How could I incorporate all the goodies (in the standard extrude.fs, presumably) so that I'm not reinventing the wheel?
For instance, adding the 'Up To' overloads and so forth would be really helpful. I fell at the first hurdle just trying to add the BoundingType enum as input within a feature precondition:
For instance, adding the 'Up To' overloads and so forth would be really helpful. I fell at the first hurdle just trying to add the BoundingType enum as input within a feature precondition:
annotation { "Name" : "Bounding Type" }
definition.boundingType is BoundingType;
Gives the warning: 'enum used as a parameter must be exported' - which is a bit vague for me. I tried just redeclaring the BoundingType, which autocompletes anyway, so was a bit of a loss there.
Effectively, all that my feature does is specifiy a point, direction via plane input, blind depth (which would be nice to overload) and segments for the sides.
Any help would be greatly appreciated!
Gives the warning: 'enum used as a parameter must be exported' - which is a bit vague for me. I tried just redeclaring the BoundingType, which autocompletes anyway, so was a bit of a loss there.
Effectively, all that my feature does is specifiy a point, direction via plane input, blind depth (which would be nice to overload) and segments for the sides.
Any help would be greatly appreciated!
0
Comments
Starting with a light stroll, before an eventual jog (hopefully), my fix was as follows:
alternatively, just the below also worked:
export import(path : "onshape/std/common.fs", version : "2066.0");
Now, call me old fashioned, but I'm one of those folks who likes to know why they're doing something way, so even just 'import this' can leave me with multiple slightly different interpretations. Even in the course of writing this post I've ended up going to the start and thinking, 'hey, but that contradicts what I thought 5 minutes ago!' my hunch is that exporting all of the importing of common.fs is unnecessarily weighty?
I suppose the notion of exporting an import semantically sounds backwards to me, because I'm importing it for use in a place that I've chosen.
Going back to the extrude, there's a tonne in the extrude command that I certainly don't and won't need to sift through. Does it make sense to be going through copying/pasting/cherrypicking bit's I'd like?
export import(path : "onshape/std/transformCopy.fs", version : "2045.0");
Or:
This is maybe a good exercise for 'importing' the transform function. In 'transformCopy.fs' there are quite a few things I can see that I could try to import. Using Evans advice, my hunch is that I essentially force a certain definition where definition.entities is specified within a duplicate of the transform feature?
For any of them all that has to be paired back is the UI, which you can make yourself. You can still call the full feature function in the code, even if the user doesn't have a chance to edit most of the definition. I made an example called "stupid extrude" which takes away all user control except whether it has draft. You could do this for any feature so you get all of the power and robustness of native features, but can control the UI and perform some additional logic in the code that creates the definition of those features. https://cad.onshape.com/documents/94dffb8d7b5b37a28b775459/w/510169e58d0d699e9cdf0893/e/d40e04a484a681c4cbc09feb
@NeilCooke
Thanks, I'll remember that method.
With the extrude command, which has a lot of permutations, I'm trying to work out the best way of creating the maps based on conditionals from the input.
Am I right in thinking that I can't 'blanket' all the fields, even if one isn't relevant for the condition in mind? In the below example, I've added all the 'second direction bound entity' types, knowing in advance that only one of these will be populated based upon the 'secondDirectionBound' choice. Does that make sense? From my fiddling around so far, I am seeing that having fields (that I expect will be undefined) tends to not be working.
The alternative to this looks like it will be a lot of conditionals and maybe some map merging to have a bit less repeated code.
OR: in the feature action, just pass extrude(context, id, definition), and that means only the map fields used based on input are passed?
which should be based on a pre-defined variable called definition containing a map. Or it could be called extrudeDef or anything you want so it doesn't get confused with your main feature definition.
The extrude command is proving tough to get that right balance of simplification but also all the good options, but I've made headway.