[solved] How to reverse shape orientation (scale by -1)?

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
stefankorisnik3
Posts: 101
Joined: Sun Jul 24, 2022 12:49 pm

[solved] How to reverse shape orientation (scale by -1)?

Post by stefankorisnik3 »

I have a mesh.
How can i rotate (reshape) the mesh like in the mirror so the result mesh is in the same place as the start mesh?
I have tried following but the result mesh is not positioned where in the place of the start mesh .

Code: Select all

@staticmethod
	def reverseModelSideMesh(mesh):
		mat = App.Matrix()
		factor = -1
		mat.scale(factor,factor,factor)

		meshCopy = mesh.copy()
		meshCopy.transform(mat)
		meshCopy.flipNormals()
		return meshCopy
Last edited by stefankorisnik3 on Fri Aug 19, 2022 11:47 pm, edited 1 time in total.
edwilliams16
Veteran
Posts: 3106
Joined: Thu Sep 24, 2020 10:31 pm
Location: Hawaii
Contact:

Re: How to reverse shape orientation (scale by -1)?

Post by edwilliams16 »

Why are you reflecting all three axes instead of just one? The extra two are just generating a 180 degree rotation which you likely don't want.
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: How to reverse shape orientation (scale by -1)?

Post by openBrain »

What is the criteria defining the location of the original shape?
stefankorisnik3
Posts: 101
Joined: Sun Jul 24, 2022 12:49 pm

Re: How to reverse shape orientation (scale by -1)?

Post by stefankorisnik3 »

edwilliams16 wrote: Fri Aug 19, 2022 2:31 am Why are you reflecting all three axes instead of just one? The extra two are just generating a 180 degree rotation which you likely don't want.
This is what i get with the code:

Code: Select all

mat.scale(-1,0,0)
Screenshot (95).png
Screenshot (95).png (2.95 KiB) Viewed 329 times
openBrain wrote: Fri Aug 19, 2022 6:45 am What is the criteria defining the location of the original shape?
The criteria is given symmetric model
if we rotate with the algorithm "like in mirror" we get same model
edwilliams16
Veteran
Posts: 3106
Joined: Thu Sep 24, 2020 10:31 pm
Location: Hawaii
Contact:

Re: How to reverse shape orientation (scale by -1)?

Post by edwilliams16 »

Code: Select all

mat.scale(-1,0,0)
You obviously don't want that. Maybe

Code: Select all

mat.scale(-1,1,1)
to reflect in the YZ plane
stefankorisnik3
Posts: 101
Joined: Sun Jul 24, 2022 12:49 pm

Re: How to reverse shape orientation (scale by -1)?

Post by stefankorisnik3 »

Yes that's what i need. You guessed the right planes YZ :)
Thanks
Post Reply