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.

Sketch constraints using another sketch?

caden_armstrongcaden_armstrong Member, User Group Leader Posts: 9 PRO
I am creating a sketch using featurescript that is using skConstraint.
I can create constraints for sketch elements within the same sketch, but is it possible to constraint to an element of another sketch?
I can do this in the user interface, ex make a point coincident with one of a different sketch.
Is there a way to do this with featurescript? Since the skConstraint is undocumented its a bit of a black box on what it can/cannot do.

If anyone has any info it would be greatly appreciated.

Comments

  • Jacob_CorderJacob_Corder Member Posts: 34 PRO
    edited January 7
    Sure can.

    use "externalSecond" or "externalFirst"
    skConstraint(sk, "arcBottomTangent", {
                            "constraintType" : ConstraintType.TANGENT,
                            "localFirst" : "offsetArc",
                            "externalSecond" : someCurveQuery
                        });

    where skArc(sk,"offsetArc") is the arc


    I have found sketch constraints extremely unreliable as they do not always solve nor tell you that they didn't solve. I normally evaluate the edges created to determine if tangency or coincident actually occurred. I have tried setting initial guess also, however this is a tough one and rarely seems to fix constraints that are not resolving. I think i have had the initial guess work for me once or twice.
  • caden_armstrongcaden_armstrong Member, User Group Leader Posts: 9 PRO
    Thanks Jacob!

    Works exactly as expected.
  • ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 1,015
    Yes, sketch constraints and FeatureScript are not as great a mix as we would like.  The general recommendation is to get the geometric information using evSomething functions, use that to do explicit computations in FS and create the sketch entities in the right place without constraints.
    Ilya Baran \ Director, Architecture and FeatureScript \ Onshape Inc
Sign In or Register to comment.