Notifications
Clear all
[Closed] Substitute modifier node position
Jan 15, 2014 7:14 pm
Hi,
adding a substitute modifier and selecting the object by script.
My problem is that the result is slightly shifted compared to picking the node by hand on the modpanel.
Here’s the code (bbox code ripped by soulburn scripts, I think).
sliceObj = snapshot $
sliceObj.material = copy newobj.material
sliceObj.name = "MySliceObj"
select sliceObj
ResetTransform $
--create Bounding Box
c = snapshot $
c.transform = matrix3 1
bb = c.max - c.min
b = box width:bb[1] length:bb[2] height:bb[3]
CenterPivot b
delete c
b.transform = $.transform
b.pos = $.center
b.pivot = $.pivot
b.name =$.name + "_box"
--substitute!
addModifier $ (substitute name:"Mysubst")
$.modifiers["Mysubst"].RetainPosition=false
$.modifiers["Mysubst"].RetainLocalRotation =false
$.modifiers["Mysubst"].RetainLocalScale=false
$.modifiers["Mysubst"].ObjectReference =b
Tried accessing the modifier with uiaccess, but I got stuck. Thanks for any help
4 Replies
Jan 15, 2014 7:14 pm
i’m not sure that you make the bbox right…
i don’t have time to check what is wrong there, but you can try my code:
fn makeSubstituteProxy node =
(
bb = nodegetboundingbox node node.objecttransform
bs = bb[2] - bb[1]
b = createinstance box width:bs.x length:bs.y height:bs.z widthsegs:1 lengthsegs:1 heightsegs:1
modi = substitute name:"Proxy" objectreference:b
addmodifier node modi
)
makeSubstituteProxy $
3 Replies
Will try asap, thanks.
Btw my problem is not the bb, it’s the different behaviour between setting the substitute node by script and by doing it manually using the modifier “pick object” button.
if target object was created right there shouldn’t be a difference between scripted and manual methods
fn makeSubstituteProxy node =
(
bb = nodegetboundingbox node node.objecttransform
bs = bb[2] - bb[1]
b = box width:bs.x length:bs.y height:bs.z widthsegs:1 lengthsegs:1 heightsegs:1
modi = substitute name:"Proxy" objectreference:b
addmodifier node modi
)
delete objects
c = cylinder radius:10 height:40
c.scale.x = 0.5
centerpivot c
resetscale c
rotate c (eulerangles 45 30 30)
makeSubstituteProxy c