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: 96 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?


  • Options
    antlu65antlu65 Member Posts: 55 EDU
    edited August 2022
    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.

  • Options
    monroe_weber_shirkmonroe_weber_shirk Member Posts: 96 EDU
    Thank you! This side steps the problem and is a great general solution.
  • Options
    Evan_ReeseEvan_Reese Member Posts: 2,070 PRO
    edited August 2022
    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
  • Options
    Jacob_CorderJacob_Corder Member Posts: 129 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)
           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.
  • Options
    monroe_weber_shirkmonroe_weber_shirk Member Posts: 96 EDU
    Jacob, this is a long overdue response that got lost in my drafts! Thank you! This code is great. I think one of my challenges in writing FS code is that it is hard to know how to search for these code examples.
  • Options
    Jacob_CorderJacob_Corder Member Posts: 129 PRO
    I just noticed this also. you can just call  


    but you can also simply do this.

    plane( WORLD_ORIGIN,Z_AXIS);
    or even faster
    and even faster yet
     {"origin":WORLD_ORIGIN,"normal": Z_AXIS,"x": X_AXIS} as Plane;// this i believe bypasses the plane function to normalize already normalized vectors.

Sign In or Register to comment.