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.

Projection of an edge onto a sketch

prajwal_shankarprajwal_shankar Member, Developers Posts: 11
considering  I have an edge selected(input) and would like to project that edge onto a sketch from a feature script, using the 'skConstraint' command in the feature script is the solution but i am unable to figure out the syntax for using the 'Projected' constraint type in this situations. any suggestions????

Comments

  • mahirmahir Member, Developers Posts: 1,307 ✭✭✭✭✭
    Strange. You're right. There is no guidance in the help file. Try feeding in an "entities" property with a value equal to a query with your input edge(s) (faces may not work directly without querying for a boundary).
  • emmett_weeksemmett_weeks Onshape Employees Posts: 29
    The projection constraint is not particularly useful when writing featurescript. When clicking the 'use' tool in a sketch, two things happen:
    1) The external geometry is projected into the sketch.
    2) Up to three projected constraints are made, one for the curve and one for each end point if the curve is open.

    To perform step 1 manually, put a curve into the sketch that will have the same geometry type as the projected edge: spline, circle, ellipse, line.
    Step 2 is a little more complicated, the important parameters are: 
    "projectionType" which should be SketchProjectionType.USE for an edge and SketchProjectionType.USE_END for a vertex.
    "localFirst" this is a query for the sketch entity that the constraint is being applied to.
    "externalSecond" this is a query for the edge being projected. It should be a coedge query, but I don't believe that is strictly required.
    For a vertex, "externalSecond" is replaced with 
    "externalVertex" and "externalVertexEdge" which are vertex and coedge queries respectively.

    You can put in a request for a featurescript function that will do all of this for you. For now, I suggest attempting this as a solid modeling operation. An extrude or sweep followed by a split face is much simpler and covers most of the same use cases.
  • prajwal_shankarprajwal_shankar Member, Developers Posts: 11
    @emmett_weeks - what if i need the projection to be interactive in my FS, like it should project any edge(query) i select....it may be an edge or a query?????

    how do i ask OnShape to help me create this Custom FS?
  • mahirmahir Member, Developers Posts: 1,307 ✭✭✭✭✭
    I think Emmet pretty much told you what needs to be done. It's just complicated. You're probably better off submitting an enhancement request or voting for an existing one if someone has already submitted one. 
  • emmett_weeksemmett_weeks Onshape Employees Posts: 29
    For now, you're best off submitting an improvement request and looking for a workaround. Since I don't know what you want to do with the projected edge, it's hard to say what workaround would be best, but extruding or sweeping it into a surface and then splitting that surface on the sketch plane is your best bet.
  • maximilian_schommermaximilian_schommer Member Posts: 32 ✭✭
    edited July 2019
    @emmett_weeks
    I can't seem to get the projection constraint to do anything. When I call skConstraint with the following arguments (where entities[0] is a vertex), the original sketch point does not move. 

    skConstraint(sketch1, "projectConstraint", {"constraintType" : ConstraintType.PROJECTED, "projectionType" : SketchProjectionType.USE_END, "localFirst" : "point1", "externalVertex" : entities[0]});
    However, when I call it with these arguments, it works: 

    skConstraint(sketch1, "projectConstraint", { "constraintType" : ConstraintType.COINCIDENT, "externalFirst" : vertices[0], "localSecond" : "point1" });
    Is there more information on how to use projection constraints? I'm having a difficult time following the procedure you laid out above, especially since there is no use of projection constraints in the standard library. 

    There also seems to be no obvious way to "project" spline curves (or other non-line/point/arc types of geometry found in external references). 

    Max
Sign In or Register to comment.