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.

transformResultIfNecessary?

S1monS1mon Member Posts: 2,815 PRO
        transformResultIfNecessary(context, id, remainingTransform);
I've noticed this line of code in a bunch of the std library (31 of the 192 tabs). I don't remember this being all over in the past.

Reading in feature.fs there's a large comment about how it enables feature based patterns.

Are there any tricks to using this line correctly in custom features? Any reason for it not to be part of the boilerplate?

Comments

  • lanalana Onshape Employees Posts: 703
    You've probably also noticed that remaining transform is computed by a call to `getRemainderPatternTransform` . That call is feature dependent - the author of the feature needs to decide which input queries can affect the behavior. Between those those two functions it was as much of a boilerplate as we could manage.
  • kevin_o_toole_1kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565
    edited December 2022
    Both getRemainderPatternTransform and transformResultIfNecessary are not possible to add to boilerplate because there are two real questions the feature author needs to answer when getting their feature to work with feature pattern:

    1) What references to provide to 
    getRemainderPatternTransform()?
    2) Where in the feature function to call transformResultIfNecessary()?

    The references are needed to avoid double-transforms. If a user patterns just an extrude, we need getRemainderPatternTransform() to return different things when extrude is called each new time. But if a user patterns both a sketch and an extrude, we want getRemainderPatternTransform() to provide different things in sketch(), but just identity transforms in extrude(). This way, the final results are not transformed twice.

    The transformResultIfNecessary() call position depends on the feature. For example, your feature might create some geometry then boolean with a part. In that case you should call transformResultIfNecessary() after the geometry creation but before the boolean. For extrude, it's more complicated than a single call to transformResultIfNecessary(). For instance, the end condition of "up to next" will create different geometry in each patterned extrude.
  • EvanAReeseEvanAReese Member, Mentor Posts: 2,077 1337
    Thanks for the answers Kevin and Lana! I'm always curious about that stuff.
    Evan Reese / Principal and Industrial Designer with Ovyl
    Website: ovyl.io
Sign In or Register to comment.