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.

Can I create sketch conics with Featurescript?

EvanReeseEvanReese Member, Mentor Posts: 2,135 ✭✭✭✭✭
I expected it to be as easy as skConic but I'm not seeing the option in the documentation. Is it hidden somewhere or not possible for some reason?
Evan Reese

Best Answer

  • mahirmahir Member, Developers Posts: 1,307 ✭✭✭✭✭
    Answer ✓
    @Evan_Reese, I found this in the std source. Might be what you already found, but just in case...

     * Creates a conic section with the given rho value through the start and end points using the control point.
     * If x is the distance between controlPoint and the line between start and end, and y is the maximum distance between
     * the conic section and the same line, then rho is x/y.
     * @param sketch : @autocomplete `sketch1`
     * @param conicId : @autocomplete `"conic1"`
     * @param value {{
     *      @field start {Vector} :
     *              @eg `vector(0, 0) * inch`
     *      @field controlPoint {Vector} :
     *              @eg `vector(0.5, 0.5) * inch`
     *      @field end {Vector} :
     *              @eg `vector(1, 0) * inch`
     *      @field rho {number} : 0 < rho < 0.5 => elliptical arc, rho = 0.5 => parabola, 0.5 < rho < 1 => hyperbola
     *              @eg `0.5`
     *      @field lowParameter {number} : starting parameter of the segment @optional
     *      @field highParameter {number} : ending parameter of the segment @optional
     *      @field construction {boolean} : `true` for a construction conic @optional
     *      @field fixedRho {boolean} : `true` to fix rho during sketch solve @optional
     * }}
     */
    export function skConicSegment(sketch is Sketch, conicId is string, value is map)
    precondition
    {
        value.start is undefined || is2dPoint(value.start);
        value.end is undefined || is2dPoint(value.end);
        value.controlPoint is undefined || is2dPoint(value.controlPoint);
        value.rho is undefined || value.rho is number;
        value.lowParameter is undefined || value.lowParameter is number;
        value.highParameter is undefined || value.highParameter is number;
        value.construction is undefined || value.construction is boolean;
        value.fixedRho is undefined || value.fixedRho is boolean;
    }
    {
        return @skConicSegment(sketch, conicId, value);
    }

Answers

  • konstantin_shiriazdanovkonstantin_shiriazdanov Member Posts: 1,221 ✭✭✭✭✭
    edited December 2020
    If you create a new part studio with the only sketch in it and add in the sketch the only conic ark and then show part studio code, you will see skConicSegment() function call in the sketch. But it has no any untrivial parameters, seems like they all are set as sketch constraints.
  • EvanReeseEvanReese Member, Mentor Posts: 2,135 ✭✭✭✭✭
    Ah, I hadn't thought to check there. Thanks! After poking around with that a bit I found an array, which has values that correspond to my conic inside the initialGuess const. I did get skConicSegment() to make a conic, but it seems like a generically positioned one and I'm not sure how to give it the values I want. Even copy/pasting the whole section of code doesn't seem to make anything work. Sounds like I should back up and look into using splines?
    Evan Reese
  • mahirmahir Member, Developers Posts: 1,307 ✭✭✭✭✭
    Answer ✓
    @Evan_Reese, I found this in the std source. Might be what you already found, but just in case...

     * Creates a conic section with the given rho value through the start and end points using the control point.
     * If x is the distance between controlPoint and the line between start and end, and y is the maximum distance between
     * the conic section and the same line, then rho is x/y.
     * @param sketch : @autocomplete `sketch1`
     * @param conicId : @autocomplete `"conic1"`
     * @param value {{
     *      @field start {Vector} :
     *              @eg `vector(0, 0) * inch`
     *      @field controlPoint {Vector} :
     *              @eg `vector(0.5, 0.5) * inch`
     *      @field end {Vector} :
     *              @eg `vector(1, 0) * inch`
     *      @field rho {number} : 0 < rho < 0.5 => elliptical arc, rho = 0.5 => parabola, 0.5 < rho < 1 => hyperbola
     *              @eg `0.5`
     *      @field lowParameter {number} : starting parameter of the segment @optional
     *      @field highParameter {number} : ending parameter of the segment @optional
     *      @field construction {boolean} : `true` for a construction conic @optional
     *      @field fixedRho {boolean} : `true` to fix rho during sketch solve @optional
     * }}
     */
    export function skConicSegment(sketch is Sketch, conicId is string, value is map)
    precondition
    {
        value.start is undefined || is2dPoint(value.start);
        value.end is undefined || is2dPoint(value.end);
        value.controlPoint is undefined || is2dPoint(value.controlPoint);
        value.rho is undefined || value.rho is number;
        value.lowParameter is undefined || value.lowParameter is number;
        value.highParameter is undefined || value.highParameter is number;
        value.construction is undefined || value.construction is boolean;
        value.fixedRho is undefined || value.fixedRho is boolean;
    }
    {
        return @skConicSegment(sketch, conicId, value);
    }

  • EvanReeseEvanReese Member, Mentor Posts: 2,135 ✭✭✭✭✭
    thanks @mahir
    I had not looked there so thanks for double-checking. I'm still not the best at knowing where to check for this stuff I guess. That got it working for me as expected
    Evan Reese
  • mahirmahir Member, Developers Posts: 1,307 ✭✭✭✭✭
    No problem. Yeah, there's all sorts of easter eggs in the source. It's pretty crazy that basically all of OS is open source.
Sign In or Register to comment.