ScriptSpot

Forum topic · ScriptSpot How To

Attaching objects by list

By thekevnn · 2012-12-03

Description

Hi guys, anyone kindly guide me on how to attach multiple objects to an editable poly, without making a selection in the viewport, but attaching them by list. Any help highly appreciated. thanks

ps. I've gone through previous similar posts but couldn't get a similar scenario.

Comments (8)

thekevnn · 2012-12-04

hey barigazy,
I finally got it working. you were right, attachlist is a bit complicated so I'm using the first method. It looked intimidating at first but I've managed to figure most of it out, maybe coz I'm a n00b. I appreciate the help… ill be posting the script once I'm done. cheers!

Try this

barigazy · 2012-12-03


fn geoFilter obj = isKindOf obj geometryClass and not isKindOf obj TargetObject
fn attachSelections nodesArr = if isKindOf nodesArr array and nodesArr.count >1 do
(
local cnt = 1
local poAttach = polyop.attach
if not isKindOf nodesArr[1] Editable_Poly do convertToPoly nodesArr[1]
while nodesArr.count > 1 do
(
cnt += 1
poAttach nodesArr[cnt-1] nodesArr[cnt]
deleteItem nodesArr cnt
if cnt >= nodesArr.count do cnt = 1
) ; nodesArr[1]
)
theObjs = selectByName title:"Select Objects" buttonText:"Attach!" filter:geoFilter showHidden:true single:false
attachSelections theObjs

thekevnn · 2012-12-03

thanks barigazy, I'll try & decipher that into my macroscript. i'll provide some feedback soon as I'm done. thanks alot

barigazy · 2012-12-03

my pleasure :)

FEEDback

thekevnn · 2012-12-03

hello barigazy, I've tried to implement your script utilizing 'iskindof' function but I'm miserably lost. However I came across this in the 3ds maxscript help docs. under Attach/Detach methods>

AttachList <&node array>nodesToAttach editPolyNode:

...when I attempt to use AttachList as outlined in the document I get syntax error. please advise. thanks in advance

barigazy · 2012-12-03

AttachList method is interface operation of Edit_Poly modifier
To perform this operation you need to be in modifier panel.
This is the first of many disadvantage.Use my method (fester for sure).
example editPoly attach list method:

boxObj = Box isSelected:on
addmodifier boxObj (Edit_Poly())
sphObj1 = Sphere pos:[-30,30,0] radius:5
sphObj2 = Sphere pos:[30,-30, 0] radius:5
sphArr = #(sphObj1,sphObj2)
max modify mode -- if u use "max create mode" then code not works
boxObj.Edit_Poly.AttachList &sphArr editPolyNode:boxObj

Thanks

thekevnn · 2012-12-04

hey barigazy,
I finally got it working. you were right, attachlist is a bit complicated so I'm using the first method. It looked intimidating at first but I've managed to figure most of it out, maybe coz I'm a n00b. I appreciate the help… ill be posting the script once I'm done. cheers!