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.

transform rotate around axis

adamohernadamohern Member, OS Professional Posts: 216 PRO
edited April 2016 in FeatureScript
opTransform(context, id + "transform1", {
        "bodies" : qCreatedBy(id + ("profileSketch")),
        "transform" : transform({
            "transformType" : TransformType.ROTATION,
            "angle" : definition.axialRotation * degree,
            "transformAxis" : ???
            })
});

I want to rotate a sketch around its z axis. I was hoping that the above would get me there. For the purposes of this thread, let's assume I was correct in my approach.

Note that "transformAxis" wants a Query. I don't have a transform axis. It would be trivial to create a Line using the sketch plane's origin and normal, but I don't think I can query that (can I?). A workaround is to create a sketch on a perpendicular plane, add a line to it, then query that line. This seems like a lot of runaround for something so simple. Is there a better way?

Comments

  • ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 1,211
    The problem here is due to confusion between transform the feature and functions to create an actual transform.  The opTransform documentation has some examples you can use -- one of them (the one you want) is using rotationAround, which takes a Line and an angle:

            const zAxis = line(vector(0, 0, 0) * meter, vector(0, 0, 1));
            opTransform(context, id + "transform1", {
                    "bodies" : qCreatedBy(id + ("profileSketch")),
                    "transform" : rotationAround(zAxis, definition.axialRotation)
            });

    Note that if you asked for definition.axialRotation in the precondition using isAngle, you shouldn't multiply by degree (because it's already an angle).
    Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc
  • adamohernadamohern Member, OS Professional Posts: 216 PRO
    The opTransform documentation has some examples you can use

    Oh dear. What did I miss? I just double-checked and didn't find any examples in the source or reference. Where are they?
  • ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 1,211
    Ah, my bad -- I was looking at the not-yet-released version of the library -- we have a number of documentation improvements on the way.
    Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc
Sign In or Register to comment.