Re-apply attributes to patterned entities

leon_poot
leon_poot Member, Developers Posts: 87 ✭✭✭
Let's say I'm (linear) patterning a couple of bodies. Some of these have been given a specific attribute using FeatureScript ({"A" : true}), some others another attribute ({"B" : true}). The new bodies apparently don't get the attributes, which I'll need for later boolean operations!

The instance count is based on a parametric variable, and there's no knowing how many instances there'll be, so I can't manually be setting the attributes for all the new instances. I'm thinking of somehow reading which parts have which attribute, and then re-applying these to each new instance.

So what I really need is to be able to query all patterned instances of a specific part. Any idea how do this, anyone?
"A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools." - Douglas Adams, Mostly Harmless
Tagged:

Best Answer

Answers

  • konstantin_shiriazdanov
    konstantin_shiriazdanov Member Posts: 1,221 ✭✭✭✭✭
    edited May 2017
    maybe is worth to try to obtain the id of body pattern and select all bodies created by operation with corresponding id like this qCreatedBy(lastModifyingOperationId(qOwnerBody(query_of_some_item_of_the_pattern)),EntityType.BODY)
  • lana
    lana Onshape Employees Posts: 782 image
    @leon_poot

    var trackingAQuery = startTracking(context, bodyA);
    opPattern(..)
    instancesA  = evaluateQuery(context, trackingAQuery) ;
    This should give you all the instances of bodyA created by pattern. 


  • leon_poot
    leon_poot Member, Developers Posts: 87 ✭✭✭
    @lana That makes sense... but this would require me do the pattern by FS, I'd much rather be able to fiddle with the parts in the part studio. But I guess I could make a modified pattern script from the std library?
    "A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools." - Douglas Adams, Mostly Harmless
  • leon_poot
    leon_poot Member, Developers Posts: 87 ✭✭✭
    Ah of course! That should do the trick, thanks :smile:
    "A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools." - Douglas Adams, Mostly Harmless