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.

working with FeatureList objects

adamohernadamohern 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_baranilya_baran Onshape Employees, Developers, HDM Posts: 1,215
    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
  • adamohernadamohern 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_carrjohn_f_carr Onshape Employees Posts: 74
    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);
        });
  • adamohernadamohern Member, OS Professional Posts: 216 PRO
    Ah, ok. So it's just a simple array of feature id's. Makes sense. Thanks!
  • ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 1,215
    Not an array, it's a map: notice the "f.key" in the loop body.
    Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc
  • adamohernadamohern Member, OS Professional Posts: 216 PRO
    Ah, right. Sorry, still getting used to this data model.
  • adamohernadamohern 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.
Sign In or Register to comment.