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.

Efficient way to generate many many duplicate geometries

kai_liu589kai_liu589 Member, Developers Posts: 5
Hi,

I am currently writing some programming using feature script. Part of the program need to generate sphere at different locations (with same radius). My problem need to generate potential 20,000 spheres at various location. 

I already tried using "opPattern" instead "opSphere" to improve the speed. I was wondering is there any other methods to further improve the rendering speed?

Thanks
Kai

Comments

  • kevin_o_toole_1kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 447
    opPattern should get you slightly better performance, yes. I can't think of another way to speed things up while still creating all the spheres.

    If it's acceptable to use point instead of spheres (via opPoint(...{..."origin" : true}) ), that will be much faster.
  • kai_liu589kai_liu589 Member, Developers Posts: 5
    Hi kevin,
    thanks for the help. It seems that might be the only solution to large scale model? I suppose the processing time also related with my computer power? 
  • kevin_o_toole_1kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 447
    edited May 2017
    Kai,

    There are several things that can make things go slowly in a model with 20,000 spheres.

    The first is regeneration, which is the actual execution of your FeatureScript code which produces geometry. This time is what gets measured when you use the "Profile Part Studio" functionality. All of that work happens on our servers, so you would see no difference in that timing regardless of your device.

    Another is simply handling the display of a large number of triangles approximating each of the 20,000 spheres. It will take some time for your browser to fully display these in the first place, and the framerate on things like rotating the view will become extremely slow. A quick trial shows that a model of 20,000 spheres will be rendered as 26 million triangles. All of this work happens in the browser on your computer, and could be improved with, say, a graphics card designed for intense gaming.

    In my trial, regeneration performance on the pattern was pretty fast (<10 seconds), but display performance was unusably slow.

    If you tried the same thing with 20,000 cubes, regeneration would be slower (there being more geometry/references to create), but rendering would be faster (since a cube can be rendered accurately with only a small number of triangles).

  • kai_liu589kai_liu589 Member, Developers Posts: 5
    edited May 2017
    Thanks Kevin for pointing out the "Profile" feature. Your explanation is very helpful. Now I have deeper understanding on how OnShape works.  :)  

    When my current tab is at feature script studio and clicked the profiling part studio function, the feature script starts running (regeneration, computation on the server). Does the geometry also rendered at of the part studio tab (display, computation on the client) or it won't rendered until I click the part studio tab?

    Is regeneration and display two separate processes? (for example, regenerate all spheres on the sever before it is displayed on the client side or regenerate one sphere and display on sphere at a time?) If I using API calls, will that separate regeneration on server, and display on client side?

    Does the model need to be rendered every time whenever I switch to a part studio tab (e.g., from one part studio tab to another part studio tab in the same document, or open a new document)?

    Thanks for your help.
    Kai
Sign In or Register to comment.