[Closed] Assigning random face number to attachment constraint?
Hello.
I’m requesting some assistance. I need to place a number of objects on top of a model with attachment constraint to keep them in place. The number is too laboring to do by hand and I bet a simple script would do it in no time.
What I need is the ability to select objects and distribute them to the target mesh. Would it be simple to just make it look how many faces does the target mesh have and copy or instance an object so many times and at the same time set the face number to the attachment constraint?
I think it will need a for loop or something like that but I haven’t gotten around to there yet with my scripting skills. There might be something like this all ready but I didn’t find any at scriptspot.
Thank you!
Could anyone help me with my problem?
I’ve been searching the interwebs but have had no luck with this.
fn applyAttachment source target align:on = if isvalidnode source and iskindof target GeometryClass do
(
max create mode
num = target.mesh.numfaces
objs = for face=0 to num-1 collect
(
obj = instance source wirecolor:source.wirecolor
c = obj.position.controller = attachment()
c.align = align
c.node = target
attachCtrl.addnewkey c 0
k = attachCtrl.getkey c 1
k.face = face
-- k.coord = [0,0]
if c.manupdate do AttachCtrl.update c
obj
)
)
/*
delete objects
sp = sphere radius:100 segments:24 wirecolor:yellow
cn = pyramid height:10 width:5 depth:5 wirecolor:green
nodes = applyAttachment cn sp align:on
notifyDependents sp
*/
cool UI make yourself…