The Featurescript skill every serious Onshape user should have

  Рет қаралды 12,499

Ovyl

Ovyl

Күн бұрын

Пікірлер
@johanviljoen4704
@johanviljoen4704 2 жыл бұрын
This video is the most underrated Onshape video ever! This is really good stuff. Thanks!
@ovyl
@ovyl 2 жыл бұрын
Glad you think so!
@RajinderYadav
@RajinderYadav Жыл бұрын
I just discovered something new about Onshape I didn't even know was possible. I truly appreciate you sharing these advanced concepts in as easy way to follow.
@ovyl
@ovyl Жыл бұрын
You are so welcome!
@jreamer0
@jreamer0 Жыл бұрын
Quality Onshape Content. Please keep going.
@ovyl
@ovyl Жыл бұрын
Thanks, will do!
@dbuezas
@dbuezas 3 ай бұрын
I keep forgetting heated insert hole diameters, will definitely put them in a custom feature. Thanks for these advanced tips!
@johnrobinson3642
@johnrobinson3642 2 жыл бұрын
Thanks so much for sharing this, this has been a great help/ I was a programmer in a past life and have been wanting to dabble in FS, and you've just shown me how to get started. Thanks!
@ovyl
@ovyl 2 жыл бұрын
Mission accomplished 😎
@chadoude
@chadoude 3 жыл бұрын
Quick reason why you need to type * millimeter is because 90mm would be interpreted as a variable (because it is a combination of letters and numbers) and just typing 90 would be interpreted as an integer. The * symbol is overloaded in the architecture of FeatureScript to not only perform necessary conversions (especially when working in other values, like inches) but also to recast the type of assigned variable to a ValueWithUnits data type.
@ovyl
@ovyl 3 жыл бұрын
Makes sense, thanks!
@1xicaradcaf
@1xicaradcaf 2 жыл бұрын
Thank you very much for the video. Ther is not much content for feature script out there, this was very helpful
@ovyl
@ovyl 2 жыл бұрын
Glad it was helpful! Now that Onshape launched their Variable Studio, this workflow is pretty much obsolete for creating global variables, but it's still a helpful primer on FeatureScript.
@MarcelRobitaille
@MarcelRobitaille 3 жыл бұрын
This is a great video. I am familiar with featurescipt, but I never thought to use it like this.
@ovyl
@ovyl 3 жыл бұрын
Thanks! Glad to hear it's useful to people who already know their way around.
@cde7850
@cde7850 3 жыл бұрын
Thanks for your lesson. it's very helpful!
@ovyl
@ovyl 3 жыл бұрын
Glad you found it helpful.
@winddrandd1092
@winddrandd1092 3 жыл бұрын
great video, helped me out a lot - thank you!
@evanreese8592
@evanreese8592 3 жыл бұрын
Wohoo! glad it helped
@HackerSpace-ng2jz
@HackerSpace-ng2jz 2 ай бұрын
Thank you!
@SuperMaukam
@SuperMaukam Жыл бұрын
This is gold!
@ovyl
@ovyl Жыл бұрын
Thanks! We have aspirations to do more FeatureScript related videos.
@dbuezas
@dbuezas 3 ай бұрын
​@@ovylyes please!!!
@StuartRobinson123
@StuartRobinson123 8 ай бұрын
thank you!
@ovyl
@ovyl 8 ай бұрын
Welcome!
@EPeltzer
@EPeltzer 2 ай бұрын
This is one of the very few channels that I actually slow down to like 0.75 speed. Maybe I'm just dense but I would request that you try to slow down a bit both on the screen and verbally. Really enjoy the content though thank you.
@johnmcclary754
@johnmcclary754 3 жыл бұрын
Nice video
@ovyl
@ovyl 3 жыл бұрын
Thanks, John!
@aeropasta
@aeropasta 2 жыл бұрын
Good stuff, thanks
@ovyl
@ovyl 2 жыл бұрын
Glad it was helpful! Now that Onshape launched their Variable Studio, this workflow is pretty much obsolete for creating global variables, but it's still a helpful primer on FeastureScript.
@wpegley
@wpegley 3 жыл бұрын
I need a dynamic part, referenced with measure distance that updates in Assemblies and annimation. IE hoist wirerope
@ovyl
@ovyl 3 жыл бұрын
Hi Warren, are you trying to animate a rope winding up on a spool? If so, I'm not sure how to do it in Onshape.
@jimmulawin6124
@jimmulawin6124 3 жыл бұрын
That's amazing! how about linking data from csv to a part studio property?
@evanreese8592
@evanreese8592 3 жыл бұрын
A prolific Onshaper, John, made this feature that turns a csv into variables (I made the icon for it though 😄). Give it a shot. cad.onshape.com/documents/75dfbb9091b5bea038398789/v/2d6edbf047281ce828b3923f/e/97a921379d1437bdaef7fcdf
@jimmulawin6124
@jimmulawin6124 3 жыл бұрын
@@evanreese8592 that was simply amazing :) thanks, wanted to learn this lesson. Will you feature some contents like this?
@evanreese8592
@evanreese8592 3 жыл бұрын
@@jimmulawin6124 I'd like to make some content about my favorite custom features from myself and others at some point. Not sure when though.
@ryanblackwood1753
@ryanblackwood1753 2 жыл бұрын
Do you know how to script the 'Variable type' and 'Description'? I've done a lot of searching, but haven't found anything on how to get the script to populate the 'Variable type' and 'Description' in the part studio I'm working in. I found another example of this "Global Variable" script a while ago and it's been crazy helpful, but it would be nice if I didn't have to pull up my script to see what each variable is. I currently have over 300 variables in my script that I use across 3 documents that are different components of the same giant project. So I use a ton of shorthand in my names to keep them less than 8 characters if possible, but it also means I end up with a lot that are very similar and I forget which is which without looking at the comments in my script. My version uses ' "name" : #*inch, //description ' for each variable. I'm hoping it's only a matter of punctuation and a minor modification to the for loop to do this.
@ovyl
@ovyl 2 жыл бұрын
I'm not sure how to set the types, but you can add a description fairly simply. Just add a comma and string to the variable as you set it: setVariable(context is Context, "variableName", 1*inch, "This is the description of the variable."); Here's an actual example: cad.onshape.com/documents/383c06e24837a21d66cc58c3/w/ef1f83ea2ab84c9118f8e630/e/5d928f70adafaa7ecb4b294b Since your 300+ variables are is already setup, with the //comments, maybe there would be a clever regex script you could use in the find/replace tool to automate it. It probably wouldn't save you time if you don't already have regex experience, but you'd learn something new. For example, starting with a variable like this: setVariable(context, "myVariable", 1*inch); //comment In the find/replace dialogue in the feature studio, with the regex search on (click the .* button), I searched "([)][^)]*[//])(.+)" and replaced it with ", "$2" );" it produces this, instead: setVariable(context, "myVariable", 1*inch, "comment" );
@ryanblackwood1753
@ryanblackwood1753 2 жыл бұрын
@@ovyl Thanks for the quick reply. It says I don't have permissions to that workspace. I tried the example you give, but it's giving me an error and failing to generate when I try to put a description My Code: const VALUES = { "Name" : # * inch, //This is my existing variable "Name" : # * inch, "1st description attempt", //This causes an error, says looking for ": " "Name" : # * inch : "2nd description attempt", //This causes an error, says looking for ", " "Name" : # * inch, "3rd description attempt" //This causes an error, says looking for ", " }; annotation { "Feature Type Name" : "Global Dimensions" } export const setGlobals = defineFeature(function(context is Context, id is Id, definition is map) precondition { } { for (var value in VALUES) setVariable(context, value.key, value.value, value.description); });
@ovyl
@ovyl 2 жыл бұрын
@@ryanblackwood1753 oh, since you're declaring them into a map and iterating over them, you'll have to actually make each entry contain the variable value and the comment. One way is to put the variable value and comment string into an array like this, and address them in the loop using a 0 or 1 var v = {}; v.varOne = [1*inch, "this string describes variables one"]; v.varTwo = [2*inch, "this string describes variables two"]; for (var key, value in v) { setVariable(context, key, value[0], value[1]); }
@ovyl
@ovyl 2 жыл бұрын
cad.onshape.com/documents/631ca2ee3804e7ad40c1f88d/w/141131493bff582c39f33431/e/37fe516070fc2a03f750b833
@ryanblackwood1753
@ryanblackwood1753 2 жыл бұрын
@@ovyl This worked great! Pretty easy to replace all and modify my existing script. Much Appreciated!
@mko9377
@mko9377 3 жыл бұрын
Hi Ovyl. can we have a summary list of the declared variables? and exported / linked in TXT or CSV? of the type: varname; value Default, written value - what if I wanted to load these variables in a script on another document by preloading the set data? Thank you very much we are hungry for clearly described examples.
@ovyl
@ovyl 3 жыл бұрын
There are two bits of code that might work for what you need, neither of which we had much to do with. I think they'd work well together too. Here's a Custom Table that can read all of the variables in a part studio and display them: cad.onshape.com/documents/67c66cbcd55f1cb2f3401e45/v/040b95f12cfdfa350c5f45dd/e/4e3ec23e83c088c9b8a60f29 Here's the CSV variables feature for converting an imported CSV to a list of variables: cad.onshape.com/documents/75dfbb9091b5bea038398789/v/2d6edbf047281ce828b3923f/e/97a921379d1437bdaef7fcdf With that, you should just need to right click the imported CSV tab and hit "update" and it ought to push it to the features using it as long they're in the same document. Across different documents you'll have to version the doc with the CSV and update the linked doc version in the CSV features manually in the other documents.
@mko9377
@mko9377 3 жыл бұрын
@@ovyl How can I "retrieve" them for another document so that they are usable with #height ? thank you so much
@ovyl
@ovyl 3 жыл бұрын
@@mko9377 They are treated just like any other custom feature. See the help doc here on how to add it. Note it can only link to a version, so you'll have to make at least one version once you want to link to another doc. cad.onshape.com/help/Content/customfeature.htm
@mko9377
@mko9377 3 жыл бұрын
@@ovyl I meant: how can i retrieve the variables inserted in your fs "Global variables" to use them in another fs that i launch later? example: 1) launch "global variables" and imposed on precondition: isLengh (definition.hight, LENGT .....) 2) launch "my fs" how do i retrieve the "definition.hight" that i set to "global variables" without redefining it? Thanks for your patience and sorry if I was not clear. ... I also tried to ask on the forum .. but there the answers are cryptic .. and for us at the beginning this is a problem.
@ovyl
@ovyl 3 жыл бұрын
@@mko9377 Ah, I think understand. I don't know of a good way to do that. If you want them used in several places, then set them in the code, and don't set them with the UI. If you feel that you absolutely must set them in the feature UI and use them multiple places, then check out the Super Derive custom feature, which can pull variables from one part studio to another. That's not what I'd do though.
@StuartRobinson123
@StuartRobinson123 8 ай бұрын
post a link to one of your global variables featurescript examples?
@ovyl
@ovyl 8 ай бұрын
just added it to the video description
@TROYOSTRANDER
@TROYOSTRANDER Ай бұрын
Thanks for tricking me. 😂❤
@StuartRobinson123
@StuartRobinson123 8 ай бұрын
do you still use this approach now that variable studio exists for global variables, and why or why not? i could see how it could possibly still be superior
@ovyl
@ovyl 8 ай бұрын
Default to Variable Studio where possible. Accessing them in an assembly is a huge win. There are some cases where FS is still better just for declaring variables. For one, anything that's going to need a lot of calculation is a good candidate for featurescript. One example from the past is trying to figure out the diameter of a roll of material based on the total length. One way to solve it is in a for loop where the "circumference" increases with each revolution, so that was done in a custom feature. Another case could be if you want to have any user inputs with the variables. For example, we have magnets we always stock, and want variables for the holes that they fit in, but the clearance needed would change for a 3D print vs a steel part. So we have a custom feature with the nominal size hard coded, and the clearance as a user input. Variable Studio doesn't currently handle functions either, so if you wanted to write a #remap() function that takes a range of numbers (say 14-to-78 range) and remaps them to the 1-to-0 range I'd do it with FS.
@StuartRobinson123
@StuartRobinson123 8 ай бұрын
@@ovyl super helpful thank you!! i'm a noob still trying to wrap my head around everything so this is great
@tophychris
@tophychris 2 жыл бұрын
Very important, I was the 69th person to like this video. Also great video thank you
@ovyl
@ovyl 2 жыл бұрын
Thanks for doing your part, Chris
@MarcelRobitaille
@MarcelRobitaille 3 жыл бұрын
What happened to your name?
@ovyl
@ovyl 3 жыл бұрын
upgrade 😎
@MSWindman
@MSWindman 4 ай бұрын
As a retired developer, I cringe at the global variables.
How to Branch and Merge in Onshape
12:43
Ovyl
Рет қаралды 5 М.
31 Advanced Sketch Tips and Tricks for Onshape
19:18
Ovyl
Рет қаралды 50 М.
It’s all not real
00:15
V.A. show / Магика
Рет қаралды 20 МЛН
Cat mode and a glass of water #family #humor #fun
00:22
Kotiki_Z
Рет қаралды 42 МЛН
The evil clown plays a prank on the angel
00:39
超人夫妇
Рет қаралды 53 МЛН
Drive checkboxes and text with expressions in Onshape
16:21
3 Levels of CAD quality, and when to use them.
11:50
Ovyl
Рет қаралды 1,6 М.
Escape from the claws of the corporate CAD overlords - with FreeCAD!
16:54
Made with Layers (Thomas Sanladerer)
Рет қаралды 359 М.
Sketch constraints in detail - 3D design for 3D printing pt10
15:25
Teaching Tech
Рет қаралды 42 М.
Model Tour: Paddle-board Grip
37:01
Ovyl
Рет қаралды 4,8 М.
Designing Parts Together (In-Context Features)
4:58
Onshape
Рет қаралды 33 М.
Parts that fit odd shaped objects - 3D design for 3D printing pt4
15:40
Designing a Hex Nut (Tutorial)
12:53
Onshape
Рет қаралды 23 М.
An introduction to Raymarching
34:03
kishimisu
Рет қаралды 161 М.