' ---------------------------------------------------
' InstanceLatticeSymmetry v.1 Sept 28 2002 (C) GDC 2002
' by Graham D Clark http://www.grahamdclark.com
' mail@grahamdclark.com
' ---------------------------------------------------
'
'   Description:
'     instances selected objects 
'     and mirrors over yz plane/x axis
'     using a lattice 
'     allowing pos/rot/scl mirror modeling of objects
'
'   Use:
'     Select Objects individually, not Branch 
'     to mirror model, run script.
'     When done mirror modeling you may wish to
'     Select all instanced objects when done
'     and freeze to remove lattice ops and cut
'     unparent from originals if nessessary,
'	  or delete them and reinstance the originals
'     using another mirror method before use
'
'     If you wish to work away from the global center
'     or moving the parent model null of the instanced 
'     objects screws, well moves them away from each 
'     other relative to global world center, then
'     parent the lattice to the parent model/null 
'
'	Limitations:
'	  Does not work with nulls for now
'
' ---------------------------------------------------
dim list, listnonulls, listNoLAttice, test
test = 1
set list = GetValue( "SelectionList" )
set listNoNulls = SIFilter (list, "null", false)
SelectAll
set listNoLattice = GetValue( "SelectionList" )
For Each oItem In listNoLattice  
if oItem.Name = "MirrorLattice" then
test = 0
else
end if
next
DeselectAll
if test = 1 then
	CreatePrim "Cube", "MeshSurface", "LatticeDummy"
	GetPrimLattice , "LatticeDummy", "MirrorLattice"
	SetValue "MirrorLattice.lattice.subdivx", 1
	SetValue "MirrorLattice.lattice.subdivy", 1
	SetValue "MirrorLattice.lattice.subdivz", 1
	Translate MirrorLattice, 0, 0, 0, 0, siGlobal, siObj, siXYZ
	CutObj "MirrorLattice"
	DeleteObj "LatticeDummy"
	'from Duplicate Symmetry script on XSINET by Softimage
	Set XSIDial = createobject("XSIDial.XSIDialog")
		Combo = Array("XY Plane","XZ Plane","YZ Plane")
		Plane = XSIDial.Combo( "Select Plane of Symmetry:", Combo)
		
		Select Case Plane 
		Case 0
			Scale MirrorLattice, 1, 1, -1, siAbsolute, siLocal, siObj
		Case 1
			Scale MirrorLattice, 1, -1, 1, siAbsolute, siLocal, siObj
		Case 2
			Scale MirrorLattice, -1, 1, 1, siAbsolute, siLocal, siObj
		end Select 
end if
For Each oItem In listnonulls             
	set thisy = Instance (oItem, [NbItems], siNoParent, siNoGrouping, [Properties], [Animation], [Constraints], 1, [Xfrom], [Sx], [Sy], [Sz], [Rx], [Ry], [Rz], [Tx], [Ty], [Tz], False)
	ApplyOp "Lattice", thisy &";MirrorLattice", 3, siPersistentOperation
	ApplyTopoOp "Inverse", thisy, 3, siPersistentOperation
    set oCurrent = oItem
	ParentObj oCurrent, thisy
Next
SetValue "MirrorLattice.visibility.viewvis", False


