Skip to main content
Question

How to use pythoncaller (getAttribute) in another function?

  • May 20, 2022
  • 2 replies
  • 80 views

Forum|alt.badge.img

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.

2 replies

hkingsbury
Celebrity
Forum|alt.badge.img+63
  • Celebrity
  • 1620 replies
  • May 22, 2022

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>

 


Forum|alt.badge.img
  • Author
  • 97 replies
  • May 22, 2022

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