This video is the most underrated Onshape video ever! This is really good stuff. Thanks!
@ovyl2 жыл бұрын
Glad you think so!
@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 Жыл бұрын
You are so welcome!
@jreamer0 Жыл бұрын
Quality Onshape Content. Please keep going.
@ovyl Жыл бұрын
Thanks, will do!
@dbuezas3 ай бұрын
I keep forgetting heated insert hole diameters, will definitely put them in a custom feature. Thanks for these advanced tips!
@johnrobinson36422 жыл бұрын
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!
@ovyl2 жыл бұрын
Mission accomplished 😎
@chadoude3 жыл бұрын
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.
@ovyl3 жыл бұрын
Makes sense, thanks!
@1xicaradcaf2 жыл бұрын
Thank you very much for the video. Ther is not much content for feature script out there, this was very helpful
@ovyl2 жыл бұрын
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.
@MarcelRobitaille3 жыл бұрын
This is a great video. I am familiar with featurescipt, but I never thought to use it like this.
@ovyl3 жыл бұрын
Thanks! Glad to hear it's useful to people who already know their way around.
@cde78503 жыл бұрын
Thanks for your lesson. it's very helpful!
@ovyl3 жыл бұрын
Glad you found it helpful.
@winddrandd10923 жыл бұрын
great video, helped me out a lot - thank you!
@evanreese85923 жыл бұрын
Wohoo! glad it helped
@HackerSpace-ng2jz2 ай бұрын
Thank you!
@SuperMaukam Жыл бұрын
This is gold!
@ovyl Жыл бұрын
Thanks! We have aspirations to do more FeatureScript related videos.
@dbuezas3 ай бұрын
@@ovylyes please!!!
@StuartRobinson1238 ай бұрын
thank you!
@ovyl8 ай бұрын
Welcome!
@EPeltzer2 ай бұрын
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.
@johnmcclary7543 жыл бұрын
Nice video
@ovyl3 жыл бұрын
Thanks, John!
@aeropasta2 жыл бұрын
Good stuff, thanks
@ovyl2 жыл бұрын
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.
@wpegley3 жыл бұрын
I need a dynamic part, referenced with measure distance that updates in Assemblies and annimation. IE hoist wirerope
@ovyl3 жыл бұрын
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.
@jimmulawin61243 жыл бұрын
That's amazing! how about linking data from csv to a part studio property?
@evanreese85923 жыл бұрын
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
@jimmulawin61243 жыл бұрын
@@evanreese8592 that was simply amazing :) thanks, wanted to learn this lesson. Will you feature some contents like this?
@evanreese85923 жыл бұрын
@@jimmulawin6124 I'd like to make some content about my favorite custom features from myself and others at some point. Not sure when though.
@ryanblackwood17532 жыл бұрын
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.
@ovyl2 жыл бұрын
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" );
@ryanblackwood17532 жыл бұрын
@@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); });
@ovyl2 жыл бұрын
@@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 This worked great! Pretty easy to replace all and modify my existing script. Much Appreciated!
@mko93773 жыл бұрын
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.
@ovyl3 жыл бұрын
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.
@mko93773 жыл бұрын
@@ovyl How can I "retrieve" them for another document so that they are usable with #height ? thank you so much
@ovyl3 жыл бұрын
@@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
@mko93773 жыл бұрын
@@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.
@ovyl3 жыл бұрын
@@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.
@StuartRobinson1238 ай бұрын
post a link to one of your global variables featurescript examples?
@ovyl8 ай бұрын
just added it to the video description
@TROYOSTRANDERАй бұрын
Thanks for tricking me. 😂❤
@StuartRobinson1238 ай бұрын
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
@ovyl8 ай бұрын
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.
@StuartRobinson1238 ай бұрын
@@ovyl super helpful thank you!! i'm a noob still trying to wrap my head around everything so this is great
@tophychris2 жыл бұрын
Very important, I was the 69th person to like this video. Also great video thank you
@ovyl2 жыл бұрын
Thanks for doing your part, Chris
@MarcelRobitaille3 жыл бұрын
What happened to your name?
@ovyl3 жыл бұрын
upgrade 😎
@MSWindman4 ай бұрын
As a retired developer, I cringe at the global variables.