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 access to complete material properties and the Onshape Material Library

Corey
Corey Member Posts: 23 EDU

I may have originally posted this in the wrong forum. I'm a bit surprised by the engagement.

https://forum.onshape.com/discussion/31431/featurescript-access-to-complete-material-properties-and-the-onshape-material-library#latest

I am a mentor for a FIRST Robotics team, and we recently started exploring Onshape Simulation. One of the first issues we encountered was that parts created by many of our custom FeatureScripts are missing the material data needed for simulation.

Our custom features already assign materials such as Aluminum 6061, but FeatureScript currently allows us to populate only the material name and density:

var myComponentMaterial is Material =
        material("Aluminum - 6061", 2.72 * gram / centimeter ^ 3);

setProperty(context, {
        "entities" : myBody,
        "propertyType" : PropertyType.MATERIAL,
        "value" : myComponentMaterial
});

After reviewing the FeatureScript documentation, it appears that density is the only material property currently exposed through the API. Consequently, the material assigned by FeatureScript does not include the additional properties required for simulation:

  • Poisson’s ratio
  • Young’s modulus
  • Tensile yield strength
  • Ultimate tensile strength
  • Compressive yield strength
  • Ultimate compressive strength

For example, the standard Onshape Material Library entry for Aluminum 6061 contains all these fields, but a FeatureScript-created material with the same name and density is not linked to that library entry. The user must manually reassign the material before the part is ready for simulation.

I would like to suggest exposing the complete material-property list through FeatureScript and/or providing a way to assign a material directly from the Onshape Material Library.

The library-assignment syntax might look something like this:

var myComponentMaterial is Material =
        onshapeLibraryMaterial("Aluminum - 6061");

setProperty(context, {
        "entities" : myBody,
        "propertyType" : PropertyType.MATERIAL,
        "value" : myComponentMaterial
});

It would also be useful to support complete custom material definitions:

var myComponentMaterial is Material = material({
        "name" : "Aluminum - 6061",
        "density" : 2720 * kilogram / meter ^ 3,
        "poissonRatio" : 0.35,
        "youngsModulus" : 6.89e10 * pascal,
        "tensileYieldStrength" : 2.41e8 * pascal,
        "ultimateTensileStrength" : 2.90e8 * pascal,
        "compressiveYieldStrength" : 0 * pascal,
        "ultimateCompressiveStrength" : 0 * pascal
});

The existing material(name, density) function could remain available for backward compatibility.

This capability would be especially helpful for teams and companies using custom features to generate standard parts, structural members, fasteners, and other components. Those features could produce simulation-ready parts automatically instead of requiring users to manually replace every FeatureScript-assigned material.

Comments

  • Kevin_Cowles
    Kevin_Cowles Member, Onshape Employees Posts: 79 image

    Stay tuned! Hopefully, updates quite soon (which is likely the reason for the lack of response). No workaround today, other than to manually input the material properties. You'd likely want to create a custom material library and then set your parts to it from the Part Studio part list or BOM.

    But like I said, stay tuned!

  • Corey
    Corey Member Posts: 23 EDU

    This is 100% more of a response than what I got so far, and sounds like the one I was looking for.

  • EvanReese
    EvanReese Member, Mentor Posts: 3,019 PRO

    I've been needing this too!

    Evan Reese
    The Onsherpa | Reach peak Onshape productivity
    www.theonsherpa.com
  • Kevin_Cowles
    Kevin_Cowles Member, Onshape Employees Posts: 79 image

    Update is out! Looks like you inspired the workflow video as well

  • Corey
    Corey Member Posts: 23 EDU

    @Kevin_Cowles These three variables do not seem to be getting set.

    "poissonRatio" :
    "compressiveYieldStrength" :
    "ultimateCompressiveStrength" :

    And for the next iteration, we should be able to set the material to a type found in the Onshape material library.

  • elif
    elif Onshape Employees Posts: 54 image

    @Corey the correct variable is
    "poissonsRatio" for Poisson's Ratio.

    "ultimateCompressiveStrength" and "compressiveYieldStrength" should work. Could you please file a support ticket?

  • lana
    lana Onshape Employees Posts: 776 image

    "And for the next iteration, we should be able to set the material to a type found in the Onshape material library."

    @Corey That is the goal ultimately, but we have to do some work on material libraries before we are able to handle that.

  • Corey
    Corey Member Posts: 23 EDU

    Yep that was the typo. Thanks. The other two are working. I suspect I was not testing with a big enough number.

    The API must currently accept any and all parameters without throwing an error if the parameter does not exist. This is something that might be useful at the "Commit" step to build and test, or when the user executes the command, a pop-up message describing one of the parameters {list} used does not exist, but allow the function to continue without fail as it does today.

    Thanks. Your dev team does have quite the task both developing the API and the IDE. I like to program all my scripts in VSCode and copy them to my FS-Studio for testing, because CODEX and I can crunch a lot of scripts reasonably fast, and there are a few other quick key and git integrations that work better than the VERY AWSOME PDM for 3D models Onshape uses that doesn't track code with nice code-focused tools like git.