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.
FeatureScript not for dummies
Josy_La
Member Posts: 82 ✭✭
Hi to all,
I won't hide the fact that I don't understand programming and never wanted to learn. I prefer leaving this task to others who really love it. But since I had a bit of time to spare I thought I could easily copy paste one of our visual basic code and magically (okay maybe with a minimum of tweaking) would run smooth in OS. Of course it is not the case otherwise I would not be writing this post. Even if lines with errors are flagged when you don't have any knowledge it is impossible to know what is the solution if any.
I'm not looking for a solution just wanted to share my thoughts on FeatureScript since it's frequently said that it can be created in a matter of minutes. But like any other language remains a hopeless challenge for people like me.
I won't hide the fact that I don't understand programming and never wanted to learn. I prefer leaving this task to others who really love it. But since I had a bit of time to spare I thought I could easily copy paste one of our visual basic code and magically (okay maybe with a minimum of tweaking) would run smooth in OS. Of course it is not the case otherwise I would not be writing this post. Even if lines with errors are flagged when you don't have any knowledge it is impossible to know what is the solution if any.
I'm not looking for a solution just wanted to share my thoughts on FeatureScript since it's frequently said that it can be created in a matter of minutes. But like any other language remains a hopeless challenge for people like me.
0
Comments
With that being said, the goal with FeatureScript was to introduce a language that could be written to customize and automate tasks in Onshape without having to setup a programming environment... all in the browser. We hope to continue to improve our documentation, examples and other resources to assist those who what to build their own tools but it will probably always require someone with some programming experience or a desire to learn programming concepts.
I think it is awesome you took a stab at it and if you are looking for something I am sure asking the community they might deliver... ;-)
Think of FeatureScript as way to build features. VB is more for automation of repetitive tasks. FS let's you go back and edit custom features because they get rebuilt just like any other feature. VB doesn't do that. Unless it's set to run every time you open a file, once the VB macro does its thing, that's it; it's done.
I am working to learn Feature Script and it is pretty exciting stuff. I have found OnShape's FS tutorial and documentation good for someone with a strong understanding of common scripting.
However, I find some of the concepts & terms challenging for someone like me without strong a programming background. Seems like a general scripting knowledge is expected. @mahir mentioned that Feature Script is most similar to Java Script and I am working on learning Java Script along with FS.
My questions -
- Am I on the right track with Java Script?
- What type of JS applications would best parallel FS?
- What are best resources for learning Java Script? I have used Kahn Academy and Microsoft Virtual Academy. I think both are good, yet the tutorial style leaves me without references and examples. I want to get book(s) and/or website documents.
It sounds like you're really interested in getting into programming! JavaScript and FeatureScript have similar syntax, but I wouldn't say their uses overlap too much. In general, JavaScript is used to make a website dynamic (animations, buttons, communicating information with a server). There are some cases where JavaScript would be run outside of a web page (ex: node.js allows a programmer to write a web server in JavaScript), but in a vast majority of cases JavaScript will just be the driving force behind user interaction in a web page.
You may like this tutorial to see what JS is good for: https://www.codecademy.com/courses/web-intermediate-en-jfhjJ/0/1
p.s. super minor nitpick: because Java and JavaScript are both very widely used languages, and very different, it's best not to put a space in 'JavaScript' to avoid confusion. ( http://www.htmlgoodies.com/beyond/javascript/article.php/3470971 )
In onshape a variable is a super variable and differs from other languages. It knows the units a variable has, therefore you can't add an area + length. This makes no sense.
Something that works, for instance:
A=1in;
B=2in;
C=A+B;// equals 3in
Also
A=1in;
B=1mm;
C=A+B;// equals 1.040in, you don't need to worry about units
To an extreme:
A=vector1;
B=vector2;
C=vector1+(vector2-vector1)/2; // equals mid way between these vectors, ie.. midpoint
After a while, you begin to like programming in featurescript.
One other thing, as a sublime user, I really like the featurescript editor. It'll help you compose
quickly if you let it.
This is a great post! Your examples are very helpful to understand the FS variables. I have been struggling with them; Besides units, the mix of query, vector, definition, etc. are a bit boggling. Gonna keep working on it. Great to have the encouragement from somebody further down the path. Thanks!!