You could also try something like the following…
–Mitch
Option Explicit
Call LineBSYO()
Sub LineBSYO()
Dim strCrv,dblLen
strCrv = Rhino.GetObject("Select curve to process", 4, True)
If IsNull(strCrv) Then Exit Sub
dblLen = Rhino.CurveLength(strCrv)
Call Rhino.AddLine(Array(0, -dblLen * 0.5, 0), Array(0, dblLen * 0.5, 0))
End Sub
A very important resource is the Rhinoscript Help file, available once you’re in the script editor via the Help menu. If you look at the AddLine method you will see:
AddLine
Adds a line curve to the current model.
Syntax
Rhino.AddLine (arrStart, arrEnd)
Parameters
arrStart Required. Array. The starting point of the line.
arrEnd Required. Array. The ending point of the line.
Returns
String The identifier of the new object if successful.
Null If not successful, or on error.
In Rhinoscript points are specified by arrays of 3 numbers, you can create them by using the syntax
point=Array(x,y,z)
The AddLine method requires a start and end point for the line.
Hi Falfa
The script works without declaring variables .
If you want to draw in absolute coordinates then:
Rhino.command("_Line _Bothsides W0,0,0 W0,"&cstr(ll)&",0")
Ciao Vittorio
There is a difference between a Rhino point object - what you see on the screen as a dot and what is represented by an object ID or GUID - and the actual coordinates of that point, which are represented as an array of 3 numbers (X,Y,Z).
Rhino.AddPoint(Array(x,y,z)) adds a point object to the document at coordinates x,y,z
Rhino.IsPoint() tells you if the object (represented by its GUID) in question is a point object
(returns True or False)
However, if you want to use the coordinates of a point object, you need to first extract them with coords=Rhino.PointCoordinates(point). This will give you the array of 3 numbers that are the point object’s coordinates.
However, you have already supplied those coordinates when using RhinoAddPoint()
So, you can make a line as follows:
Option Explicit
Call Test()
Sub Test()
Dim XY3,XY4,line
XY3 = Array(700, 0.0, 200)
XY4 = Array(-1100, 0.0, 200)
line = Rhino.AddLine(XY3, XY4)
End Sub
You might want to look at some of the available info on Rhinoscript here:
Can you help me this scrip. It’s not successful to creat line .
Sub Main()
Dim a, b, c, d, f, g
a = Rhino.getobject("select curve a")
b = Rhino.getobject("select curve b")
c = Rhino.CurveEndPoint(a)
d = Rhino.CurveStartPoint(b)
f = Rhino.AddLine(Array(c, d))
g = Rhino.AddLine(Array(Array(c(0), 0.0, c(2)), Array(d(0), 0.0, d(2))))