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.

NEW Video series: Expressions in Onshape

EvanReeseEvanReese Member, Mentor Posts: 2,572 PRO

Onshape does a good job at blurring the lines between CAD and code without being overwhelming for beginners. One way this happens is by allowing access to FeatureScript functions in any input field. In this series I'm covering pretty much everything I know about it from basic to advanced. Videos 1 and 2 are out now with another 4 or so on the way.

Part 1: Math and Units

Part 2: Number manipulation

Evan Reese
The Onsherpa | Reach peak Onshape productivity
www.theonsherpa.com

Comments

  • Ste_WilsonSte_Wilson Member Posts: 517 EDU

    Will have to watch! Thanks for putting this together.

  • MichaelPascoeMichaelPascoe Member Posts: 2,561 PRO
    edited September 9

    Dope!

    This is a much needed topic. Opens up so many possibilities. Nice job Evan!


    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   Learn How to FeatureScript Here 🔴
  • GWS50GWS50 Member Posts: 468 PRO

    Thank you, for a non-coder this is really useful.

  • chadstoltzfuschadstoltzfus Member, Developers, csevp Posts: 163 PRO

    Love this mentality and it makes so much sense with what you mentioned at the end of video three, how Onshape is also tricking us all to code by using a CAD system. I 100% agree that the sooner people realize this the sooner they can become a CAD magician.

    Applications Developer at Premier Custom Built
    chadstoltzfus@premiercb.com
  • S1monS1mon Member Posts: 3,605 PRO

    I just watched #4 (at 2x).

    These are great. I know that things like this can be done, in theory, but seeing actual applications and examples is really powerful.

    Simon Gatrall | Product Development Specialist | Open For Work

  • EvanReeseEvanReese Member, Mentor Posts: 2,572 PRO

    Thanks, Simon! I think I didn't do maps justice here, but might add a bonus in the next one if I can think of a good case to show.

    Evan Reese
    The Onsherpa | Reach peak Onshape productivity
    www.theonsherpa.com
  • S1monS1mon Member Posts: 3,605 PRO

    Maps are a bit weird. I understand some of their uses in FeatureScript, but as an end user I'm not as sure where they would come into play, other than perhaps some sort of configuration tool.

    Simon Gatrall | Product Development Specialist | Open For Work

  • EvanReeseEvanReese Member, Mentor Posts: 2,572 PRO

    if they'd autocomplete with their keys as you type they'd immediately become more useful as a way to group related variables. That's the one thing keeping me from using them that way.

    Evan Reese
    The Onsherpa | Reach peak Onshape productivity
    www.theonsherpa.com
  • Caden_ArmstrongCaden_Armstrong Member Posts: 321 PRO

    Maps are important for "object oriented programming", or just structured data. Data doesn't just exist, but the value belongs to something.
    In the context of just the feature tree (no featurescript) generating the data is probably the hindrance to it being useful. But knowing how to reference the data might useful if you were to have a FeatureScript generate the data.

    For example, if you had a featurescript generate a series of objects (lets say boxes). Each has a property, length,width,height. As named variables, for N boxes, you'd have to create each variable and give it a unique name, like "Height_1", "Height_2". Which doesn't seem bad until you see downstream effects.

    But if you created a variable that had an array of maps - where each map has the properties of that specific box. The properties of each box could be easily indexed and referenced.
    box[ i ].height is a lot easier and more flexible than trying to reference "Height_i". The height of the ith box could be an input, but the indexed box could be configured, and its infinitely scalable.

    www.smartbenchsoftware.com --- fs.place --- Renaissance
    Custom FeatureScript and Onshape Integrated Applications
  • Konst_ShKonst_Sh Member Posts: 74 PRO

    In fact individual part studio variables are already equivalent of key-value pairs in the map. The map is only required if you need to dynamically add or remove keys, or ensure key uniqueness. Also in some cases it is handy to check equality on maps since they not depending on order, but thats unlikely to be used for normal modeling

  • EvanReeseEvanReese Member, Mentor Posts: 2,572 PRO

    Yep, great clarity. You're both hitting on why I struggle to come up with a believable use-case that doesn't require any "real" featurescript coding. When coding an actual feature they're indispensable, of course.

    I really would use it in Variable features like this though though if it autocompleted the contents, just as a way to organize my variables better. It could be used to create something resembling a file path so you could drill down to the right variable without being hit by all variables at once for autocomplete options. I use a lot of variables.

    For now all I've got is "you can do this! neat right? Any idea what you'd do with it?"

    Evan Reese
    The Onsherpa | Reach peak Onshape productivity
    www.theonsherpa.com
Sign In or Register to comment.