Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- 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?
S1mon
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?
Tagged:
0
Comments
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.
Website: ovyl.io