Hi,
I have run into an odd issue with my script. I want to get a second edge loop from a subd, but the Rhino document doesn’t prompt me for another selection. I’m guessing that the results of the first ‘get’ are sticking around being reused when i try assigning to another variable (selected_edge_id2)
Any thoughts? Do I need to do something like an unset?
#
import Rhino
import Rhino.Geometry as rg
import rhinoscriptsyntax as rs
import scriptcontext as sc
import System
def GetSubDEdge():
#select a subd edge, return edge ids of selection
go = Rhino.Input.Custom.GetObject()
go.GeometryFilter = Rhino.DocObjects.ObjectType.MeshEdge
go.SetCommandPrompt('Select subd edge for fairing')
go.GetMultiple(1,0) # could be optional depending on inputs, add cmd line op?
objrefs = go.Objects()
subdref = go.Objects() [0].SubD()
edge_ids = [ objref.GeometryComponentIndex.Index for objref in objrefs ]
return edge_ids, subdref
def SubDPointsInfo( subd ):
# input a subd, return all info of subds points
verts = subd.Vertices.First
control_net_pts, srf_pts = [ verts.ControlNetPoint ], [ verts.SurfacePoint() ]
subd_vert_objects = [verts] # temp variable
subd_vert_ids = [verts.Id]
for vert in range( subd.Vertices.Count - 1 ):
current = subd_vert_objects[-1].Next
subd_vert_objects.append( current )
subd_vert_ids.append( current.Id)
control_net_pts.append( current.ControlNetPoint )
srf_pts.append(current.SurfacePoint( ) )
value = [ current.ControlNetPoint, current.SurfacePoint( ) ]
point_loc_tuple = zip( control_net_pts, srf_pts )
point_loc = list(map(list, point_loc_tuple))
points_info_dict = dict (zip( subd_vert_ids, point_loc) )
return points_info_dict
def GetSelectedSubDEdgePoints( edges, selected_edge_ids ):
selected_edge_points = [ ]
for edge in edges:
if edge.Id in selected_edge_ids:
selected_edge_points.append(edge.VertexFrom.Id)
selected_edge_points.append(edge.VertexTo.Id)
selected_vertex_ids_set = set ( selected_edge_points )
srf_pt = [ ]
for id in selected_vertex_ids_set:
selected_vertex = verts.Find( id )
srf_pt.append( selected_vertex.SurfacePoint() )
selected_vertex_ids = [ vert for vert in selected_vertex_ids_set ]
return selected_vertex_ids, srf_pt
#get operation one, no problem
selected_edge_id, subdref = GetSubDEdge() #returns selected edge ids
points_info = SubDPointsInfo( subdref )
#get operation two, rhino document doesn't prompt for another selection?
selected_edge_id2, subdref = GetSubDEdge()
1 post - 1 participant