Getting the curvelength of a line despite UVW xform modifier

I'm trying to query the length of a line, but a UVW Xform modifier changes it to an editable mesh.
Accessing the baseobject using .baseobject works but not for the curvelength function:

"-- No ""curveLength"" function for Line"

Is there a way to access my the length of my line without disabling the UVW modifier?

regards,
Henning

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
henning's picture

thank you both! I now based

thank you both! I now based it on variant 2 from Anubis. I thought I could make in dynamically in a script controller but a one-click solution for every one of my lines works just as well

here is my script in case anyone is interested:

for obj in selection do (
-- disable all modifiers
obj.modifiers.enabled = false
 
-- set "UVW_Xform" v_tile to length of shape
obj.modifiers[#UVW_Xform].v_tile = (curvelength obj) / 200
 
-- re-enable all modifiers
obj.modifiers.enabled = true
) 
lutteral's picture

something went wrong with my

something went wrong with my last post, and I can't edit it. Let's see if the code is ok now:

fn newCurveLength myShape =
(
	tempObj = line()
	tempObj.baseobject = copy myShape.baseobject
	theLength = curveLength tempObj
	delete tempObj
	theLength
)
lutteral's picture

another option: fn

another option:

fn newCurveLength myShape =
(
tempObj = line()
tempObj.baseobject = copy myShape.baseobject
!REG3XP1!>theLength = curveLength tempObj
delete tempObj
theLength
)
Anubis's picture

--// variant 1 ----------- c

--// variant 1 -----------
c = copy $Line01 -- create a temp copy of the object
deleteModifier c 1 -- delete UVW_Xform modifier
cLen = curveLength c -- get the length
delete c -- delete the temp object
 
--// variant 2 -----------
$Line01.modifiers[#UVW_Xform].enabled = false -- disable the modifier
cLen = curveLength $Line01 -- get the length
$Line01.modifiers[#UVW_Xform].enabled = true -- enable the modifier

my recent MAXScripts RSS (archive here)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.