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

Trouble Patterning a FeatureScript

robert_morrisrobert_morris OS Professional, Developers Posts: 166 PRO
Hello all,

I've been working on a new FeatureScript, and have it mostly working, but now I'm having a little trouble getting it to work with the Pattern tool.

I found the "getRemainderPatternTransform()" and "transformResultIfNecessary()" functions and have added them to my code.
Now when I try to pattern my feature, it will pattern the sketches in the FeatureScript, but the actual solid bodies still don't get replicated.

I'm not sure what I'm missing or doing wrong, so if anybody can help me out here, that would be great.

I've made a stripped down example of my code public, you can access it here:
https://cad.onshape.com/documents/ffb2867fa9892c78256b73fd/w/e73b0aaba0a8f6e661b4c33a/e/4647be21759905a925687466

Thanks,
Tagged:

Best Answers

Answers

  • Options
    robert_morrisrobert_morris OS Professional, Developers Posts: 166 PRO
    Thanks for the help on this. What you both said makes sense.

    Both methods (extrude NEW or transforming the sketch) yield partial success with my full code.
    The problem now seems to be that since I'm also adding other things on top of those first extrusions, those items aren't being transformed as well.

    It looks like I will have to rethink how some of the code is organized in order to get it to fully work with patterns. Either by doing all the sketches at once and transforming those, or messing around with booleans of the individual features.

    This FeatureScript doesn't really need to work with patterns, but I thought i'd do it for completeness sake.

    FWIW, here is a link to the full code of what I'm working on:
    https://cad.onshape.com/documents/2972a375d9fd3b741d7cc02a/w/45408693c3984999d8c8ff22/e/403280a8c811319478bddf50

    It's for making Mounting Bosses used in molded plastic parts.
    I borrowed some of the code from Neil Cooke's Screw Boss feature, modified a couple of things, and expanded on it to allow for other types of boss.


  • Options
    ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 1,175
    Looks like a nice feature!  Yeah, as the previous posters noted, getting a feature to work with feature pattern can be hard (and there are multiple approaches).  Personally, the thing I'd try is use getRemainderPatternTransform() at the beginning and then transform the locations (and axes) and then do the other operations without any transforms.  This is similar to what we do with our hole feature.
    Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc
  • Options
    robert_morrisrobert_morris OS Professional, Developers Posts: 166 PRO
    @ilya_baran
    Thanks for the pointers.
    I took a look at the hole feature and borrowed some of the computeCSys() code in there to do the transformation of the locations, and with some healthy debug() usage, I got everything working.

  • Options
    ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 1,175
    Great!
    Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc
Sign In or Register to comment.