ScriptSpot

Forum topic · General Scripting

Getting the curvelength of a line despite UVW xform modifier

By henning · 2010-06-10

Description

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 (4)

henning · 2010-06-10

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 · 2010-06-10

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
)

another option: fn

lutteral · 2010-06-10

another option:


fn newCurveLength myShape =
(
tempObj = line()
tempObj.baseobject = copy myShape.baseobject
theLength = curveLength tempObj
delete tempObj
theLength
)

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

Anubis · 2010-06-10

--// 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