working with FeatureList objects

adamohern
adamohern Member, OS Professional Posts: 216 PRO
I want to allow my user to select a previously created feature, then build something using that feature as an input. I assume I need to use a query for FeatureList objects, but I'm not sure how to handle them once I have them.

Let's say I have a feature called "VertexGenerator", and another called "LineGenerator" that accepts VertexGenerator features as inputs. How would I get the vertices generated by the selected VertexGenerator features for use in drawing the lines?

Comments

  • ilya_baran
    ilya_baran Onshape Employees, Developers, HDM Posts: 1,278 image
    The feature list is a map from feature id to function.  You can pass the feature id(s) to qCreatedBy.
    Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc
  • adamohern
    adamohern Member, OS Professional Posts: 216 PRO
    I imagined something along those lines. But how do I convert, say, "definition.instanceFunction" to a query or set of queries? Sorry, I get the concept, but I'm not clear on the mechanics.
  • john_f_carr
    john_f_carr Onshape Employees Posts: 74 image
    annotation { "Feature Type Name" : "Point out points" }
    export const show = defineFeature(function(context is Context, id is Id, definition is map)
        precondition
        {
            annotation { 'Name' : 'Feature' } definition.f is FeatureList;
        }
        {
            var queries = [];
            for (var f in definition.f)
                queries = append(queries, qCreatedBy(f.key, EntityType.VERTEX));
            const q = qUnion(queries);
            debug(context, q);
        });
  • adamohern
    adamohern Member, OS Professional Posts: 216 PRO
    Ah, ok. So it's just a simple array of feature id's. Makes sense. Thanks!
  • ilya_baran
    ilya_baran Onshape Employees, Developers, HDM Posts: 1,278 image
    Not an array, it's a map: notice the "f.key" in the loop body.
    Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc
  • adamohern
    adamohern Member, OS Professional Posts: 216 PRO
    Ah, right. Sorry, still getting used to this data model.
  • adamohern
    adamohern Member, OS Professional Posts: 216 PRO
    Oh, come now. opPlanes return vertices at their corners!? This pseudo-bounded nature of planes is really bothersome. A plane is just an infinite plane. It does not have edges or corners. Sheesh.