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.
Absolute beginner understanding of FeatureScript.
Hi everyone,
I'm a user of Onshape and I'm interested in learning FeatureScript. I've gone through most of the courses available, but I'm still struggling to understand the nuts and bolts of the language.
The courses I've taken generally assume that the learner has some prior knowledge of coding, but I don't have any. I'm looking for a course that will explain every comma, space, and function in FeatureScript in a way that I can understand.
I'm willing to put in the time and effort to learn, but I need a course that will give me a solid foundation in the language. Does anyone have any recommendations?
Thanks in advance for your help!
Comments
-
Definitely make sure you've done this one. It's great:
https://learn.onshape.com/courses/featurescript-fundamentals
This is also kind of fun:
https://learn.onshape.com/learn/article/teach-programming-with-onshape
If you don't have any prior knowledge of coding, before you dive into FeatureScript, it might be smart to start with a basic JavaScript course like this one:
https://www.codecademy.com/learn/introduction-to-javascript
2 -
I definitely agree with the things Matt lists above definitely including some JS tutorials. I also learned a lot from these tutorials from cadjunkie.com (first ones free, and later one paid, but worth it), and I've been told people got some something from this video I made about using Featurescript to create variables (before Variable Studios were a thing)2
-
Thank you, Matt and Evan, for providing me with all this content. I will check it out and let you know what I think. I appreciate your help!0
-
@M_Arc when you get stuck, reach back out on the forums and we will help you out. Evan and Konstantin helped me out back when I first started. There are lots of willing FeatureScript devs around.
RENDERCAD
rendercad.ai - Photorealistic product rendering.
▚▞▚▞▚▞▚▞▚
________________________________________________________________________0 -
All I had going for me was that I'd just recently learned any of it myself so it was fresh, haha. Now you're off doing professional code and leaving me in the dust.MichaelPascoe said:
@M_Arc when you get stuck, reach back out on the forums and we will help you out. Evan and Konstantin helped me out back when I first started. There are lots of willing FeatureScript devs around.1 -
@M_Arc not knowing anything about JavaScript was a huge hurdle for me too, but I'm two months into FeatureScript and loving it - hang in there and don't forget about your friends here in the forum!0
-
Do you think it would be possible to write a program for tube steel or weldments that would generate part numbers based on the length and type of tube it is?
0 -
@M_Arc yes, this is possible. I believe the feature set you are looking for will be Frames. The Cutlist feature can calculate all of the frame data such as length, frame profile, etc... You can copy the cutlist or frames feature then modify it to add part numbers to your frames.
Here is an example of how to copy and modify the Frame feature so that it generates a part number and part name based on profile and longest edge of the frame:
https://cad.onshape.com/documents/0470f1119a2d2fc1b2e6c761/w/6bb4d328e5af27a714045feb/e/f4cf48ae649f809b73b6...
After copying the Frame features code, I added the following to the doFrame() function. The added code will find the selected frame profile description, then search for the longest edge of each frame. Once it finds the longest edge of a frame, it sets the properties for that frame.var description = profileData["profileAttribute"]["Description"]; for (var i = 0; i < size(sweepData.sweepBodies); i += 1) { const body = sweepData.sweepBodies[i]; const edges = qOwnedByBody(body, EntityType.EDGE); const longestEdge = evaluateQuery(context, qLargest(edges))[0]; const length = evLength(context, { "entities" : longestEdge }); setProperty(context, { "entities" : body, "propertyType" : PropertyType.PART_NUMBER, "value" : description ~ "_" ~ toString(roundToPrecision(length.value, 2)) }); setProperty(context, { "entities" : body, "propertyType" : PropertyType.NAME, "value" : description ~ "_" ~ toString(roundToPrecision(length.value, 2)) }); setProperty(context, { "entities" : body, "propertyType" : PropertyType.APPEARANCE, "value" : color(1, 1, 1) }); }
RENDERCAD
rendercad.ai - Photorealistic product rendering.
▚▞▚▞▚▞▚▞▚
________________________________________________________________________3 -

Wow, this is awesome! Thank you so much! This is going to help so much.
What I circled in red, is that the length? If so how do I get it in inches?
0 -
Looks like the DM was quicker and this was just now posted. I'll quote the DM answer for any future users to see:Happy to help. FeatureScript keeps all values with units in meters behind the scenes. The number you circled is the unitless value length.value on lines 281 and 287 in the Frame PN feature studio. For large feature studios Ctrl + F will let you search quickly for exact portions of code. You can multiply length.value times (meter / inch) to get inches instead of meters. Remember, usually you would not need to convert, but since we are using a unitless value for the name and part number, we have to convert.
RENDERCAD
rendercad.ai - Photorealistic product rendering.
▚▞▚▞▚▞▚▞▚
________________________________________________________________________0



