PDA

View Full Version : Merger two scripts can't correctly run !


su37
04-19-2009, 06:54 AM
I have a problem, When i Merger two scripts,the first can correctly run but the second can't correctly run .please help, thanks !
Sorry ! These two scripts is others.

The first scripts :

-- MBG measurer 1.0
-- by Mauricio B. Gehling

-- mbg3dmind@yahoo.com.br


-- measure the distance of 2 vertices (ONLY 2)
-- measure the distance of vertices in a edge, is possible to select various (sum various)
-- works only with editable mesh or poly
-- only centimeters

-- use:
-- just run
-- select a poly or mesh, then select 2 vertices or any edges



rollout medidor "measurer by MBG" width:150 height:20
(
label label "..." pos:[80,5] --width:99 height:25

fn gogogo =
(

try (
-- pega selecao vert
vselba = getvertselection $
vsel = vselba as array
-- pega edges
eselba = getedgeselection $
esel = eselba as array

-- pega pos vert
if subobjectlevel == 1 then (-- vertex

if classof $ == Editable_mesh then (
cb = getvert $ vsel[1]
ct = getvert $ vsel[2]
) else (
cb = polyop.getvert $ vsel[1]
ct = polyop.getvert $ vsel[2]
)

-- calcula dist
calc = sqrt((cb.x-ct.x)*(cb.x-ct.x)+(cb.y-ct.y)*(cb.y-ct.y)+(cb.z-ct.z)*(cb.z-ct.z))


label.caption = calc as string

) else ( -- edge
soma = 0

if classof $ == Editable_poly then (
For x = 1 to esel.count do (

baverts = polyop.getvertsusingedge $ esel[x]
vertices = baverts as array

cb = polyop.getvert $ vertices[1]
ct = polyop.getvert $ vertices[2]

calc = sqrt((cb.x-ct.x)*(cb.x-ct.x)+(cb.y-ct.y)*(cb.y-ct.y)+(cb.z-ct.z)*(cb.z-ct.z))
soma = soma + calc
) -- end for

label.caption = soma as string

) else

(-- is mesh

For x = 1 to esel.count do (

baverts = meshop.getvertsusingedge $ esel[x]
vertices = baverts as array

cb = getvert $ vertices[1]
ct = getvert $ vertices[2]

calc = sqrt((cb.x-ct.x)*(cb.x-ct.x)+(cb.y-ct.y)*(cb.y-ct.y)+(cb.z-ct.z)*(cb.z-ct.z))
soma = soma + calc
) -- end for

label.caption = soma as string


)
-- end else
) -- end else edge
---------------------------------------------------------------------------------------------------------


---------------------------------------------------------------------------------------------------------
) catch label.caption = "- * - * -"

)
on medidor open do registerRedrawViewsCallback gogogo
on medidor close do unregisterRedrawViewsCallback gogogo


)

createdialog medidor







-----------------------------------------------------------------------------------------
The second scripts:
if ((superclassof $ == shape) and (subobjectLevel == 2)) then
(
obj=selection[1]
spl=0
seg=0
soma=0
for s = 1 to (numsplines obj) do
(
spl=spl+1 ----- 1 to number of splines
seg=getSegSelection obj s
seglen=getSegLengths obj spl
if (seg.count) != 0 then
(
for t=1 to seg.count do
(
calc=(seglen[(((seglen.count-1)/2) + seg[t])])
soma = soma + calc

label.caption = soma as string
)
)
)
)

---------------------------------------------------------------------------------
After Merger:









-- MBG measurer 1.0
-- by Mauricio B. Gehling

-- mbg3dmind@yahoo.com.br


-- measure the distance of 2 vertices (ONLY 2)
-- measure the distance of vertices in a edge, is possible to select various (sum various)
-- works only with editable mesh or poly
-- only centimeters

-- use:
-- just run
-- select a poly or mesh, then select 2 vertices or any edges



rollout medidor "measurer by MBG" width:150 height:20
(
label label "..." pos:[80,5] --width:99 height:25

fn gogogo =
(

try (
-- pega selecao vert
vselba = getvertselection $
vsel = vselba as array
-- pega edges
eselba = getedgeselection $
esel = eselba as array

-- pega pos vert
if subobjectlevel == 1 then (-- vertex

if classof $ == Editable_mesh then (
cb = getvert $ vsel[1]
ct = getvert $ vsel[2]
) else (
cb = polyop.getvert $ vsel[1]
ct = polyop.getvert $ vsel[2]
)

-- calcula dist
calc = sqrt((cb.x-ct.x)*(cb.x-ct.x)+(cb.y-ct.y)*(cb.y-ct.y)+(cb.z-ct.z)*(cb.z-ct.z))


label.caption = calc as string

) else ( -- edge
soma = 0

if classof $ == Editable_poly then (
For x = 1 to esel.count do (

baverts = polyop.getvertsusingedge $ esel[x]
vertices = baverts as array

cb = polyop.getvert $ vertices[1]
ct = polyop.getvert $ vertices[2]

calc = sqrt((cb.x-ct.x)*(cb.x-ct.x)+(cb.y-ct.y)*(cb.y-ct.y)+(cb.z-ct.z)*(cb.z-ct.z))
soma = soma + calc
) -- end for

label.caption = soma as string

) else

(-- is mesh

For x = 1 to esel.count do (

baverts = meshop.getvertsusingedge $ esel[x]
vertices = baverts as array

cb = getvert $ vertices[1]
ct = getvert $ vertices[2]

calc = sqrt((cb.x-ct.x)*(cb.x-ct.x)+(cb.y-ct.y)*(cb.y-ct.y)+(cb.z-ct.z)*(cb.z-ct.z))
soma = soma + calc
) -- end for

label.caption = soma as string


)
-- end else
) -- end else edge
---------------------------------------------------------------------------------------------------------
if ((superclassof $ == shape) and (subobjectLevel == 2)) then
(
obj=selection[1]
spl=0
seg=0
soma=0
for s = 1 to (numsplines obj) do
(
spl=spl+1 ----- 1 to number of splines
seg=getSegSelection obj s
seglen=getSegLengths obj spl
if (seg.count) != 0 then
(
for t=1 to seg.count do
(
calc=(seglen[(((seglen.count-1)/2) + seg[t])])
soma = soma + calc

label.caption = soma as string
)
)
)
)






---------------------------------------------------------------------------------------------------------
) catch label.caption = "- * - * -"

)
on medidor open do registerRedrawViewsCallback gogogo
on medidor close do unregisterRedrawViewsCallback gogogo


)

createdialog medidor

CGTalk Moderation
04-19-2009, 06:54 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.