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.

constructPath using faces with holes

johnsoggjohnsogg Member, Developers Posts: 14
I'm attempting to traverse paths on a face that potentially has holes in it. Using the constructPath function throws an error with the message "Edges do not form a continuous path" in the case where there is a hole. I suppose this makes sense.

Two questions: (1) is there a reasonable pre-processing I can do to the edge query to separate edges? Seems there's a bigraph of vertices to edges, so maybe there's a function for this already?

(2) This is the tooltip text for constructPath: "A Query of edges to form into a Path. The edges are ordered with query evaluation order, so a qUnion should be used to ensure a stable ordering." I'm having a hard time parsing what that means. Can anyone translate that into 8th grade terms?


  • Jake_RosenfeldJake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,381
    Hi John,

    There is no one-size-fits-all preprocessing function like you're looking for.  If you want to see how we check for unconnected Paths you can check out path.fs in the standard library. You could potentially make a copy and change the error messages so you can see what specifically is wrong with your path.  One workaround would be to separate out your edges into an array of individual edges with something like `var edgesArray = evaluateQuery(context, edgesQuery)` and then try to get some permutation of those edges to work in constructPath(...).  Posting a screenshot of the edges you are trying to make into a Path may help diagnose the problem.

    As for (2): Unless some 'referenceGeometry' is provided to determine the starting vertex of the Path, the start of the path will be determined by the order of the edges returned by an evaluateQuery(...) on the supplied edges.  In the case of an open path (the ends of the path do not connect), the starting point of the path is the first vertex associated with the edge query that does not connect to an even number of edges.  In the case of a closed path (the path is some kind of loop), the starting vertex is the first vertex of the first edge of the edge query.

    Implementation aside, the statement you are asking about is basically saying "If you know which edge you want to have as the start of the path, do a qUnion with that edge coming first; If you don't care which edge comes first continue as normal."
    Jake Rosenfeld - Modeling Team
  • johnsoggjohnsogg Member, Developers Posts: 14
    Thanks. The code in path.fs is helpful (computeGraphInformation especially). I expect I will build a function that accepts a bunch of edges related to a single face, and spit out an array of edges that should be acceptable to build paths from. Something like this using a bipartite graph, where paths are edges that are mutually discoverable via points:

    I'm not very familiar with the available tools within FS. Are there sets, or at least set-like semantics associated with any existing data structure(s)? Or more ideally, a graph data structure?

    However I end up doing it, this will probably generally useful; so anyone who finds this and wants access let me know and I'll share.
  • Jake_RosenfeldJake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,381
    Hi John,

    Sounds awesome!  Your function will probably look similar to computeGraphInformation in that you will need to take each edge, evaluate its parameterization at 0 and 1 to find its ends, and then use clusterPoints to form these into the Points in your bipartite graph. Be careful also with the following: points on a face always meet at exactly 2 edges, but points/edges from a sketch may form a more interesting graph:

    Unfortunately there are no direct Sets in FeatureScript, but since FS Maps have unique keys you can use the map as a set by either coming up with a hashing scheme or just using the object itself as the key (a deep copy is performed when storing a value as a key in a map https://cad.onshape.com/FsDoc/variables.html ).  There is as yet no implementation of a Graph in FeatureScript (besides what is temporarily happening in computeGraphInformation)
    Jake Rosenfeld - Modeling Team
  • johnsoggjohnsogg Member, Developers Posts: 14
    Good to know about sketches. My code should only receive edges adjacent to a face, so the function I'll write won't be generalizable to all edge queries.

    Also good to know wrt maps-as-sets. That's how it is done in Go, so I can port some of my own modeling code over.

    Appreciate the help & sorry to keep bugging you guys.
  • Jake_RosenfeldJake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,381
    No worries, happy to help
    Jake Rosenfeld - Modeling Team
Sign In or Register to comment.