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.
Re-usable code
john_mcclary
Member, Developers Posts: 3,936 PRO
Is there a way to "#include" or maybe something like 'using' another featurescript?
tried to do : import(path : "onshape/str/sheetMetalStart.fs", version : "920.0"); but that gave me a bunch of errors
I basically want to just expand on "sheet metal model's" pre-conditions. (add a guage and bend radius table)
but I don't want to maintain the rest of the featurescript manually every 3 weeks, if they decide to fix a bug or whatever in the standard library source.
this also applies to many other standard features / custom features which I want the base code, but just a more customized dialog.
I'm probably missing something simple
https://cad.onshape.com/documents/28050bca2b1ddeb0acbab720/w/72369ffa7faabbf84de28ab1/e/227b8ffd6d2196f915165a0d
tried to do : import(path : "onshape/str/sheetMetalStart.fs", version : "920.0"); but that gave me a bunch of errors
I basically want to just expand on "sheet metal model's" pre-conditions. (add a guage and bend radius table)
but I don't want to maintain the rest of the featurescript manually every 3 weeks, if they decide to fix a bug or whatever in the standard library source.
this also applies to many other standard features / custom features which I want the base code, but just a more customized dialog.
I'm probably missing something simple
https://cad.onshape.com/documents/28050bca2b1ddeb0acbab720/w/72369ffa7faabbf84de28ab1/e/227b8ffd6d2196f915165a0d
0
Best Answers
-
MBartlett21 Member, OS Professional, Developers Posts: 2,050 ✭✭✭✭✭I think that sheetMetalStart is already imported, you can just use it like this:
annotation { "Feature Type Name" : "Sheet metal model New" } export const sheetMetalStartNew = defineFeature(function(context is Context, id is Id, definition is map) precondition {...} { // Calculate K-Factor from definition definition.kFactor = (-definition.radius + ((definition.bendAllowance) / (PI / 2))) / definition.thickness; definition.kFactorRolled = definition.kFactor; sheetMetalStart(context, id, definition); });
The code for calculating the K-Factor from the BA is from Wikipedia (It is my implementation of it)5 -
lana Onshape Employees Posts: 706
@john_mcclaryso would these functions need to be exported in SheetMetalStart.fs in order to access them?Yes, so if you can follow @mbartlett21's pattern of "massaging" definition and passing it to sheetMetalStart, that would work much better.5
Answers
Here is my Sheet metal model FS: (it has bend allowance and deduction. It also supports recognizing a part as sheet metal if you extruded it normally.)
https://cad.onshape.com/documents/a39db7615a2a945ffb7076c3
What i'd really like is some way to see what has changed in the Feature Studio in STD (Compare feature for Feature Studios), so as to update my feature easier
IR for AS/NZS 1100
The code for calculating the K-Factor from the BA is from Wikipedia (It is my implementation of it)
IR for AS/NZS 1100
but I have other FS's that only have a couple edits to the standard library. For example "Log Linear Pattern" allows for logarithmic spacing. When they allowed sheet-metal to be linear patterned, I had to copy paste their new code in to the script and add my 2 lines again.
Would be nice to just set overrides to the pre-condition.
Your errors are coming from a couple sources. Firstly, You don't ned to copy SMProcessType, SMCornerStrategyType etc. because they are already defined and exported out of sheetMetalStart.fs. It's saying 'dupicate top level symbol' because you are trying to define something that's already been defined.
Next, the whole feature is errored because you need to import 'sheetMetalUtils.fs' (same syntax as how you imported 'sheetMetalStart.fs'). You'll notice that hovering over this highlight says 'defineSheetMetalFeature not found'. That function is defined and exported by sheetMetalUtils module.
You actually don't need the sheetMetalStart.fs import, since geometry.fs exports that module:
https://cad.onshape.com/documents/12312312345abcabcabcdeff/w/a855e4161c814f2e9ab3698a/e/b9a58548f6cc4fa7acef723a
@john_mcclary , Welcome to sheet metal development team
@john_mcclary