AttributeError: 'int' object has no attribute 'x'
Question: I realize this is a common topic for posts here, however, I can't seem to find
one example that really helped me fix the problem. I'm trying to run a script
that will add two new fields (x and y coords) to a shapefile then populate
those fields with X and Y coords using the code block. This is for AcrGIS
10.2.2, but I don't think the problem is a ArcGIS problem. Script below:

    
    
    # Add new fields for "New_X" and "New_Y" for new points to be added
    # Calculate values for those new fields based on distance along line
    import arcpy, arcpy.mapping
    from arcpy import env
    env.workspace = r"G:\Geocomputation_Project\Section_C\Model_Shapes"
    env.overwriteOutput = True
    
    # Set local Variables
    in_table = 'Points.shp'
    field_x = 'New_X'
    field_y = 'New_Y'
    expression = "getXY(!Shape!, !ITEMID!, !CHAINAGE!)"
    code_block_x = """def getXY (point, id, d2add):
    mxd = arcpy.mapping.MapDocument("G:\Geocomputation_Project\Section_C\Model_Shapes\Geocomputation_Project.mxd")
    lyr=arcpy.mapping.ListLayers(mxd,"LINES")[0]
    q='"ITEMID"=%s%s%s' %(r"'",id,"'")
    pNew = 0
    with arcpy.da.SearchCursor(lyr,"Shape@",q)as cursor:
        for row in cursor:
            line=row[0];break
            pointPos=line.measureOnLine(point)+d2add
            pNew+=line.positionAlongLine(pointPos).firstPoint
    pNew.X"""
    code_block_y = """def getXY (point, id, d2add):
    mxd =  arcpy.mapping.MapDocument("G:\Geocomputation_Project\Section_C\Model_Shapes\Geocomputation_Project.mxd")
    lyr=arcpy.mapping.ListLayers(mxd,"LINES")[0]
    q='"ITEMID"=%s%s%s' %(r"'",id,"'")
    pNew = 0
    with arcpy.da.SearchCursor(lyr,"Shape@",q)as cursor:
        for row in cursor:
            line=row[0];break
            pointPos=line.measureOnLine(point)+d2add
            pNew+=line.positionAlongLine(pointPos).firstPoint
    pNew.Y"""
    
    # Execute AddField for each new X and Y coord
    arcpy.AddField_management(in_table, field_x, "Double")
    arcpy.AddField_management(in_table, field_y, "Double")
    
    # Execute CalculateField to each new X and Y field
    arcpy.CalculateField_management(in_table, field_x, expression,  "PYTHON_9.3", code_block_x)
    arcpy.CalculateField_management(in_table, field_y, expression, "PYTHON_9.3", code_block_y)
    

I keep getting AttributeError: 'int' object has no attribute 'X'.


Answer: Assuming the error in the title is correct, and not the one in the post body,
here's your problem:

    
    
    pNew = 0
    # ...
    pNew.Y
    

It should be pretty obvious that's not going to work

