[Closed] How to Pick Top and Pick Bottom objects for Hose?
Hello
There is maxscript access to almost all Hose properties except for the “Pick Top Object” and “Pick Bottom Object”.
Is there any way those two objects to be added programmatically without using UIAccessors?
Not! You also can’t add these targets even through the SDK. Add Reference is always a virtual method, and it’s impossible to guess what the object is doing when adds a reference.
But… You can change targets if references for them were created. That means you can merge a Hose with already created targets and change them to what you need.
NO!!! you can! wait a sec…
delete objects
gc()
(
h = hose name:#source round_hose_diameter:10 round_hose_sides:8 rectangular_hose_width:50 \
segments_along_hose:100 flex_cycle_count:200 wirecolor:green
t0 = box name:#target1 wirecolor:red
t1 = box name:#target2 pos:[100,0,0] wirecolor:orange
h.end_placement_method = 1
refs.replaceReference h.baseobject 2 t0
refs.replaceReference h.baseobject 3 t1
h.end_placement_method = 0
h
)
There are two types of objects in terms of how they handle adding new references. Some create placeholders and add them on the fly, but some create them in advance. Luckily for you, the Hose object is from the second family.
delete objects
gc()
undo off, redraw off
(
A = dummy name:"ANIM" boxsize:[20,20,20]
bip = biped.createNew 300 -90 [0,0,288]
in A
(
P = snapshot (biped.getnode bip #pelvis) name:"pelvis" pos:[0,0,90] wirecolor:red
L = snapshot (biped.getnode bip #lleg link:3) name:"foot_L" pos:[-50,0,17] wirecolor:(green*0.75)
R = snapshot (biped.getnode bip #rleg link:3) name:"foot_R" pos:[50,0,17] wirecolor:(blue*0.75)
Lh = hose name:"leg_L_MESH" round_hose_diameter:10 round_hose_sides:8 rectangular_hose_width:50 \
segments_along_hose:100 flex_cycle_count:200 top_tension:15 bottom_tension:60 wirecolor:orange
Rh = hose name:"leg_R_MESH" round_hose_diameter:10 round_hose_sides:8 rectangular_hose_width:50 \
segments_along_hose:100 flex_cycle_count:200 top_tension:15 bottom_tension:60 wirecolor:orange
in P
(
Lp = point name:"leg_L_JOINT" cross:on wirecolor:green rotation:(angleaxis 90 -y_axis) pos:(P.pos + [-5,0,0])
Rp = point name:"leg_R_JOINT" cross:on wirecolor:blue rotation:(angleaxis 90 y_axis) pos:(P.pos + [5,0,0])
)
)
delete bip
worldalignpivot L
worldalignpivot R
Lh.end_placement_method = 1
refs.replaceReference Lh.baseobject 2 L
refs.replaceReference Lh.baseobject 3 Lp
Lh.end_placement_method = 0
Rh.end_placement_method = 1
refs.replaceReference Rh.baseobject 2 R
refs.replaceReference Rh.baseobject 3 Rp
Rh.end_placement_method = 0
A
)
You also can’t add these targets even through the SDK
hoseObject->ReplaceReference(1, node1);
and
hoseObject->ReplaceReference(2, node2);
should do the job
Yes. Replacing a Reference is not a problem for both MXS and SDK. As I said, the problem is to add a reference. Hose object adds references when you select “Bind to Object Pivots” mode for the first instance of the class.
? the number of references is the same regardless of “Bind to Object Pivots” being set, custnode1 and custnode2 (refs 1 & 2) are just set to NULL at creation.
yes… Hose makes all extra 3 placements for references at creation time. First is as usually the paramblock, two placeholders for targets and fourth is a nodemonitor for itself. But not all objects do the same. Some add references as I said on the fly.