Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- 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_shirk
Member Posts: 103 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?
Tagged:
0
Comments
-
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.
3 -
Thank you! This side steps the problem and is a great general solution.
0 -
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.3
-
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.2 -
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.0
-
I just noticed this also. you can just call
qTopPlane(EntityType.FACE);
but you can also simply do this.
plane(vector(0,0,0)*meter,vector(0,0,1));
orplane( WORLD_ORIGIN,Z_AXIS);
or even faster
plane( WORLD_ORIGIN,Z_AXIS,X_AXIS);
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.
0


