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.

Drive a Linear Pattern Using an Array?

jackson_kingjackson_king OS Professional Posts: 80 PRO
Hi All,
Is there a way to get a linear pattern to vary the instance spacing based on a #variable that contains an array of values?




The use for this is to create a feature pattern of mate connectors or holes in a part studio.
As you can see the row of mate connectors directly under the holes, these features go in at the same spacing as the purple gussets and I would like to be able to drive patterns for the mate connectors and holes using a #variable containing an array (shown above).

There are several variations of this cylindrical tank with decks on the side and I would like a good way to put in a lot of info (arrays) and get the varied spacing I am looking for.

Thanks, Jackson 

Best Answers

Answers

  • Dylan_StewartDylan_Stewart Member, Developers Posts: 106 PRO
    This sounds like something that could be very possible with use of FeatureScript.
    Have you tried that yet? 
    Digital Engineering
  • jackson_kingjackson_king OS Professional Posts: 80 PRO
    No I haven't tried that yet.  I have done the tutorials for featurescript but was unsuccessful with creating my own custom feature.  I think I tried to do a way too complex set of operations for my first solo attempt:(  Kinda left it alone after that..... 
  • mahirmahir Member, Developers Posts: 1,139 ✭✭✭✭✭
    Sounds like an interesting FS project. I'll take a look in the near future.
  • jackson_kingjackson_king OS Professional Posts: 80 PRO
    #Dylan_Stewart & #mahir,  thank you for your comments!  Where have you found good resources for learning more about featurescript?

    I have also asked #oleg_shilovitsky about having a way to use an OpenBOM like table to drive the variables or reference the table directly from the dimensions.  I think both could have equal validity in practice.

    The reason I wanted to array the driving dimensions is illustrated below:




    There are many that are tied to "compartment 1", then "compartment 2", etc. as there are 3 compartments to this tank and each have about the same plumbing holes cut in it.


  • jackson_kingjackson_king OS Professional Posts: 80 PRO
    Thanks guys! @Dylan_Stewart@mahir,   When I have some time to devote to FS, I'll come and bug you for help!  but, not too much;)

    Probably by the time I get around to this, Onshape will have rolled out some awesome new capability for handling this situation.

    I also have a feeling that @oleg_shilovitsky has a few tricks up his programming sleeve too!  So if I just procrastinate long enough, it will get fixed;)
  • jackson_kingjackson_king OS Professional Posts: 80 PRO
    edited September 2016
    mahir said:
    @jackson_king, I just remembered there is a point pattern featurescript written by OS I believe. It's not the same as driving a pattern with an array, but you can get the similar results by driving a pattern with a bunch of independently dimensioned points.
    You are definitely correct @mahir!  I had totally forgotten about that pattern.  I was all excited and and just checked it out and it would work really well for the parts but it won't let me select a mate connector (I was wanting to pattern MC's to use for part positioning in the assembly).....  I looked a little into the FS and found where I should change the filter type from "body" to "???", "any"?

    I tried looking through things a little and could not find how to allow me to select a MC for pattern (not sure what to set the filter to?).

    This may be more of a moot point as OpenBOM just released an update and now I can "group by name" and that should let me have multiple instances of the same part in a particular part studio and be able to treat them as the same in the BOM.
  • jackson_kingjackson_king OS Professional Posts: 80 PRO
    @jackson_king  Please take a look at this public model of using arrays in patterns.  I think this is similar to what you are asking.

    https://cad.onshape.com/documents/8ba8f542acbba774726bc830/w/0f1f32a1cdf32489b727efa4/e/6dcc5e4b7c2375c65da14d9d



    @cody_armstrong, thanks for taking a look at my questions in regards to the linear patterning!!  I think I may not be asking the question in the correct way...  

    I am trying to get the spacing between the patterned instances to vary based on the array set up as a variable.  Let's say I want to pattern the square bars in the "ladder" example you linked above; I want the 1st bar (instance/seed) to be at zero, the 2nd at 3", the 3rd at 10", the 4th at 14", & the 5th at 27.5".  I was trying to set up an array as variable to look like this,   [3,10,14,27.5][VariedSpacing].  Then in the spacing spot in the linear pattern I would call #VariedSpacing and put in 5 for the # of instances.

    I hope I was able to be more clear on this!!  It makes my head hurt when I try to explain it;)

  • jackson_kingjackson_king OS Professional Posts: 80 PRO
    @jackson_king  Here is a simple example of patterning mate connectors based on sketch point locations using FeatureScript.

    https://cad.onshape.com/documents/57cf1a62dfdcf610c72f3c76/w/b957914f796545e00f196d60/e/407aa1a7b47f5776f5cf649c

    I will update the Point Pattern to support features soon.
    @cody_armstrong, This FS is sweet!!!!  As I was trying to explain myself, you were providing an answer;)  I will be trying out the "Mo Mate Connectors" on some truck service body designs I am working on.  I really liked how it does not fill the feature list with all the MC's (a.k.a. really clean look).

    This in itself will be a big time saver for me!  Onshape rocks!

    Thanks, Jackson
  • owen_sparksowen_sparks Member, Developers Posts: 2,660 PRO
    @jackson_king  Here is a simple example of patterning mate connectors based on sketch point locations using FeatureScript.

    https://cad.onshape.com/documents/57cf1a62dfdcf610c72f3c76/w/b957914f796545e00f196d60/e/407aa1a7b47f5776f5cf649c

    I will update the Point Pattern to support features soon.
    Nice job @cody_armstrong really useful :)

    Thanks, Owen S.
    Business Systems and Configuration Controller
    HWM-Water Ltd
  • 3D3D OS Professional Posts: 52 ✭✭
    @cody_armstrong, this is a very usefull FS feature. Can I ask how much would be involved in modifying this to enable this FS to "Replicate" features  - parts or otherwise - to "Circular" edges - much like the replicate feature allows you to do in "Assemblies". This would be very useful for placing fastenings such as rivets etc.
  • cody_armstrongcody_armstrong Moderator, Onshape Employees, Developers Posts: 204
    @3D How do you imagine this working? Would you want it to find circular edges with the same radius and pattern a part with respect to the radius? Can you explain what the ideal workflow would be?

    If you have a sketch point (an arc center for example), you can use the Point Pattern feature to accomplish something similar to this.
  • 3D3D OS Professional Posts: 52 ✭✭
    Thanks for quick response @cody_armstrong, as of now, it is necessary to derive the fixing, place mate connector on both fixing & object. If it were then possible to use this scenario as a seed, & just click on each "Hole edge" where appropriate to replicate this, would save up to 3 steps per repitition. For example, if you had 100 rivets in non std posisions ie (non-patternable with linear / circular) - you would save 300 steps. Does that make sense?
  • cody_armstrongcody_armstrong Moderator, Onshape Employees, Developers Posts: 204
    @3D I think the code for this would be fairly straight forward.  Below is a snippet I threw together based on your description.  Here is a link to an example doc.  This does not do a transform rotate to orient the part for faces that are not parallel with the original, although I don't think that would be too hard to add.

    One more thing.  This may not be the best technique if each "rivet" you mentioned is a separate instance of a part. Multiple instances of parts is best handled at the assembly level so you can ensure the quantity counts are correct.  This would mean you would use the actual Replicate command in Assemblies to accomplish this.


    annotation { "Feature Type Name" : "Replicate" } export const myFeature = defineFeature(function(context is Context, id is Id, definition is map) precondition { annotation { "Name" : "Circular Edge", "Filter" : EntityType.EDGE, "MaxNumberOfPicks" : 1 } definition.edge is Query; annotation { "Name" : "Part To Pattern", "Filter" : EntityType.BODY, "MaxNumberOfPicks" : 1 } definition.part is Query; annotation { "Name" : "Faces to find match in", "Filter" : EntityType.FACE } definition.face is Query; } { var part = evaluateQuery(context, definition.part); var instanceNames = []; var transforms = []; var patternNumber = 1; var edge = definition.edge; var curve = evCurveDefinition(context, { "edge" : edge }); if (!(curve is Circle)) // if the selected curve is not a circle throw error { throw regenError("Selected edge is not a circle"); } var curveRadius = curve.radius; var origin = curve.coordSystem.origin; var faces = definition.face; var edges = evaluateQuery(context, qEdgeAdjacent(faces, EntityType.EDGE)); for (var i = 0; i < size(edges); i += 1) { var selectedEdge = edges[i]; var selectedCurve = evCurveDefinition(context, { "edge" : selectedEdge }); if (selectedCurve is Circle) { var selectedCurveRadius = selectedCurve.radius; if (tolerantEquals(selectedCurveRadius, curveRadius)) { var point = selectedCurve.coordSystem.origin; transforms = append(transforms, transform(point - origin)); instanceNames = append(instanceNames, "" ~ patternNumber); patternNumber += 1; } } } definition.transforms = transforms; definition.instanceNames = instanceNames; var remainingTransform = getRemainderPatternTransform(context, { "references" : definition.part }); opPattern(context, id + "pattern1", { "entities" : definition.part, "transforms" : transforms, "instanceNames" : instanceNames }); });
  • 3D3D OS Professional Posts: 52 ✭✭
    Thanks for the effort Cody, however, this does not seem to work if you select edges other than the original face. Would be really great if this could be refined as it would have the potential to save  a lot of time. Many thanks so far though!
Sign In or Register to comment.