Skip to main content
Question

How to use pythoncaller (getAttribute) in another function?


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+53
  • Celebrity
  • 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
  • May 22, 2022
hkingsbury wrote:

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings