3-point* Mirror

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

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
alexbls's picture

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

jahman's picture

.

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]

alexbls's picture

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

)
)
)

jahman's picture

.

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's picture

Sorry Jahaman, but I'm really

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's picture

_

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's picture

Thank you very much!! :)

Thank you very much!! :)

1rv's picture

Miauu, could you please add

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's picture

Thank you Miauu! Please check

Thank you Miauu! Please check PM.

jahman's picture

_

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

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.