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.

Cone Script

jensen_brightmanjensen_brightman Member Posts: 8

I am trying to make a simple script that creates a cone, but I cant seem to get the opRevolve method to work

  const frontSketchId = id + "frontSketch";
  const radius = 1;
  const height = 3;

  // Create a new sketch on the front plane
  var frontSketch = newSketch(context, frontSketchId, {
          "sketchPlane" : qCreatedBy(makeId("Front"), EntityType.FACE)
      });

  skLineSegment(frontSketch, "axis", {
              "start" : vector(0, 0) * centimeter,
              "end" : vector(0, height) * centimeter
          });

  // Add a line for the cone profile
  skLineSegment(frontSketch, "profile", {
              "start" : vector(0, 0) * centimeter,
              "end" : vector(radius, height) * centimeter
          });

  // Solve the sketch
  skSolve(frontSketch);

  // Use opRevolve to create the cone
  opRevolve(context, id + "revolve", {
      "entities": qCreatedBy(frontSketchId, EntityType.FACE),
      "axis": qCreatedBy(frontSketchId, EntityType.EDGE),
      "angle": 360 * degree
  });

The error looks like this

Thanks in advance for any response 😃

Comments

  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,671

    You need one more skLineSegment to close the profile if you want a solid (or not if you want a surface), but the main problem is your axis - you're giving it all the edges from the sketch and it needs one. Best just to use vector(0,0,1).

    Senior Director, Technical Services, EMEAI
Sign In or Register to comment.