ScriptSpot home

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)
alessandro

Symmetry instead??

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

Reply to alessandro
Panteleev Sergey

.

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]

Reply to Panteleev Sergey
alessandro

thanks for your reply

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()
)

)
)
)

Reply to alessandro
Panteleev Sergey

.

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

Reply to Panteleev Sergey
alessandro

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!

Reply to alessandro
Panteleev Sergey

_


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()
1rv

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

Thank you Miauu! Please check PM.

Panteleev Sergey

_


(
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

.

I will.