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.

multiple select

papawopapawo Member, Developers Posts: 206 PRO
 Im trying to select a point then create a circle and loop again.
where can i insert the sketchId so i can have a diff Id everytime it loop.



 for (var i = 0; i < numberOfPoints; i += 1) 
        if (definition.TypesOfHoles ==TypesOfHoles.TRANSOMHOLE )
        {
            sketchId = sketchId + i;
            skCircle(skTransomHole, "circle1" , {
                    "center" : vector(0, 0) * inch,
                    "radius" : .25 * inch
            });
            skSolve(skTransomHole);
            println(sketchId);
             

Comments

  • kevin_o_toole_1kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565
    Sketch ids, unlike feature ids, are just plain strings. So the overloaded "+" operator that makes a sub-id doesn't work.

    FS string concatenation uses the "~" operator, so you should instead use e.g.:
    sketchId = "someId" ~ i;

  • kevin_o_toole_1kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565
    edited October 2016
    Sorry, I misread your code and your question. Let me give a better answer.

    You can insert a unique sketch id as the "id" parameter in the call to skCircle, e.g.:
                skCircle(skTransomHole, "circle" ~ i , {
                        "center" : vector(0, 0) * inch,
                        "radius" : .25 * inch
                });
    Also, you should call skSolve only once, at the end of the sketch feature, after all entities have been added to the sketch.
  • papawopapawo Member, Developers Posts: 206 PRO
    edited October 2016
     I tried what you suggested and picked 2 points but it doesnt do the 2nd sketch,
    i added a  println( "circle1"~i);; and it shows me diff   Id

     { 
            for (var i = 0; i < numberOfPoints; i += 1) 
            if (definition.TypesOfHoles ==TypesOfHoles.TRANSOMHOLE )
           
            {
                skCircle(skTransomHole, "circle1"~i , {
                "center" : vector(0, 0) * inch,
                "radius" : .25 * inch
                });
                println( "circle1"~i);
                println ("a");
              
            }}
             skSolve(skTransomHole);
        
            
  • kevin_o_toole_1kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565
    You won't see two circles unless you place them in different positions. Your current code puts both circles centered at vector(0, 0) — the origin of the sketch.

    To get the circles positioned correctly, you'll need to calculate the position of each circle as a 2D vector on the sketch plane, and pass that vector as the "center" argument of skCircle.
  • papawopapawo Member, Developers Posts: 206 PRO
     can you please show me an example.
  • kevin_o_toole_1kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565
    The position of the sketch (and the position of the circles within that sketch), will need to be calculated based on what you want this feature to do.

    Here's an example that takes in sketch points and draws circles around them on their sketch planes:
    https://cad.onshape.com/documents/75e57c1e19ec6d534fb18b97/w/24279c587ff21cf8bd9ae49b/e/a32b15596565802fe644c917
  • papawopapawo Member, Developers Posts: 206 PRO
    edited October 2016
    im new on this and thank you for giving me direction ! :)
  • papawopapawo Member, Developers Posts: 206 PRO
    how to make this item as "answered"?
Sign In or Register to comment.