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.
unexpected selection behavior when filleting the results of a self-repeating custom feature

i'm not quite sure what to make of this. the lower-right hole is the one based on the first item i selected for my custom feature and that seems to be relevant here, and in other cases where i ran into this with the same feature.
clicking the edge of the first instance selects both instances. deselecting the first does not deselect the second. while both are selected from the single click, it shows a single entity selected in the list. etc… i assume i've written a bug in my script, but i wouldn't have expected to be able to do this and i'm not sure what i'm doing wrong with the ids.
thanks for any thoughts you have on what i've got wrong here.
Comments
Please share a link to your custom feature so we can have a look at the code.
Learn more about the Gospel of Christ ( Here )
CADSharp - We make custom features and integrated Onshape apps! Learn How to FeatureScript Here 🔴
huh, looks like my link got turned into a yellow circle exclamation mark for some reason. let's try this again. sorry.
failed again… https://cad.onshape.com/documents/cdf6376c4598c490bca1f966/v/4c18c76026d6a3c0462474ec/e/0191915c73a5234fa1a2ca1b?renderMode=0&leftPanel=false&uiState=68b1c8aa62d5f2280f7e4af5
https://gist.github.com/altendky/e90df0468edfe407c756bb330c8f8b03 here's the code anyways in case the link still doesn't work.
:[
https://cad.onshape.com/documents/cdf6376c4598c490bca1f966/v/4c18c76026d6a3c0462474ec/e/0191915c73a5234fa1a2ca1b?renderMode=0&uiState=68b1c91362d5f2280f7e4da4
hopefully a
*bump*
here isn't too rude given the technical issues with posting the link.The entity ID's are getting confused. Looks like your loop is a little strange. Try to use just a standard for-loop and do not use in-line functions for starting out in FeatureScript:
Here is an example of a standard for-loop:
.
If this is giving you trouble, I recommend following the FeatureScript video tutorials in order, this way you learn all the concepts properly:
FeatureScript Fundamentals by Onshape
FeatureScript Video Tutorials by CADSharp
.
Learn more about the Gospel of Christ ( Here )
CADSharp - We make custom features and integrated Onshape apps! Learn How to FeatureScript Here 🔴
thanks for the suggestion. i know i have a couple other inline functions i should reconsider, but i had thought that
forEachEntity()
was the proper way to get the looping ids handled well relative to the original entities i was building from. to confirm,forEachEntity()
should not be my default pattern for this? it seems like a simple loop withi
as the id modifier would be somewhat non-unique in the sense that created features will have ids based on simply the selection order and not the original entity they are built from. this could result in downstream references pointing at the wrong entities if the selection passed to my feature is changed, when instead it might be better for the downstream references to break than to reference the wrong entity.thanks for the video links, i'll take a look.
this was a slightly different route than your exact code, but the same idea and it does indeed avoid the issue. i guess i'll print out the ids in both cases and try to better understand how my use of
forEachEntity()
is wrong. then maybe figure out how that doesn't trigger the id reuse error either. thanks again.forEachEntity()
is ok if i disable my cleanup code at the end. i knew my cleanup was a hack.There are a variety of neat ways to loop. For whatever reason, I have found the most success using the old school way.
Learn more about the Gospel of Christ ( Here )
CADSharp - We make custom features and integrated Onshape apps! Learn How to FeatureScript Here 🔴
i still haven't quite figured out the underlying issue, but moving my cleanup outside of the
forEachEntity()
call and using the code below seems to both have the effect i want of not showing the sketches as well as avoiding the shown selection trouble.i'll clean up my code and post a new working version.
https://cad.onshape.com/documents/cdf6376c4598c490bca1f966/v/f0e9920ccf50036003da5f7e/e/0191915c73a5234fa1a2ca1b?renderMode=0&uiState=68beffa2f38c870f00ec4c8d
i simplified the cleanup down to a single call to this at the very end of the feature function and outside of the
forEachEntity()
.thanks for getting me started down a useful debugging path.
Sure thing! Welcome to FeatureScript 😎
Learn more about the Gospel of Christ ( Here )
CADSharp - We make custom features and integrated Onshape apps! Learn How to FeatureScript Here 🔴