How to use the rhino3dm.LineCurve function in rhino3dm

To help you get started, we’ve selected a few rhino3dm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jesterKing / import_3dm / import_3dm / converters / curve.py View on Github external
return None

def import_line(rcurve, bcurve, scale):

    fr = rcurve.Line.From
    to = rcurve.Line.To

    line = bcurve.splines.new('POLY')
    line.points.add(1)

    line.points[0].co = (fr.X * scale, fr.Y * scale, fr.Z * scale, 1)
    line.points[1].co = (to.X * scale, to.Y * scale, to.Z * scale, 1)

    return line

CONVERT[r3d.LineCurve] = import_line

def import_polyline(rcurve, bcurve, scale):

    N = rcurve.PointCount

    polyline = bcurve.splines.new('POLY')

    polyline.use_cyclic_u = rcurve.IsClosed
    if rcurve.IsClosed:
        N -= 1

    polyline.points.add(N - 1)
    for i in range(0, N):
        rpt = rcurve.Point(i)
        polyline.points[i].co = (rpt.X * scale, rpt.Y * scale, rpt.Z * scale, 1)
github mcneel / rhino3dm / docs / python / samples / spherelines.py View on Github external
center_pt = rhino3dm.Point3d(0.0, 0.0, 0.0)

# Create a File3dm object
model = rhino3dm.File3dm()

for i in range(num_lines):
	# Calculate random line end point
	random.seed(i * 100)
	theta = random.uniform(theta_min, theta_max)
	alpha = random.uniform(alpha_min, alpha_max)
	x = sphere_radius * math.sin(theta) * math.cos(alpha)
	y = sphere_radius * math.sin(theta) * math.sin(alpha)
	z = sphere_radius * math.cos(theta)
	end_pt = rhino3dm.Point3d(x, y, z)
	# Create line curve
	line_curve = rhino3dm.LineCurve(center_pt, end_pt)
	# Add to model
	model.Objects.AddCurve(line_curve)

# Full path to 3dm file to save
desktop = os.path.join(os.path.join(os.environ['USERPROFILE']), 'Desktop') 
filename = 'spherelines.3dm'
path = os.path.join(desktop, filename)

# Write model to disk
model.Write(path, 6)