I am trying to sort the list of numbers in ascending order. I have used the Sort list component of Grasshopper and I got the desired list but when I call this component using python it give me same result but with two list. One with the required list of numbers and second one with None. Any idea why is this happening?
import rhinoscriptsyntax as rs
import Grasshopper as gh
import ghpythonlib.components as ghc
dokument = ghenv.Component.OnPingDocument().Objects
D=[]
D_sort=[]
if Aktualisieren:
for obj in dokument:
if type(obj) is gh.Kernel.Special.GH_Panel:
if obj.NickName=="LF":
D.append(obj.UserText)
D_sort=ghc.SortList(D)
D_sort = D_sort.keys
for obj in dokument:
if type(obj) is gh.Kernel.Special.GH_Panel:
if obj.NickName==Panel_Name:
obj.UserText='\r\n'.join(map(str,D_sort))
obj.ExpireSolution(True)
Or you could just use Python sorting:
import rhinoscriptsyntax as rs
import Grasshopper as gh
dokument = ghenv.Component.OnPingDocument().Objects
D=[]
if Aktualisieren:
for obj in dokument:
if type(obj) is gh.Kernel.Special.GH_Panel:
if obj.NickName=="LF":
D.append(int(obj.UserText))
D_sort = sorted(D)
for obj in dokument:
if type(obj) is gh.Kernel.Special.GH_Panel:
if obj.NickName==Panel_Name:
print D_sort
obj.UserText='\r\n'.join(map(str,D_sort))
obj.ExpireSolution(True)