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.
can i create a method ?
sjalife
Member, Developers Posts: 24 PRO
i need to create a method , because i need to do some operations into this method ...so, when i call this method, but how can i create a method and how can i call this method?
Tagged:
1
Answers
In FeatureScript, we usually say function instead of method (possibly because there are no objects, but mostly just a style choice). Here is an example of the definition of a helper function in FS:
I may have missed the point of your question though? Are you wondering how to create a feature (a.k.a. a button in the part studio that changes geometry)? This tutorial may help:
https://cad.onshape.com/FsDoc/tutorials/create-a-slot-feature.html
Happy to answer any more question you may have.
yes, now i coulded create a function, but my function returns one string, and i wan to use this string, calling my function that is return a value (String), and according to the value that is returned i do some operation like if(String =="a") { do this} else if (String=="b"} do this.... etc.. how can i call this function inside precondition? for use the value returned and do my operations
The precondition of a feature is used to define the UI it presents when a user clicks the button for the feature. Arbitrary functions cannot be called in the precondition, as no FeatureScript is executed when deciding how the dialog should look. The description of how the precondition becomes a feature dialog is described here:
https://cad.onshape.com/FsDoc/uispec.html
Many examples can be found in the standard library; a relatively simple one is the variable feature:
https://cad.onshape.com/documents/12312312345abcabcabcdeff/w/a855e4161c814f2e9ab3698a/e/357eadcd05424ef4a2360e88
Or the shell feature:
https://cad.onshape.com/documents/12312312345abcabcabcdeff/w/a855e4161c814f2e9ab3698a/e/8ca395d9c7db47e5805098d5
If you share a link to a document with the feature you are working on, it may be easer to provide some guidance.