ScriptSpot

Forum topic · General Scripting

How can I use the "distance"?

By season_X · 2019-02-20

Description

num_knot = numKnots $ 1
seg_len = getSegLengths $ 1
num_seg = num_knot-1
for i=1 to num_knot do
(
pt1 = getKnotPoint $ 1 i
pt2 = getKnotPoint $ 1 i+1
knot_len = distance pt1 pt2
messageBox ((knot_len as string)+","+(seg_len[i+num_seg] as string))
)

why the"knot_len" was always equal to "1.73205"?and the"knot_len" is same.so I need help.

Comments (3)

Who did use Base64 Image for Button?

season_X · 2019-03-01

global Logo_image = "...."
local ConvertClass = dotnetclass "system.convert"
local ImageClass = dotnetclass "system.drawing.image"
fn ConvertBase64StringToImage string =
(
bytearr = convertclass.FromBase64String string
memstream = dotnetobject "System.IO.MemoryStream" bytearr
DecodedImg = ImageClass.fromstream memstream
memstream.close()
DecodedImg
)
btn_image = ConvertBase64StringToImage Logo_image
button Align_Right width:45 height:45 image:#(btn_image, undefined, 1,1,1,1,1)

-----Why didn't the image show?

.

miauu · 2019-02-26


(
	num_knot = numKnots $ 1
	seg_len = getSegLengths $ 1
	num_seg = num_knot-1
	for i=1 to num_knot - 1 do
	(
		pt1 = getKnotPoint $ 1 i
		pt2 = getKnotPoint $ 1 (i+1)
		knot_len = distance pt1 pt2
		format "knots: %   knot_len: %   seg_len: % \n" #(i, i+1) knot_len seg_len[i+num_seg]
	)
)

The knot_len depends of the position of the knots. If they are placed so the distance between them is always "1.73205" then you will see "1.73205" as knot_len value.
The seg_len will be the same as knot_len if all segments are straight lines(itheir type is Line not Curve).

.

TsveTan · 2019-02-26

maybe...

pt2 = getKnotPoint $ 1 i+1

should return to

pt2 = getKnotPoint $ 1 (i+1)

, also

for i = 1 to num_seg do

to avoid out of range.