Don’t know what it could be. Tested it in different Max versions and it works. Just have the UI opened and then manually create a Tape and it should update the values.
EDIT 1: I’ve updated the code, it should now work with any amount of Tapes and keep the values of the latest selected one.
EDIT 2: Improved it a bit. Should have better response and work better when changing selections.
EDIT 3: Fixed bugs and converted to MacroScript.
macroScript Floater_Tape
category:"Tools"
tooltip:"Floater Tape"
buttontext:"Tape"
icon:#("Helpers",5)
(
global RO_TAPE_FLOATER
on execute do
(
rollout RO_TAPE_FLOATER "Tape Floater" width:140 height:194
(
label lbl "Length:" pos:[12, 4]
spinner spn1 "" pos:[ 8,20] fieldwidth:112 range:[0,1e9,0] type:#worldunits enabled:false
label lbl_node "" pos:[12,40] width:104
label lbl1 "To X Axis:" pos:[20, 64]
label lbl2 "To Y Axis:" pos:[20, 84]
label lbl3 "To Z Axis:" pos:[20,104]
label lbl4 "To XY Plane:" pos:[ 8,134]
label lbl5 "To YZ Plane:" pos:[ 8,154]
label lbl6 "To ZX Plane:" pos:[ 8,174]
label edt1 "" pos:[74, 64] width:104
label edt2 "" pos:[74, 84] width:104
label edt3 "" pos:[74,104] width:104
label edt4 "" pos:[74,134] width:104
label edt5 "" pos:[74,154] width:104
label edt6 "" pos:[74,174] width:104
local plane_xy = [0,0,1]
local plane_yz = [1,0,0]
local plane_zx = [0,1,0]
local node = undefined
local ctrl = float_script()
fn DeleteHandlers =
(
deleteallchangehandlers id:#ID_0X5D5F4A2C
gc light:on
)
fn UpdateUI =
(
if node == undefined or isdeleted node or node.target == undefined or isdeleted node.target then
(
spn1.value = 0
lbl_node.text = edt1.text = edt2.text = edt3.text = edt4.text = edt5.text = edt6.text = ""
DeleteHandlers()
)else(
p1 = node.pos
p2 = node.target.pos
dir = normalize (p1-p2)
angleToAxis_X = acos dir.x
angleToAxis_Y = acos dir.y
angleToAxis_Z = acos dir.z
angleToPlane_XY = abs ((acos (dot dir plane_xy))-90)
angleToPlane_YZ = abs ((acos (dot dir plane_yz))-90)
angleToPlane_ZX = abs ((acos (dot dir plane_zx))-90)
spn1.value = distance p1 p2
edt1.text = angleToAxis_X as string
edt2.text = angleToAxis_Y as string
edt3.text = angleToAxis_Z as string
edt4.text = angleToPlane_XY as string
edt5.text = angleToPlane_YZ as string
edt6.text = angleToPlane_ZX as string
)
)
fn GetSelection =
(
sel = selection[1]
if sel == undefined do return()
if iskindof sel tape then
(
node = sel
)else if iskindof (refs.dependentnodes sel)[1] tape then
(
node = (refs.dependentnodes sel)[1]
)else(
node = undefined
)
if node != undefined and node.target != undefined do
(
DeleteHandlers()
if ctrl.VariableExists "TAPE" then ctrl.SetObject "TAPE" node.controller else ctrl.AddObject "TAPE" node.controller
when parameters ctrl changes id:#ID_0X5D5F4A2C do UpdateUI()
when node deleted id:#ID_0X5D5F4A2C do
(
node = undefined
UpdateUI()
)
lbl_node.text = node.name
ctrl.update()
)
)
on RO_TAPE_FLOATER open do
(
callbacks.removescripts id:#ID_0X350B32A9
callbacks.addscript #selectionSetChanged "::RO_TAPE_FLOATER.GetSelection()" id:#ID_0X350B32A9
GetSelection()
)
on RO_TAPE_FLOATER close do
(
callbacks.removescripts id:#ID_0X350B32A9
DeleteHandlers()
)
)
createdialog RO_TAPE_FLOATER style:#(#style_titlebar, #style_toolwindow, #style_sysmenu)
startobjectcreation Tape
) -- End Excecute
on isChecked return (mcrUtils.IsCreating Tape)
)
Here is a modified version, as suggested by Denis, with TextBox controls so you can copy the values.
macroScript Floater_Tape
category:"Tools"
tooltip:"Floater Tape"
buttontext:"Tape"
icon:#("Helpers",5)
(
global RO_TAPE_FLOATER
on execute do
(
rollout RO_TAPE_FLOATER "Tape Floater" width:140 height:194
(
label lbl "Length:" pos:[12, 4]
spinner spn1 "" pos:[ 8,20] fieldwidth:112 range:[0,1e9,0] type:#worldunits enabled:false
label lbl_node "" pos:[12,40] width:104
label lbl1 "To X Axis:" pos:[20, 64]
label lbl2 "To Y Axis:" pos:[20, 84]
label lbl3 "To Z Axis:" pos:[20,104]
label lbl4 "To XY Plane:" pos:[ 8,134]
label lbl5 "To YZ Plane:" pos:[ 8,154]
label lbl6 "To ZX Plane:" pos:[ 8,174]
dotnetcontrol edt1 "TextBox" pos:[70, 60] width:62
dotnetcontrol edt2 "TextBox" pos:[70, 80] width:62
dotnetcontrol edt3 "TextBox" pos:[70,100] width:62
dotnetcontrol edt4 "TextBox" pos:[70,130] width:62
dotnetcontrol edt5 "TextBox" pos:[70,150] width:62
dotnetcontrol edt6 "TextBox" pos:[70,170] width:62
local plane_xy = [0,0,1]
local plane_yz = [1,0,0]
local plane_zx = [0,1,0]
local node = undefined
local ctrl = float_script()
fn DeleteHandlers =
(
deleteallchangehandlers id:#ID_0X5D5F4A2C
gc light:on
)
fn UpdateUI =
(
if node == undefined or isdeleted node or node.target == undefined or isdeleted node.target then
(
spn1.value = 0
lbl_node.text = edt1.text = edt2.text = edt3.text = edt4.text = edt5.text = edt6.text = ""
DeleteHandlers()
)else(
p1 = node.pos
p2 = node.target.pos
dir = normalize (p1-p2)
angleToAxis_X = acos dir.x
angleToAxis_Y = acos dir.y
angleToAxis_Z = acos dir.z
angleToPlane_XY = abs ((acos (dot dir plane_xy))-90)
angleToPlane_YZ = abs ((acos (dot dir plane_yz))-90)
angleToPlane_ZX = abs ((acos (dot dir plane_zx))-90)
spn1.value = distance p1 p2
edt1.text = angleToAxis_X as string
edt2.text = angleToAxis_Y as string
edt3.text = angleToAxis_Z as string
edt4.text = angleToPlane_XY as string
edt5.text = angleToPlane_YZ as string
edt6.text = angleToPlane_ZX as string
edt1.update()
edt2.update()
edt3.update()
edt4.update()
edt5.update()
edt6.update()
)
)
fn GetSelection =
(
sel = selection[1]
if sel == undefined do return()
if iskindof sel tape then
(
node = sel
)else if iskindof (refs.dependentnodes sel)[1] tape then
(
node = (refs.dependentnodes sel)[1]
)else(
node = undefined
)
if node != undefined and node.target != undefined do
(
DeleteHandlers()
if ctrl.VariableExists "TAPE" then ctrl.SetObject "TAPE" node.controller else ctrl.AddObject "TAPE" node.controller
when parameters ctrl changes id:#ID_0X5D5F4A2C do UpdateUI()
when node deleted id:#ID_0X5D5F4A2C do
(
node = undefined
UpdateUI()
)
lbl_node.text = node.name
ctrl.update()
)
)
fn SetUpControls =
(
for j in RO_TAPE_FLOATER.controls where iskindof j dotNetControl do j.ReadOnly = true
)
on RO_TAPE_FLOATER open do
(
SetUpControls()
callbacks.removescripts id:#ID_0X350B32A9
callbacks.addscript #selectionSetChanged "::RO_TAPE_FLOATER.GetSelection()" id:#ID_0X350B32A9
GetSelection()
)
on RO_TAPE_FLOATER close do
(
callbacks.removescripts id:#ID_0X350B32A9
DeleteHandlers()
)
)
createdialog RO_TAPE_FLOATER style:#(#style_titlebar, #style_toolwindow, #style_sysmenu)
startobjectcreation Tape
) -- End Excecute
on isChecked return (mcrUtils.IsCreating Tape)
)
A last version with buttons for copying the values. A bit cluttered UI but does the job.
Three flavors, for all tastes.
macroScript Floater_Tape
category:"Tools"
tooltip:"Floater Tape"
buttontext:"Tape"
icon:#("Helpers",5)
(
global RO_TAPE_FLOATER
on execute do
(
rollout RO_TAPE_FLOATER "Tape Floater" width:156 height:194
(
label lbl "Length:" pos:[12, 4]
spinner spn1 "" pos:[ 8,20] fieldwidth:108 range:[0,1e9,0] type:#worldunits enabled:false
label lbl_node "" pos:[12,40] width:104
label lbl1 "To X Axis:" pos:[20, 64]
label lbl2 "To Y Axis:" pos:[20, 84]
label lbl3 "To Z Axis:" pos:[20,104]
label lbl4 "To XY Plane:" pos:[ 8,134]
label lbl5 "To YZ Plane:" pos:[ 8,154]
label lbl6 "To ZX Plane:" pos:[ 8,174]
label edt1 "0.0" pos:[74, 64] width:58
label edt2 "0.0" pos:[74, 84] width:58
label edt3 "0.0" pos:[74,104] width:58
label edt4 "0.0" pos:[74,134] width:58
label edt5 "0.0" pos:[74,154] width:58
label edt6 "0.0" pos:[74,174] width:58
button bt0 "C" pos:[132, 18] width:18 height:18 tooltip:"Copy Value"
button bt1 "C" pos:[132, 62] width:18 height:18 tooltip:"Copy Value"
button bt2 "C" pos:[132, 82] width:18 height:18 tooltip:"Copy Value"
button bt3 "C" pos:[132,102] width:18 height:18 tooltip:"Copy Value"
button bt4 "C" pos:[132,132] width:18 height:18 tooltip:"Copy Value"
button bt5 "C" pos:[132,152] width:18 height:18 tooltip:"Copy Value"
button bt6 "C" pos:[132,172] width:18 height:18 tooltip:"Copy Value"
local plane_xy = [0,0,1]
local plane_yz = [1,0,0]
local plane_zx = [0,1,0]
local node = undefined
local ctrl = float_script()
fn DeleteHandlers =
(
deleteallchangehandlers id:#ID_0X5D5F4A2C
gc light:on
)
fn UpdateUI =
(
if node == undefined or isdeleted node or node.target == undefined or isdeleted node.target then
(
spn1.value = 0
lbl_node.text = ""
edt1.text = edt2.text = edt3.text = edt4.text = edt5.text = edt6.text = "0.0"
DeleteHandlers()
)else(
p1 = node.pos
p2 = node.target.pos
dir = normalize (p1-p2)
angleToAxis_X = acos dir.x
angleToAxis_Y = acos dir.y
angleToAxis_Z = acos dir.z
angleToPlane_XY = abs ((acos (dot dir plane_xy))-90)
angleToPlane_YZ = abs ((acos (dot dir plane_yz))-90)
angleToPlane_ZX = abs ((acos (dot dir plane_zx))-90)
spn1.value = distance p1 p2
edt1.text = angleToAxis_X as string
edt2.text = angleToAxis_Y as string
edt3.text = angleToAxis_Z as string
edt4.text = angleToPlane_XY as string
edt5.text = angleToPlane_YZ as string
edt6.text = angleToPlane_ZX as string
)
)
fn GetSelection =
(
sel = selection[1]
if sel == undefined do return()
if iskindof sel tape then
(
node = sel
)else if iskindof (refs.dependentnodes sel)[1] tape then
(
node = (refs.dependentnodes sel)[1]
)else(
node = undefined
)
if node != undefined and node.target != undefined do
(
DeleteHandlers()
if ctrl.VariableExists "TAPE" then ctrl.SetObject "TAPE" node.controller else ctrl.AddObject "TAPE" node.controller
when parameters ctrl changes id:#ID_0X5D5F4A2C do UpdateUI()
when node deleted id:#ID_0X5D5F4A2C do
(
node = undefined
UpdateUI()
)
lbl_node.text = node.name
ctrl.update()
)
)
fn SetUpControls =
(
for j in RO_TAPE_FLOATER.controls where iskindof j dotNetControl do j.ReadOnly = true
)
on RO_TAPE_FLOATER open do
(
SetUpControls()
callbacks.removescripts id:#ID_0X350B32A9
callbacks.addscript #selectionSetChanged "::RO_TAPE_FLOATER.GetSelection()" id:#ID_0X350B32A9
GetSelection()
)
on RO_TAPE_FLOATER close do
(
callbacks.removescripts id:#ID_0X350B32A9
DeleteHandlers()
)
on bt0 pressed do setclipboardtext (spn1.value as string)
on bt1 pressed do setclipboardtext edt1.text
on bt2 pressed do setclipboardtext edt2.text
on bt3 pressed do setclipboardtext edt3.text
on bt4 pressed do setclipboardtext edt4.text
on bt5 pressed do setclipboardtext edt5.text
on bt6 pressed do setclipboardtext edt6.text
)
createdialog RO_TAPE_FLOATER style:#(#style_titlebar, #style_toolwindow, #style_sysmenu)
startobjectcreation Tape
) -- End Excecute
on isChecked return (mcrUtils.IsCreating Tape)
)