ScriptSpot

Forum topic · General Scripting

Cloned object single color

By Mrjacks2o · 2009-11-13

Description

Hi i cant seem to get the cloned source objects all the same color for example i want all the cloned objects to be red this is the code if anyone can help me out i will appreciate it thanks

----------------------

(
JM_float = NewRolloutFloater "JM" 120 400
(
(
)
fn fn_bs_img str1 = (#(getdir #scripts+"\3DJM\\"+str1 , undefined, 1, 1, 1, 1, 1))
(
local copyState=1,sourceObj,destinationObj

fn Align souCopy desNormal pos =
(
worldUpVector = [0,0,1]
rightVector = normalize (cross worldUpVector desNormal)
upVector = normalize ( cross rightVector desNormal)
theMatrix = matrix3 rightVector upVector desNormal Pos
souCopy.transform = theMatrix

)

fn CopySource numCopies=
(
case copyState of
(
1:
souCpy = for i = 1 to numCopies collect(copy sourceObj)
2:
souCpy = for i = 1 to numCopies collect(instance sourceObj)
default:
souCpy = for i = 1 to numCopies collect(reference sourceObj)

)
return souCpy
)
rollout Param "Parametershgh"
(
pickButton sourcePikBtn "Source" width:75 autoDisplay:true
pickButton destnationPikBtn "Destination" width:75
checkBox vertexChkBox "Vertex" checked:true
checkBox polygonChkBox "Polygon"
group "Copy option"
(
radioButtons copyOption labels:#("Copy", "Instance", "Reference") align:#left default:1
)

on sourcePikBtn picked sObj do
(
if sObj != undefined then
sourceObj=sObj
)
on destnationPikBtn picked dObj do
(
if(sourceObj != undefined) and (not isDeleted sourceObj) then
(
if(vertexChkBox.state == true or polygonChkBox.state == true) then
(
if dObj!= undefined then
(
destinationObj=dObj
If ((classOf destinationObj) == Editable_poly) then
(
if (polygonChkBox.state == true) then
(
numPolygon = destinationObj.getnumfaces()
Source =CopySource numPolygon
for i = 1 to numPolygon do
(
faceCentre= polyOp.getFaceCenter destinationObj i
faceNormal = polyOp.getFaceNormal destinationObj i
Align source[i] faceNormal faceCentre
)
)

if (vertexChkBox.state == true) then
(
numVertex = destinationObj.getNumVertices()
source =CopySource numVertex
editNormalsModifier=edit_Normals()
addModifier destinationObj editNormalsModifier
setCommandPanelTaskMode #modify
destinationVertex = #{}
destinationNormalIds = #{}
for i = 1 to numVertex do
(
select destinationObj
destinationVertex = #{i}
destinationObj.edit_Normals.convertVertexSelection &destinationVertex &destinationNormalIds
normalArray = destinationNormalIds as array
firstNormalValue = destinationObj.edit_Normals.getNormal normalArray[1]
vertexPos= polyOp.getVert destinationObj i
Align source[i] firstNormalValue vertexPos
)

deleteModifier destinationObj(editNormalsModifier)
)
)
else
messageBox "Select only Editable poly object" title:"Error"
)
)
else
messageBox "Select Vertex or/and Polygon" title:"Error"
)
else
messageBox "Select Source Object" title:"Error"
)
on copyOption changed State do
(
copyState=State
)
)
)
addRollout Param JM_float rolledUp:False
)
)

Comments (2)

Anubis · 2009-11-14

if you talk about wirecolor:

fn CopySource numCopies = (
	case copyState of
	(
	...
	)
	souCpy.wireColor = red -- add this to your fn
	souCpy
)

Mrjacks2o · 2009-11-14

Thanks allot worked like a charm :)