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.

Create a query from a Z_AXIS

monroe_weber_shirkmonroe_weber_shirk Member Posts: 74 EDU
I am using circularPattern in FeatureScript. It requires the axis of rotation as a query. I want to rotate around the Z_AXIS. How do I convert the Z_AXIS into a query?

Comments

  • antlu65antlu65 Member Posts: 55 EDU
    edited August 11
    I was wondering the same awhile back. I don't know if this helps, but you might consider using 'opPattern' with 'rotationAround' instead of 'circularPattern'. That's what I ended up doing.

    Example here:
    const axis = Z_AXIS;
    var Ta = [];   // Array of transforms to apply.
    var names = [];   // Array of instance names.
    for (var i = 1; i < n; i += 1)
    {
       Ta = append(Ta, rotationAround(axis, i*360*degree / n));
       names = append(names, toString(i));
    }
    opPattern(context, patternId, {
       "entities" : qEntity,
       "transforms" : Ta,
       "instanceNames" : names
    });
    For patterning bodies and faces, this should produce the same result as using 'circularPattern'. A benefit is you aren't restricted to rotations about an axis.

  • monroe_weber_shirkmonroe_weber_shirk Member Posts: 74 EDU
    Thank you! This side steps the problem and is a great general solution.
  • Evan_ReeseEvan_Reese Member Posts: 1,464 PRO
    edited August 12
    The circularPattern feature is looking for a query, as you found. opPattern just uses transforms and is the better solution like you said. If you ever needed to get a query of a line for an axis you have to create the actual geometry and then delete it. You could make a sketch line on the front or right plane; a sketch circle on the top plane; a mate connector at the origin; or a 2-point fit spline. There may be others too, but generally opPattern will be easier to code (though less like actual modeling), and faster to regenerate.
    Evan Reese / Principal and Industrial Designer with Ovyl
    Website: ovyl.io
  • Jacob_CorderJacob_Corder Member Posts: 69 PRO
    if you want the Top plane to get the z axis from, you can simply call qCreatedBy(makeId("Top"),EntityType.FACE)

    annotation { "Feature Type Name" : "top plane axis" }
    export const topPlaneAxis = defineFeature(function(context is Context, id is Id, definition is map)
        precondition
        {
           
        }
        {
           var topPlane = qCreatedBy(makeId("Top"),EntityType.FACE);
           addDebugEntities(context, topPlane, DebugColor.RED);
           var tPlane = evPlane(context, {
                   "face" : topPlane
           });
           addDebugArrow(context, tPlane.origin, (tPlane.normal*25*millimeter) + tPlane.origin, 5 * millimeter, DebugColor.RED);
        });

    default features should always exist.  I am not saying this is the way to do it, but it is a way to do it.
Sign In or Register to comment.