<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Open feature class attribute table with arcpy in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/open-feature-class-attribute-table-with-arcpy/m-p/1386261#M69949</link>
    <description>&lt;P&gt;EDIT: To clarify some confusion. My script current adds EXTABLE, geocodes EXTABLE and saves a new feature class to a file geodatabase. That new Feature class is called EXAMPLE. I also want the script to open the attribute table in a new view window that is associated with EXAMPLE.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The closest method I have found is .openView() under the Map class. I have not been able to successfully execute this method without receiving an error: openView() takes 1 positional argument but 2 were given.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Sample&lt;/STRONG&gt;:&lt;/P&gt;&lt;P&gt;aprx = arcpy.mp.ArcGISProject("Current")&lt;/P&gt;&lt;P&gt;MP = aprx.activeMap&lt;/P&gt;&lt;P&gt;Layer = MP.listLayers("EXAMPLE")[0]&lt;/P&gt;&lt;P&gt;MP.openView(Layer)&lt;/P&gt;&lt;P&gt;This returns the &lt;EM&gt;"openView() takes 1 positional argument but 2 were given error."&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My next best guess it to just make python perform an action such as Ctrl + T or Ctrl double click to open the attribute table.&lt;/P&gt;&lt;P&gt;&lt;EM&gt;"I am once again asking for your support" - Bernie Sanders&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a script that adds an access database table to a map.&lt;/P&gt;&lt;P&gt;Then geocodes that table and creates a new feature class.&lt;/P&gt;&lt;P&gt;I also want this script to open the attribute table associated with the new feature class.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to do this in arcpy?&lt;/P&gt;</description>
    <pubDate>Mon, 26 Feb 2024 14:27:06 GMT</pubDate>
    <dc:creator>BrandonMcAlister</dc:creator>
    <dc:date>2024-02-26T14:27:06Z</dc:date>
    <item>
      <title>Open feature class attribute table with arcpy</title>
      <link>https://community.esri.com/t5/python-questions/open-feature-class-attribute-table-with-arcpy/m-p/1386261#M69949</link>
      <description>&lt;P&gt;EDIT: To clarify some confusion. My script current adds EXTABLE, geocodes EXTABLE and saves a new feature class to a file geodatabase. That new Feature class is called EXAMPLE. I also want the script to open the attribute table in a new view window that is associated with EXAMPLE.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The closest method I have found is .openView() under the Map class. I have not been able to successfully execute this method without receiving an error: openView() takes 1 positional argument but 2 were given.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Sample&lt;/STRONG&gt;:&lt;/P&gt;&lt;P&gt;aprx = arcpy.mp.ArcGISProject("Current")&lt;/P&gt;&lt;P&gt;MP = aprx.activeMap&lt;/P&gt;&lt;P&gt;Layer = MP.listLayers("EXAMPLE")[0]&lt;/P&gt;&lt;P&gt;MP.openView(Layer)&lt;/P&gt;&lt;P&gt;This returns the &lt;EM&gt;"openView() takes 1 positional argument but 2 were given error."&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My next best guess it to just make python perform an action such as Ctrl + T or Ctrl double click to open the attribute table.&lt;/P&gt;&lt;P&gt;&lt;EM&gt;"I am once again asking for your support" - Bernie Sanders&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a script that adds an access database table to a map.&lt;/P&gt;&lt;P&gt;Then geocodes that table and creates a new feature class.&lt;/P&gt;&lt;P&gt;I also want this script to open the attribute table associated with the new feature class.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to do this in arcpy?&lt;/P&gt;</description>
      <pubDate>Mon, 26 Feb 2024 14:27:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/open-feature-class-attribute-table-with-arcpy/m-p/1386261#M69949</guid>
      <dc:creator>BrandonMcAlister</dc:creator>
      <dc:date>2024-02-26T14:27:06Z</dc:date>
    </item>
    <item>
      <title>Re: Open feature class attribute table with arcpy</title>
      <link>https://community.esri.com/t5/python-questions/open-feature-class-attribute-table-with-arcpy/m-p/1386412#M69950</link>
      <description>&lt;P&gt;Hi, I am not sure about the question. Regarding access directly to the database, arcpy has arcpy.da (&lt;A href="https://pro.arcgis.com/en/pro-app/3.1/arcpy/data-access/what-is-the-data-access-module-.htm" target="_blank"&gt;What is the Data Access module—ArcGIS Pro | Documentation&lt;/A&gt;). I usually use InsertCursor, UpdateCursor, and SearchCursor.&lt;/P&gt;&lt;P&gt;For geocodes, arcpy has geocode module (&lt;A href="https://pro.arcgis.com/en/pro-app/3.1/tool-reference/geocoding/geocode-addresses.htm" target="_blank"&gt;Geocode Addresses (Geocoding)—ArcGIS Pro | Documentation&lt;/A&gt;). Unfortunately, arcpy geocode best practice results only US. I already tried in my home country is not what I expected. Usually, I use another 3rd party such as the osm module. The result will be used by arcpy to record in the feature class or shp.&lt;/P&gt;&lt;P&gt;Hope, it might answered your curiosity&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;</description>
      <pubDate>Sat, 24 Feb 2024 01:50:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/open-feature-class-attribute-table-with-arcpy/m-p/1386412#M69950</guid>
      <dc:creator>AlexanderDanielPratama</dc:creator>
      <dc:date>2024-02-24T01:50:37Z</dc:date>
    </item>
    <item>
      <title>Re: Open feature class attribute table with arcpy</title>
      <link>https://community.esri.com/t5/python-questions/open-feature-class-attribute-table-with-arcpy/m-p/1386467#M69953</link>
      <description>&lt;P&gt;If I'm reading your question correctly, you want the last step of the tool to open the attribute table the same as if you'd right-clicked on the layer and said "Open Attribute Table", correct?&lt;/P&gt;&lt;P&gt;Unless I'm mistaken, that would likely be in the arcpy.mp module, if it's anywhere.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm only just beginning most of my dive into that module, so I'm not familiar enough to say off-hand if/how it can be done.&lt;/P&gt;</description>
      <pubDate>Sat, 24 Feb 2024 18:50:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/open-feature-class-attribute-table-with-arcpy/m-p/1386467#M69953</guid>
      <dc:creator>MErikReedAugusta</dc:creator>
      <dc:date>2024-02-24T18:50:31Z</dc:date>
    </item>
    <item>
      <title>Re: Open feature class attribute table with arcpy</title>
      <link>https://community.esri.com/t5/python-questions/open-feature-class-attribute-table-with-arcpy/m-p/1388902#M69998</link>
      <description>&lt;P&gt;Could not find an easy way to do this within arcpy.mp, however using a SendKeys style hack off of Stack Overflow you can send the Keyboard shortcut Ctrl+T right after adding the layer. See the code below, if you paste this directly into the Python window it doesn't work because it sends the keystrokes to the code editor, however if you put the script behind a Geoprocessing tool, it does work for me ..&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

