Hello everybody,
I am a new user of Rhinoscript. Currently, I am trying to write a script which will be used in my Diploma Project. But, I face too many problems doing it. That is why I am kindly asking for your help and advice.
So far I have developed a script which adds control points at the intersection of lines and identifies which points are connected to each other. But, the problem is:
I cannot make the programm display the resulting Matrix. When I write Rhino.Print Matrix(1,2) or any other cell of the resulting Matrix, the programm shows its value. But, I can’t make it to show the whole Matrix. (Rhino.Print Matrix(i,j) gives an error…)
Please help…
Option Explicit
'Script written by <insert name>
'Script copyrighted by <insert company name>
'Script version 4 октября 2016 г. 23:40:16
Call putpoints
Sub PutPoints()
Dim i,spoint,epoint,N,PNTS,pts
ReDim PNTS(0)
N = 0
Const CurveConst = 4
Dim line : line = Rhino.ObjectsByType(CurveConst)
If IsNull(line) Then Rhino.Print("Nothing selected")
If IsArray(line) Then
For i=0 To Ubound(line)
ReDim Preserve PNTS(N)
PNTS(N) = Rhino.CurveStartPoint(line(i))
N = N + 1
ReDim Preserve PNTS(N)
PNTS(N) = Rhino.CurveEndPoint(line(i))
N = N + 1
Next
End If
PNTS = Rhino.CullDuplicatePoints(PNTS)
pts = Rhino.AddPoints(PNTS)
For i=0 To ubound(PNTS)
Rhino.addText i, PNTS(i), 1
Next
ReDim Lines(Ubound(line))
Dim j,coord,dist,p
For i=0 To ubound(line)
Lines(i) = Array(Rhino.CurveStartPoint(line(i)), Rhino.CurveEndPoint(line(i)))
Next
Dim test_p
Dim e:e = 1e-10
Dim z
z = Ubound(PNTS)
ReDim Matrix(z,z)
For i=0 To Ubound(PNTS)
For j=0 To Ubound(line)
dist = Rhino.Min(array(Rhino.Distance(PNTS(i), Rhino.CurveStartPoint(line(j))), Rhino.Distance(PNTS(i), Rhino.CurveEndPoint(line(j)))))
If dist < e Then
Rhino.AddText i, Rhino.CurveMidPoint(line(j)), 1.5
Matrix(i, j) = 1
End If
If dist > e Then
Matrix(i, j) = 0
End If
Next
Next
Rhino.Print Matrix(i, j)
End Sub