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.

Options

pattern in a cloud of points (around 2K/3K points or more)

otaolafrotaolafr Member Posts: 113 EDU
edited November 2020 in FeatureScript
hello,
I want to create a pattern of solids in a cloud of points that I create by a FS.

my issue is that as there will be too many solids (around 2 to 3 k). until here everything works okey.
but when I try to fuse them all together the onshape server keeps loading (until it times out) and I can not achieve to generate my geometry. 
an example of the cloud of points:


as the points are ordered first in the z-axis, then in y and lastly in x. so I thought about fusing all the elements in the pattern for each slice separately and then fuse each slice,
for this, I thought in to create a number of lists equal to the number of different z values, and then with a loop divide the big list of points in the list and then use it in the opPattern so something like this:

create cloud of points (from a loop) -> create N lists (N equal to the number of different values of z in the cloud) ->do N opPatterns -> fuse each N qCreatedby opPatterns -> duse all the N "slices"

I am pretty sure that there is a more clever/cleaner way to do this (I excuse myself as my solution is brut force.... :s ), but I do not see how to. anyone that could enlighten me with this issue?
best regards,

Comments

  • Options
    mahirmahir Member, Developers Posts: 1,291 ✭✭✭✭✭
    What is your end goal? No matter how you do it, having a pattern with 3K instances is never going to go smoothly. This looks like you're trying to create a uniform pattern around a cylinder. If that's the case, perhaps you can fuse some of the instances into a single feature with a more complicated sketch. Then, use a combination of circular and linear patterns to propagate to the rest of the cylinder.
  • Options
    otaolafrotaolafr Member Posts: 113 EDU
    mahir said:
    What is your end goal? No matter how you do it, having a pattern with 3K instances is never going to go smoothly. This looks like you're trying to create a uniform pattern around a cylinder. If that's the case, perhaps you can fuse some of the instances into a single feature with a more complicated sketch. Then, use a combination of circular and linear patterns to propagate to the rest of the cylinder.
    I am trying to fill up the geometry with a lattice, something like the infills from 3D printing, controlling the angle between the internal structure and the principal axis of the cylinder, when the angle is 0 and 45 as you mention, I create one slice and then use a linear pattern to create the 3rd dimension. the issue is when the angle is different in these two cases, as if I use a linear pattern, I have two options:
    1. I use the axis of the cylinder as the vector for the linear pattern this will create a pattern that is not perfectly periodic as the following image (to keep the alignment of the structure I should go in discontinuous sections as in 2.) (see between 4th and 5th line of the boxes in the image at the end)


    2. approximate the vector of the axis of the cylinder to a vector that would match to the grid (so a little bit more in x and y or a little bit less) the benefit of this approach is that the structure will match, but it risk of drift away from the solid I want to fill. (see the 3th 4th and 7th line of boxes)

    I put the two problems in the same image for simplification :)



    that way I thought about creating a line, fuse it, then the second one, fuse it, etc... that way I would limit the number of objects at the same time. (and in this case, I took a cylinder but I was also trying to do it with other types of manifold solids there are other software that handles quite well this type of things but are limited in others tools and I would prefer to stay with Onshape also ^^ )

  • Options
    mahirmahir Member, Developers Posts: 1,291 ✭✭✭✭✭
    It's an interesting problem, but my gut tells me its not one suited to 3D CAD. Slicers can handle the task relatively easily because they're just dealing with point to point toolpaths. OS is trying to actually render these as 3D objects, which will slow the server down to a crawl anytime you start to hit anywhere close to 1k separate bodies. I know it's not the answer you wanted to hear. Maybe someone from the OS team has a better response. 

    But if you can do this better with other tools, perhaps it would be a worthwhile compromise to simply export geometry back and forth between that other software into OS.
  • Options
    otaolafrotaolafr Member Posts: 113 EDU
    mahir said:
    It's an interesting problem, but my gut tells me its not one suited to 3D CAD. Slicers can handle the task relatively easily because they're just dealing with point to point toolpaths. OS is trying to actually render these as 3D objects, which will slow the server down to a crawl anytime you start to hit anywhere close to 1k separate bodies. I know it's not the answer you wanted to hear. Maybe someone from the OS team has a better response. 

    But if you can do this better with other tools, perhaps it would be a worthwhile compromise to simply export geometry back and forth between that other software into OS.
    yes, but slicers gives similar results but I am looking for solids not meshes created by slicers. I know that onshape is not the best tool for this but I was looking to stay in the environment, and if I can achieve to create a layer, fuse it together and then create the next one this could be handle with no more than ~50 objects at the time, my issue is not exactly the number of solids, it is how to handle the creation of them and fusing of them that I do not understand how to created in feature scritp languate.
  • Options
    otaolafrotaolafr Member Posts: 113 EDU
    edited December 2020

    I have mostly successfully created the custom feature but I am getting an error when I try to fuse the "slices" together,

     

    I create each "slice" separatly with a loop:

     

    for (var n = 0 ; n <= size(zOfLayers); n+= 1)//
            {
                opPattern(context, id + ("pattern"~n), {
                        "entities" : qCreatedBy(id + "cylinder1", EntityType.BODY),
                        "transforms" :  sepTransforms[n],
                        "instanceNames" : sepInstanceNames[n]
                    });
                opBoolean(context, id + ("boolean_"~n), {
                        "tools" : qCreatedBy(id + ("pattern"~n), EntityType.BODY),
                        "operationType" : BooleanOperationType.UNION
                    });
                debug(context, "boolean_"~n);
            }

     

    until here everything is okey, then I after the creation of all the "slices" I redo a loop (I know that they could be done at the same time as the previous loop but as I was trying to debug I put it separately)

    I do:

    var slice = qNothing()
    for (var n = 1 ; n <= size(zOfLayers); n+= 1)
            {
                debug(context, n);
                dummy=n-1;
                if (n==1)
                {
                    debug(context, "boolean."~n);
                    debug(context, "boolean_"~n);
                    debug(context, "boolean_"~dummy);
                    slice= qUnion([qCreatedBy(id + ("boolean_"~dummy), EntityType.BODY), qCreatedBy(id + ("boolean_"~n), EntityType.BODY)]);
                    opBoolean(context, "boolean."~n, {
                            "tools" : slice,
                            "operationType" : BooleanOperationType.UNION
                        });
                   
                }
                else
                {
                    debug(context, "boolean."~n);
                    debug(context, "boolean_"~n);
                    debug(context, "boolean."~dummy);
                    slice= qUnion([qCreatedBy(id + ("boolean_"~n), EntityType.BODY), qCreatedBy(id + ("boolean."~dummy), EntityType.BODY)]);
                    opBoolean(context, "boolean."~n, {
                            "tools" : slice,
                            "operationType" : BooleanOperationType.UNION
                        });           
                }
            }

     

     

    from the results of the debug, I am getting the correct ids to call so I do not get why I still get the error, but I still get an error

    EDIT:

    okey, from trying to find what was the problem, from the forum, I found that my query was empty: https://forum.onshape.com/discussion/8005/opboolean-dont-work


    so I changed

     for (var n = 1 ; n <= size(zOfLayers); n+= 1)//
            {
                debug(context, n);
                dummy=n-1;
                if (n==1)
                {
                    debug(context, "boolean."~n);
                    debug(context, "pattern"~n);
                    debug(context,qCreatedBy(id + ("pattern"~n), EntityType.BODY));
                    debug(context, "pattern"~dummy);
                    debug(context,qCreatedBy(id + ("pattern"~dummy), EntityType.BODY));
                    slice= qUnion([qCreatedBy(id + ("pattern"~n), EntityType.BODY), qCreatedBy(id + ("pattern"~dummy), EntityType.BODY)]);
                    debug(context,slice);
                    opBoolean(context, "bool"~n, {
                            "tools" : slice,
                            "operationType" : BooleanOperationType.UNION
                        });
                } 
            }
          

Sign In or Register to comment.