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.
How to do a simple rotation of cylinder around center point after a move?
jarrod_bellmore
Member Posts: 3 ✭
Hello!
I am pretty new to featurescript (though I am a software engineer in my day job). I have been able to do some of the basics like making a drawing plane, extruding the plane and moving bodies around but I can't seem to figure out how to do a basic rotation of a cylindrical body I have created. This seems like it should be a pretty simple thing to do so I am guessing I must be missing something!
The only example I can find seems to rotate the body around an axis relative to the world, not relative to itself. I basically just want to "spin" the object without having the object change position. Is there an example of this someone could point me towards?
Thank you!
I am pretty new to featurescript (though I am a software engineer in my day job). I have been able to do some of the basics like making a drawing plane, extruding the plane and moving bodies around but I can't seem to figure out how to do a basic rotation of a cylindrical body I have created. This seems like it should be a pretty simple thing to do so I am guessing I must be missing something!
The only example I can find seems to rotate the body around an axis relative to the world, not relative to itself. I basically just want to "spin" the object without having the object change position. Is there an example of this someone could point me towards?
Thank you!
0
Answers
https://forum.onshape.com/discussion/3590/transform-rotate-around-axis
So I guess my question is, how do I get the center line of the object? I tried creating a plan on the top face of the cylinder using evPlane and using the origin/normal to create the line to pass into rotationAround but that does not seem to be doing what I want.
In the forum post I linked to they show creating the line to rotate around like this:
precondition { annotation { "Name" : "Cylinder", "Filter" : EntityType.FACE && GeometryType.CYLINDER, "MaxNumberOfPicks" : 1 } definition.cyl is Query; annotation { "Name" : "Angle" } isAngle(definition.angle, ANGLE_360_BOUNDS); } { var axis = evAxis(context, { "axis" : definition.cyl }); var angle = rotationAround(axis, definition.angle); opTransform(context, id + "rotate", { "bodies" : qOwnerBody(definition.cyl), "transform" : angle }); });https://cad.onshape.com/documents/c5698e768c34d23543bbe7aa/w/ee5ffbf19da0ae5ae19c4dd0/e/f8faa9dc058fc1731f57c070