Dear Community,
I am French speacking person, so sorry in advance for my English.
I used to script a lot in RVB and I latly switch to Python. I am totaly ammazed by all the possibiliies.
For 3 days now, in am blocking on a very stupide thing: I would like to know the way to get the same return then the RVB command “rhino.GetLayerUserText(strLayerName)”.
I have been trying things like that :
- CollecUserStringOnLayer = scriptcontext.doc.Layers[layerIndex].GetUserStrings but the return is : : <built-in method GetUserStrings of Layer object at 0x00000000000015C3> and I don’t know how to access the values inside…
Thank you in advance.
Loïc
Please find below the complet code :
Code :
# coding=utf-8
import rhinoscriptsyntax as rs
import Rhino
import scriptcontext
def GetAllUserString(layerName):
layerIndex = layerName.LayerIndex
arrReturn = []
nb =layerName.UserStringCount
CollecUserStringOnLayer = scriptcontext.doc.Layers[layerIndex].GetUserStrings
print "Number of user strings : ",nb
print "Dir : " , dir(CollecUserStringOnLayer)
print "Value : " , CollecUserStringOnLayer
return arrReturn
def Main():
# Get the layer table of the project
PolygonLayerToProcess = scriptcontext.doc.Layers
LayerCandidate=[]
# let the user choose the layer
ChoosenLayer = rs.ListBox(PolygonLayerToProcess,"Select the polygon layer", "Select layer")
if ChoosenLayer == None:
return False
arrExistingFieldOnLayer = GetAllUserString(ChoosenLayer)
if( __name__ == "__main__" ):
Main()