Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:

  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. 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_LaJosy_La Member Posts: 82 ✭✭
edited September 2016 in FeatureScript
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.


Comments

  • lougallolougallo Member, Administrator, Moderator, Onshape Employees, Developers Posts: 1,675
    @Josy_La Like every language, they are unique.  The fundamentals might be similar with functions, variables and how to do things like loops or if statements but they all do it differently.  Visual Basic is a language originally designed for Windows and is typically used for older Windows programs.  Similar I cannot paste in FeatureScript into VB and have it run.  Now I am sure there would be someone out there that might help with a way to port a VB action to FeatureScript but like most porting to a different language, it only takes you so far.

    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... ;-)
    Lou Gallo / PD/UX - Support - Community / Onshape, Inc.
  • mahirmahir Member, Developers Posts: 862 ✭✭✭✭
    @Josy_La, FeatureScript is most similar to JavaScript. You'd get similar results if you tried to copy a VB macro into a JS.

    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.
  • bruce_williamsbruce_williams Member, Developers Posts: 349 PRO
    @mahir@lougallo ;

    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.


  • Jake_RosenfeldJake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,381
    Hey Bruce!

    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 )
    Jake Rosenfeld - Modeling Team
  • bruce_williamsbruce_williams Member, Developers Posts: 349 PRO
    Hi Jake,  Thanks for the explanation.  Yes, I want to learn programming and have been surprised how tough it is.  The Onshape tutorial covers a lot of ground and the FS editor is good.  Just need to make more time to work through it.  I do appreciate getting pointed in the right direction!  Codecadamy look good and the article comparing Java and JavaScript is helpful.
  • billy2billy2 Member, OS Professional, Mentor, Developers Posts: 1,300 PRO
    edited January 2017
    value with units

    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.


  • bruce_williamsbruce_williams Member, Developers Posts: 349 PRO
    edited January 2017
    @billy2
    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!!
Sign In or Register to comment.