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.
Connector pin patterning/instantiation
Bill_Orner_Esperanto
Member Posts: 5 ✭
I am creating a model for an electrical connector which has 3,200 pins! The connector pins are not located in a (nice) standard pattern
I have all the pins and location coordinates in a spreadsheet. I have a model for the pin and the whole connector. Is there a way to write a FeatureScript that will instantiate the 3,200 pins into an assembly using the location coordinates?
I have all the pins and location coordinates in a spreadsheet. I have a model for the pin and the whole connector. Is there a way to write a FeatureScript that will instantiate the 3,200 pins into an assembly using the location coordinates?
0
Answers
Yes you can definitely do this! Featurescript understands CSV format, so if you can get your data into a CSV file and upload that into the document in question you can reference that data from featurescript. From there you could use importDerived(...) or applyPattern(...) to place the pins in the desired locations.
https://cad.onshape.com/FsDoc/imports.html
@ilya_baran or @kevin_o_toole_1 May have better advice than me about the performance difference between deriving vs. patterning 3200 similar parts, or may have an entirely different suggestion.
Thanks!
I'd be interested in trying my hand at something like this, if not just to learn and test our FeatureScript workflows. I don't think I can live stream, but I can try to set up something nice for you to plug-and-play your CSV and Pin. I'll let you know if I make any progress.
This is my first pass at what you would need:
https://cad.onshape.com/documents/abcec3031933a947d9ab22c4/w/c6d1cfebe2198b29879a753e/e/ff7728b8b7af62b4c4f7d1cb
Please copy the Onshape document and explore the FeatureScript and part studios. I didn't know the format of your spreadsheet, so there are comments in the FeatureScript file of what variables you may need to change depending on what the format of your sheet is. Patterning complex geometry with 3200 instances will border on waiting for tar to drip, so I added a "Simplify pattern" option, which just patterns a box at every location in the CSV.
In the process of doing this, I re-read your original question and think there may be better way of doing this overall. You mention doing this in an assembly, which is actually much better for performance than patterning in the part studio (and creating 3200 separate instances of your part). You could do this by creating some kind of extruded depression on the connector at every pin location (this could be done using the feature I provided with some small tool and then subtracting all the patterned tools from the connector), then using the assembly 'Replicate' command.
https://cad.onshape.com/help/Content/replicate.htm
https://www.youtube.com/watch?v=Wkdh4ja6Tkw
Let me know if you have any questions.
FYI @ilya_baran
I was able to copy your example code into my project and make the changes necessary for my file and format. I am still working through testing. I have a few more simple questions:
- I don't see how to enable Featurescripts in assemblies? I found a website called Solidsmack and from what it says I can only use Featurescript for part design? If true then the option to instanciate the pins as an assembly is not possible.
- I think this was your point to use Featurescript to place a simple thing at each pin and then do some kind of global replace in assembly to insert the pin. Taking that approach is there any kind of macro capabilities like Cadence "Skill" to enable this?
Thanks for your patience and help getting me up the learning curve. If there are any books or other reference materials that I should be referring to please let me know.Featurescript is used to build parts in a part studio. Assemblies just use these built parts, and Featurescript cannot be used to define anything about the assembly itself.
When I mentioned instancing the pin, I meant for you to only create the pin once in a part studio and use the 'Replicate' command in the assembly to instance it.
This help document may help:
https://cad.onshape.com/help/Content/replicate.htm
This video gives more detail:
https://www.youtube.com/watch?v=Wkdh4ja6Tkw
You may want to play around with replicate with simpler cases to see what I mean before you attempt to do something more complicated with your final design. If you share a link to your document here, it may be easier to see a good way to optimize your design.
https://cad.onshape.com/documents/5ef5092995173454deafda44/w/018cb5e0d8018a41067685c5/e/a72b8a4aec2c87124a8e90a3
after much trial and error I have made the import script and pin placement work! As expected the loading of the drawing is very slow due to the thousands of pins, no different than the performance with the "other" design tools with something this complex.
Onshape users would greatly benefit from more complete Featurescript documentation including practical examples organized in one place for easy access. I can see a lot of capabilities in Featurescript but the learning curve is difficult. Some challenges I had for example is that fCylinder and skCircle have different behavior for the ID. I used a "for" loop with fCylinder to place the pins, I had to concatenate onto the fCylinder ID an incremental number from the loop counter using "id + "cylinder" + i" where "i" is a counter. I tried and experiment to see if placing a circle instead of a cylinder would make drawings load faster but found that ID for skCircle behaves differently, couldn't figure out why. So, some more thorough documentation would be a great benefit to users and in particular how the relationships work between the active drawing, face and the script. You can close this as complete.
Thanks,
Bill
Have you tried the FS profiler to optimize the regeneration of your feature? For example, I expect that creating one cylinder and doing an opPattern will go faster than a lot of fCylinder calls (assuming you need it to regen faster and the profiler tells you that's the bottleneck)...