Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

**First time visiting? Here are some places to start:**

- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- 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.

Options

# constructPath using faces with holes

johnsogg
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

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?
Tagged:

0

## Comments

1,646There 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."

14✭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.

1,646Sounds 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)

14✭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.

1,646