# shamelessly lifted from ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# https://stackoverflow.com/questions/13289777/how-can-i-send-keyboard-commands-hold-release-simultanous-with-a-python-script
import ctypes, time

PUL = ctypes.POINTER(ctypes.c_ulong)

class KeyBdInput(ctypes.Structure) :
    _fields_ = [("wVk", ctypes.c_ushort), ("wScan", ctypes.c_ushort), ("dwFlags", ctypes.c_ulong), ("time", ctypes.c_ulong), ("dwExtraInfo", PUL)]

class HardwareInput(ctypes.Structure):
    _fields_ = [("uMsg", ctypes.c_ulong), ("wParamL", ctypes.c_short), ("wParamH", ctypes.c_ushort)]

class MouseInput(ctypes.Structure):
    _fields_ = [("dx", ctypes.c_long), ("dy", ctypes.c_long), ("mouseData", ctypes.c_ulong), ("dwFlags", ctypes.c_ulong), ("time",ctypes.c_ulong), ("dwExtraInfo", PUL)]

class Input_I(ctypes.Union):
    _fields_ = [("ki", KeyBdInput), ("mi", MouseInput), ("hi", HardwareInput)]

class Input(ctypes.Structure):
    _fields_ = [("type", ctypes.c_ulong), ("ii", Input_I)]

def doKey(hexKeyCode, keyUp=False) :
    direction_flag = 0
    if (keyUp) : direction_flag = 0x0002
    extra = ctypes.c_ulong(0)
    ii_ = Input_I()
    ii_.ki = KeyBdInput( hexKeyCode, 0x48, direction_flag, 0, ctypes.pointer(extra) )
    x = Input( ctypes.c_ulong(1), ii_ )
    ctypes.windll.user32.SendInput(1, ctypes.pointer(x), ctypes.sizeof(x))    
    # ------------------------------------------------------------------------

def PressKeys(hexKeys, waitTime=1):
    for hk in hexKeys : doKey(hk)
    time.sleep(waitTime)
    for hk in hexKeys : doKey(hk, keyUp=True)
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

# --------------------------------------------------------------------------
try :
    proj = arcpy.mp.ArcGISProject("CURRENT")
    map = proj.activeMap
    lyr = arcpy.management.MakeFeatureLayer(r"C:\Users\rh\Documents\ArcGIS\Projects\MyProject\MyProject.gdb\test_dataset", "TEST1234").getOutput(0)
    map.addLayer(lyr)
except Exception as ex :
    arcpy.gp.AddError(ex)

# https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
PressKeys( [0x11, 0x54], 1 ) # Ctrl + T&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RHmapping_0-1709223931058.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/96326iD6918F43D3653EC5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RHmapping_0-1709223931058.png" alt="RHmapping_0-1709223931058.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Feb 2024 16:25:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/open-feature-class-attribute-table-with-arcpy/m-p/1388902#M69998</guid>
      <dc:creator>RHmapping</dc:creator>
      <dc:date>2024-02-29T16:25:58Z</dc:date>
    </item>
  </channel>
</rss>

