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.
Transform sketch entities
Hi,
I've been unsuccessful in finding an example of transforming sketch entities.
In my use case I need to rotate a rectangle about its centre.
So far I have:
skRectangle(sketchStartFormer, "rectangleStartFormer", {
"firstCorner" : vector(centreStartXmm - (width / 2), centreStartYmm - (height / 2)),
"secondCorner" : vector(centreStartXmm + (width / 2), centreStartYmm + (height / 2))
});
const rotationMatrix = [[cos(startRotation), -sin(startRotation)], [sin(startRotation), cos(startRotation)]] as Matrix;
How do I apply this (if it's correct) to the rectangle and rotate it about its center?
Thank you.
Best Answer
-
Caden_Armstrong Member Posts: 169 PRO
You have a few different options,
- Calculate the four corners and create 4 line segments (this is how onshape does aligned rectangles, probably how I would do it in this case).
- Create rectangle, solve the sketch, and use opTransform to rotate it, just note that opTransform takes in a transform not a matrix.
- Create the rectangle and use sketch constraints to rotate it (personally my least favourite option)www.smartbenchsoftware.com --- fs.place --- Renaissance
Custom FeatureScript and Onshape Integrated Applications0
Answers
You have a few different options,
- Calculate the four corners and create 4 line segments (this is how onshape does aligned rectangles, probably how I would do it in this case).
- Create rectangle, solve the sketch, and use opTransform to rotate it, just note that opTransform takes in a transform not a matrix.
- Create the rectangle and use sketch constraints to rotate it (personally my least favourite option)
Custom FeatureScript and Onshape Integrated Applications
Thank you