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.

Is there a way to randomly instance parts over a surface?

ron_morelandron_moreland Member Posts: 90 ✭✭
I want to scatter spheres over a freeform surface. Is there a featurescript to do this?

Answers

  • Jake_RosenfeldJake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,646
    Hi @ron_moreland

    We intentionally don't provide true randomness in FeatureScript.  If we did, your spheres would regenerate in a different place every time and lots of downstream features would probably break due to references changing in unpredictable ways.

    Instead, you can use this function that Ilya wrote:
    https://forum.onshape.com/discussion/4086/pseudo-random-number-generator

    It takes a "seed" that you could take as a parameter into your feature.  That way, when you change the seed, the spheres change position, but every time it regenerates with the same seed, it regenerates the same way.
    Jake Rosenfeld - Modeling Team
Sign In or Register to comment.