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.
Drive an Instantiator via an Enum input?
owen_sparks
Member, Developers Posts: 2,660 PRO
Hi folks.
I'm writing a little FS that will make pockets in a target part for threaded "Heatserts" and bring in a part representing the insert.
Instead of building the parts within FS it imports a solid "Void" from and external file, transforms it into place and then boolean removes it from the target part. Likewise for the insert itself.
File here:-
clicky
It's working nicely (thanks Neil) with the insert type hard coded into an Instantiator, so it'll put in an M6 insert no matter which option you chose! (M6 was always my favourite "M" but it'd be nice to be able to use others!)
I added a choice of insert types via the enum at the top of the feature, but am unsure how to pass that value to the Instantiator?
I'd expect to be able to declare a variable, set that depending on the enum choice and use the variable in place of the "HeatsertVoidForM6x8_5mmx8mm::build" in this line of code:-
Help!
Sorry for the newbie questions; it's like being a toddler again!
Cheers,
Owen S
I'm writing a little FS that will make pockets in a target part for threaded "Heatserts" and bring in a part representing the insert.
Instead of building the parts within FS it imports a solid "Void" from and external file, transforms it into place and then boolean removes it from the target part. Likewise for the insert itself.
File here:-
clicky
It's working nicely (thanks Neil) with the insert type hard coded into an Instantiator, so it'll put in an M6 insert no matter which option you chose! (M6 was always my favourite "M" but it'd be nice to be able to use others!)
I added a choice of insert types via the enum at the top of the feature, but am unsure how to pass that value to the Instantiator?
//Set Which PartStudios to use for Instantiator based on user input if (definition.InsertTypeSelected == InsertType.M3x5_4x8) { debug(context, "M3 Selected"); //Help! I want to set a variable here so pick which import to use! } if (definition.InsertTypeSelected == InsertType.M6x8_5x8) { debug(context, "M6 Selected"); }
I'd expect to be able to declare a variable, set that depending on the enum choice and use the variable in place of the "HeatsertVoidForM6x8_5mmx8mm::build" in this line of code:-
addInstance(instantiatorVoid, HeatsertVoidForM6x8_5mmx8mm::build, { "transform" : toWorld(coordSystem(skPlane))} );
Help!
Sorry for the newbie questions; it's like being a toddler again!
Cheers,
Owen S
Business Systems and Configuration Controller
HWM-Water Ltd
HWM-Water Ltd
Tagged:
0
Comments
There has to be a better way
Owen S
HWM-Water Ltd
Hi Neil,
Thanks for the replies. I may be missing the point.
Are we talking cross purposes here, I need the instantiator to use a different "import" for each enum type?
Is we can set a variable at the top of the code it's be much easier to maintain that sifting through the whole when new parts are added.
If I'm making no sense don't be shy in telling me so!
It's also Assembly Configs Webinar time so I think I'll leave this until the morning!
Cheers, Owen S.
HWM-Water Ltd
HWM-Water Ltd
HWM-Water Ltd
HWM-Water Ltd
You still have to import every Part Studio but it means the code is cleaner.
HWM-Water Ltd
IR for AS/NZS 1100
HWM-Water Ltd
HWM-Water Ltd
HWM-Water Ltd
HWM-Water Ltd