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.

FS cPlane angled plane

graham_lockgraham_lock Member Posts: 148 PRO
Hi,

I'm trying to create an angled plane using the code below:

var sketch = newSketchOnPlane(context, id + "angledPlaneSketch", {
                    "sketchPlane" : refPlane
            });
            
            // draw line for angled plane
            var lineMap = skLineSegment(sketch, "angledPlaneLine", {
                    "start" : vector(0, 0) * millimeter,
                    "end" : vector(50, 0) * millimeter
            });
            
            skSolve(sketch);
            
            // now create angled plane            
            cPlane(context, id, {
                "entities" : qCreatedBy("angledPlaneLine"),
                "cplaneType": CPlaneType.LINE_ANGLE,
                "angle": definition.angle,
                "oppositeDirection" : definition.angleDirection
                }
            );

I'm not sure if this is the way to go about it?

If it is the correct way how do I pass the sketch line to cPlane? qCreatedBy currently fails.

Thank you.

Best Answer

  • Caden_ArmstrongCaden_Armstrong Member Posts: 180 PRO
    Answer ✓
    You are probably better off using opPlane. Ultimately, cPlane is calling opPlane, it just has some extras for the user.
    All you would need to do is calculate the normal direction of your plane (and the origin), which will be a lot less work.

    qCreatedBy is failing because the Id is that of a sketch entity, but that query type takes in the feature id ("angledPlaneSketch"). To use that sketch line, you need to do something like qCreatedBy(id + "angledPlaneSketch", EntityType.EDGE); As its the only line in the sketch, quering for all edges made by the sketch should produce only that edge.
    Or you can do sketchEntityQuery(id + "angledPlaneSketch", EntityType.EDGE, "angledPlaneLine"); if you were to have multiple sketch lines.

    www.smartbenchsoftware.com --- fs.place --- Renaissance
    Custom FeatureScript and Onshape Integrated Applications

Answers

  • Caden_ArmstrongCaden_Armstrong Member Posts: 180 PRO
    Answer ✓
    You are probably better off using opPlane. Ultimately, cPlane is calling opPlane, it just has some extras for the user.
    All you would need to do is calculate the normal direction of your plane (and the origin), which will be a lot less work.

    qCreatedBy is failing because the Id is that of a sketch entity, but that query type takes in the feature id ("angledPlaneSketch"). To use that sketch line, you need to do something like qCreatedBy(id + "angledPlaneSketch", EntityType.EDGE); As its the only line in the sketch, quering for all edges made by the sketch should produce only that edge.
    Or you can do sketchEntityQuery(id + "angledPlaneSketch", EntityType.EDGE, "angledPlaneLine"); if you were to have multiple sketch lines.

    www.smartbenchsoftware.com --- fs.place --- Renaissance
    Custom FeatureScript and Onshape Integrated Applications
  • graham_lockgraham_lock Member Posts: 148 PRO
    Thank you.
Sign In or Register to comment.