Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5793

Cannot recover geometry of surface stored in document

$
0
0

@Terry_Chappell wrote:

I make a surface using:

srfGeo = NurbsSurface.CreateThroughPoints(pts, nx, ny, 3, 3, False, False)

I can evaluate this surface using u & v parameters:

	for pt in zPts:
	# Find conformal z for each vertice in mesh.
	x,y,z = pt.X, pt.Y, pt.Z
	if x >= minX and x <= maxX and y >= minY and y <= maxY:
		# Initial u,v guess; scale mesh x,y by max(u,v)/max(x,y) of land.
		u, v = x*x_scale, y*y_scale
		ps = srfGeo.PointAt(u,v)

I save this surface to the document:

# Add surface to document on layer Bare Earth.
bare_earth = doc.Objects.AddSurface(srfGeo)
if not rs.IsLayer('Tree Orchard'): tree_orchard_index = setupLayer(True,'Tree Orchard')
bare_earth_index = setupLayer(True,'Bare Earth',None,'Tree Orchard',False)
setLayer([bare_earth], bare_earth_index)

I try to recover the geometry for this surface the next time I invoke my GUI:

def getGeo(id):
    obj = doc.Objects.Find(id)
    return obj.Geometry

if rs.IsLayer('Bare Earth') and rs.ObjectsByLayer('Bare Earth', False):
	objs = rs.ObjectsByLayer('Bare Earth', False)
	# Set values for bare earth related constants.
	if len(objs) == 1:
		print '1 bare earth found.'
		bare_earth = objs[0]
		print getGeo(bare_earth)
		srfGeo = getGeo(bare_earth)
		# Setup x,y scaling and surface for evaluation.
		u_range, v_range = srfGeo.Domain(0), srfGeo.Domain(1)

But the last line fails with the message:

Message: 'NoneType' object has no attribute 'Domain'

When I print srfGeo it says:

<Rhino.Geometry.Brep object at 0x0000000000000088 [Rhino.Geometry.Brep]>

I have tried to figure out what to do with the brep but so far I have not found the right technology to penetrate its cloaking shield.

How do I get this to work so I can recover the surface geometry and access points using u & v parameters?

Please help.

Regards,
Terry.

Posts: 2

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 5793

Trending Articles