ScriptSpot

Forum topic · Scripts Wanted

3-point* Mirror

By 1rv · 2017-08-22

Description

Could anybody write the subject please?
Something like Autocad's Mirror3d (Sketchup has similar plugin too)
*3 mouse clicks would define a mirror plane

Thanks in advance

Comments (11)

Symmetry instead??

alexbls · 2020-01-30

Thanks Jahman,

I've tried to modify the script using "Symmetry" instead "mirror" modifier but does'n really work...
can you please tell me how can I do it?

Many thanks
Alessandro

.

jahman · 2020-01-30

just change mirror modifier properties with corresponding symmetry modifier properties
if you don't know what properties to change select object with symmetry mod and
run show $.modifiers[1]

thanks for your reply

alexbls · 2020-01-30

this is what I did... and, sorry but I'm not so good in scripting :)

(
tool pick3points (

local p1,p2,p3

on mousePoint clickno do (

case clickno of (

1: p1 = worldpoint
3: p2 = worldPoint
4: (

p3 = worldPoint
stopTool pick3points
#( p1, p2, p3 )

)
default:()

)

)

on mouseMove clickno do redrawViews()

on mouseAbort val do (

stopTool pick3points
undefined
)

)

if selection.count > 0 do (

pts = starttool pick3points

if pts != undefined do (

norm = normalize (cross (pts[2] - pts[1]) (pts[3] - pts[1]))

center = (pts[1] + pts[2] + pts[3]) / 3.0

for s in selection do (

try (

addModifier s (m = Symmetry())

m.Symmetry_axis = 1
m.Symmetry_flip = boolean
m.Symmetry_slice = 1
m.Symmetry_weld = (Weld_Seam) : 0
m.Symmetry_threshold = 0.1

)catch()
)

)
)
)

.

jahman · 2020-01-30

that's what props these two modifier have

mirror:Mirror
.copy : boolean
.offset (Mirror_Offset) : float
.mirror_axis : integer
.Mirror_Center : transform

symmetry:Symmetry
.axis : integer
.flip : boolean
.slice : integer
.weld (Weld_Seam) : integer
.threshold : float
.Mirror : transform

replacing Mirror_Center with Mirror should be enough I think

alexbls · 2020-01-30

Sorry Jahaman, but I'm really struggling to understand... for me is like another language! :D
I would be grateful if you can show me how to modify the script...

Thank you very much!

_

jahman · 2020-01-30


try (
 
			/*
			addModifier s (m = mirror()) 
 
			m.mirror_axis = 2
			m.Mirror_Center.rotation = inverse (MatrixFromNormal norm).rotation
			m.Mirror_Center.scale = [1,1,1]
			m.Mirror_Center.position = (center - s.pos)
			*/
				
			addModifier s (m = symmetry()) 
 
			m.axis = 2
			m.mirror.rotation = inverse (MatrixFromNormal norm).rotation
			m.mirror.scale = [1,1,1]
			m.mirror.position = (center - s.pos)
				
			)catch()

alexbls · 2020-02-04

Thank you very much!! :)

1rv · 2017-08-27

Miauu, could you please add 'keep original' option?
and there's a bug: oddly the script mirrors ALL instances (not only the ones are preselected)

1rv · 2017-08-23

Thank you Miauu! Please check PM.

_

jahman · 2017-08-23


(
tool pick3points (
		
	local p1,p2,p3
	
	on mousePoint clickno do (
		
		case clickno of (
			
			1: p1 = worldpoint
			3: p2 = worldPoint			
			4: (
				
				p3 = worldPoint	
				stopTool pick3points
				#( p1, p2, p3 )
				
			)
			default:()			
			
		)
		
	)
	
	on mouseMove clickno do redrawViews()
		
	on mouseAbort val do (
		
		stopTool pick3points
		undefined
	)
	
)

if selection.count > 0 do (
	
	pts = starttool pick3points

	if pts != undefined do (

		norm = normalize (cross (pts[2] - pts[1]) (pts[3] - pts[1]))
		
		center = (pts[1] + pts[2] + pts[3]) / 3.0

		for s in selection do (

			try (
				
			addModifier s (m = mirror()) 

			m.mirror_axis = 2
			m.Mirror_Center.rotation = inverse (MatrixFromNormal norm).rotation
			m.Mirror_Center.scale = [1,1,1]
			m.Mirror_Center.position = (center - s.pos)
			
			)catch()
		)
		
	)
)
)

.

miauu · 2017-08-22

I will.