Skip to main content

Hello,

I'd like to use feature attribute in another function. something like

class FeatureProcessor:

  def __init__(self):

    pass

  def input(self, feature):

    col1 = feature.getAttribute('col1')

    col2 = feature.getAttribute('col2')

    self.pyoutput(feature)

  def close(self):

    pass

def myFunction(col1,col2)

another code etc.  

I do not know how I can get attributes col1 and col2 to use it in another function.. (first time using python caller) .. thanks for help.

With your second function, you need to call it (line 7), so something like:

class FeatureProcessor:
  def __init__(self):
    pass
  def input(self, feature):
    col1 = feature.getAttribute('col1')
    col2 = feature.getAttribute('col2')
    myFunction(col1,col2)
    self.pyoutput(feature)
  def close(self):
    pass
def myFunction(col1,col2)
    <do something>

 


With your second function, you need to call it (line 7), so something like:

class FeatureProcessor:
  def __init__(self):
    pass
  def input(self, feature):
    col1 = feature.getAttribute('col1')
    col2 = feature.getAttribute('col2')
    myFunction(col1,col2)
    self.pyoutput(feature)
  def close(self):
    pass
def myFunction(col1,col2)
    <do something>

 

Hello I  found a solution similar to that .. I wrote the function within the  def input function (nested function). But I will try your solution.. that would be easier.

Thanks for your answer


Reply