Skip to main content
deleted 105 characters in body; edited tags; edited title
Source Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

How to Determine Determining if Layer is a Point using Python Toolbox?

Any ideas as to why I am getting this error? 

Am I using the correct data type? 

I have tried using other data types for this parameter, such as DEFeatureClass, GPPoint, and DEShapefile, but I received the following error if I tried adding my shapefile in as my parameter:

The error was the same regardless of which of the three I used. Any assistance on this would be appreciated.

Update: 10/10/2014

 

When I add a shapefile that I know in fact is a point, the tool does not output a warning. It simply accepts it without any feedback to the user. 

Does it matter if the Describe.shapeType function has an output of Unicode? 

I tested this through the ArcMap Python window with the following sequence of commands:

Hence, I've hit a wall once again. Any assistance on this would be appreciated.

How to Determine if Layer is a Point

Any ideas as to why I am getting this error? Am I using the correct data type? I have tried using other data types for this parameter, such as DEFeatureClass, GPPoint, and DEShapefile, but I received the following error if I tried adding my shapefile in as my parameter:

The error was the same regardless of which of the three I used. Any assistance on this would be appreciated.

Update: 10/10/2014

When I add a shapefile that I know in fact is a point, the tool does not output a warning. It simply accepts it without any feedback to the user. Does it matter if the Describe.shapeType function has an output of Unicode? I tested this through the ArcMap Python window with the following sequence of commands:

Hence, I've hit a wall once again. Any assistance on this would be appreciated.

Determining if Layer is Point using Python Toolbox?

Any ideas as to why I am getting this error? 

Am I using the correct data type? 

I have tried using other data types for this parameter, such as DEFeatureClass, GPPoint, and DEShapefile, but I received the following error if I tried adding my shapefile in as my parameter:

The error was the same regardless of which of the three I used.

 

When I add a shapefile that I know in fact is a point, the tool does not output a warning. It simply accepts it without any feedback to the user. 

Does it matter if the Describe.shapeType function has an output of Unicode? 

I tested this through the ArcMap Python window with the following sequence of commands:

Hence, I've hit a wall once again.

deleted 28 characters in body
Source Link
nmpeterson
  • 8.4k
  • 34
  • 60
    def updateParameters(self, parameters):
    
    describe = arcpy.Describe(parameters[0].value)
    def updateParameters(self, parameters):
    
    describe = arcpy.Describe(parameters[0].value)
    #check = str(describe.shapeType)
    if describe.shapeType == 'Point':
        parameters[0].setWarningMessage('This is a point feature class')
    else:
        parameters[0].clearMessage()    
    
    if parameters[2].value == True:
        parameters[3].enabled = True
        parameters[4].enabled = True
        parameters[5].enabled = True
        
    else:       
        parameters[3].enabled = False
        parameters[4].enabled = False
        parameters[5].enabled = False       
        
    return
    def updateParameters(self, parameters):
    
    describe = arcpy.Describe(parameters[0].value)
    def updateParameters(self, parameters):
    
    describe = arcpy.Describe(parameters[0].value)
    #check = str(describe.shapeType)
    if describe.shapeType == 'Point':
        parameters[0].setWarningMessage('This is a point feature class')
    else:
        parameters[0].clearMessage()    
    
    if parameters[2].value == True:
        parameters[3].enabled = True
        parameters[4].enabled = True
        parameters[5].enabled = True
        
    else:       
        parameters[3].enabled = False
        parameters[4].enabled = False
        parameters[5].enabled = False       
        
    return
def updateParameters(self, parameters):
    describe = arcpy.Describe(parameters[0].value)
def updateParameters(self, parameters):
    describe = arcpy.Describe(parameters[0].value)
    #check = str(describe.shapeType)
    if describe.shapeType == 'Point':
        parameters[0].setWarningMessage('This is a point feature class')
    else:
        parameters[0].clearMessage()    
    
    if parameters[2].value == True:
        parameters[3].enabled = True
        parameters[4].enabled = True
        parameters[5].enabled = True
        
    else:       
        parameters[3].enabled = False
        parameters[4].enabled = False
        parameters[5].enabled = False       
        
    return
added 2160 characters in body
Source Link
coolDude
  • 389
  • 3
  • 11

Update: 10/10/2014

My issue with the Describe() class has been cleared up by adding the .value extension in my updateParameters() method:

    def updateParameters(self, parameters):
    
    describe = arcpy.Describe(parameters[0].value)

However, now when I attempt to use the setWarningMessage() function, I get no response from ArcMap. My updateParameters() consists of the following:

    def updateParameters(self, parameters):
    
    describe = arcpy.Describe(parameters[0].value)
    #check = str(describe.shapeType)
    if describe.shapeType == 'Point':
        parameters[0].setWarningMessage('This is a point feature class')
    else:
        parameters[0].clearMessage()    
    
    if parameters[2].value == True:
        parameters[3].enabled = True
        parameters[4].enabled = True
        parameters[5].enabled = True
        
    else:       
        parameters[3].enabled = False
        parameters[4].enabled = False
        parameters[5].enabled = False       
        
    return

When I add a shapefile that I know in fact is a point, the tool does not output a warning. It simply accepts it without any feedback to the user. Does it matter if the Describe.shapeType function has an output of Unicode? I tested this through the ArcMap Python window with the following sequence of commands:

enter image description here

However, even if I try to convert the Describe.shapeType to a string, I still don't get a warning message. I've done the following tests:

  1. Rather than checking for: if describe.shapeType == 'Point', I tried to check for: if describe.shapeType == u'Point', which would force it to check for a Unicode data type.
  2. Converting the shapeType into a string via str(decribe.shapeType).
  3. Using the encode method to change the Unicode into a sequence of ASCII characters: describe.shapeType.encode('ascii', 'ignore').

Hence, I've hit a wall once again. Any assistance on this would be appreciated.

Update: 10/10/2014

My issue with the Describe() class has been cleared up by adding the .value extension in my updateParameters() method:

    def updateParameters(self, parameters):
    
    describe = arcpy.Describe(parameters[0].value)

However, now when I attempt to use the setWarningMessage() function, I get no response from ArcMap. My updateParameters() consists of the following:

    def updateParameters(self, parameters):
    
    describe = arcpy.Describe(parameters[0].value)
    #check = str(describe.shapeType)
    if describe.shapeType == 'Point':
        parameters[0].setWarningMessage('This is a point feature class')
    else:
        parameters[0].clearMessage()    
    
    if parameters[2].value == True:
        parameters[3].enabled = True
        parameters[4].enabled = True
        parameters[5].enabled = True
        
    else:       
        parameters[3].enabled = False
        parameters[4].enabled = False
        parameters[5].enabled = False       
        
    return

When I add a shapefile that I know in fact is a point, the tool does not output a warning. It simply accepts it without any feedback to the user. Does it matter if the Describe.shapeType function has an output of Unicode? I tested this through the ArcMap Python window with the following sequence of commands:

enter image description here

However, even if I try to convert the Describe.shapeType to a string, I still don't get a warning message. I've done the following tests:

  1. Rather than checking for: if describe.shapeType == 'Point', I tried to check for: if describe.shapeType == u'Point', which would force it to check for a Unicode data type.
  2. Converting the shapeType into a string via str(decribe.shapeType).
  3. Using the encode method to change the Unicode into a sequence of ASCII characters: describe.shapeType.encode('ascii', 'ignore').

Hence, I've hit a wall once again. Any assistance on this would be appreciated.

Source Link
coolDude
  • 389
  • 3
  • 11
Loading