<?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 Re: Geodatabase as workspace in Python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/geodatabase-as-workspace-in-python/m-p/105342#M8115</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Too many confusing variable references going on.&amp;nbsp; I see a problem with how you are referencing os.path, you're importing as 'path'....then later in the script you're still using os.path.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;So, not sure if that's your problem, but still bad practice because how do you know how 'os.path' is being interpreted if you told Python that 'path' itself represents 'os.path' (with 'import os.path as path')??&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I suggest this, simplify your 'os' import statement (if you aren't going to use the 'path' ref anyway) and until you get a better idea, just use the single import statement as shown:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import os, sys, arcpy
arcpy.env.overwriteOutput = True
Building = sys.argv[1]
DirOutPut = sys.argv[2]
 
arcpy.CreateFileGDB_management(DirOutPut, "data_building.gdb", "CURRENT") 
arcpy.env.workspace = os.path.join(DirOutPut, "data_building.gdb")


arcpy.SimplifyBuilding_cartography(Building,"Building_symply", 0.5) 
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Try that --- not sure about the syntax of the SimplifyBuilding, but think you can take if from here....notice the toolbox aliases are after the command appended with an underscore character (e.g., '_management').&amp;nbsp; Probably other ways are acceptable, but this is the common way.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Enjoy,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Wayne&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;EDIT:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I don't see anything wrong with reference statements such as 'import arcpy.cartography as CA' coupled with your later statement 'CA.SimplifyBuilding...', but can be more confusing until you grow more accustomed to using such references.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, fetching arguments with 'sys.argv' is ok, but also consider the get parameter methods of arcpy - such as:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Building = arcpy.GetParameterAsText(0)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;See--- (and also notice the other varieties under the 'Getting and Setting Parameters' topic)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;GetParameterAsText (arcpy)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Desktop » Geoprocessing » ArcPy » ArcPy functions&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//018v00000047000000" rel="nofollow noopener noreferrer" target="_blank"&gt;http://resources.arcgis.com/en/help/main/10.1/index.html#//018v00000047000000&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 06:25:54 GMT</pubDate>
    <dc:creator>T__WayneWhitley</dc:creator>
    <dc:date>2021-12-11T06:25:54Z</dc:date>
    <item>
      <title>Geodatabase as workspace in Python</title>
      <link>https://community.esri.com/t5/python-questions/geodatabase-as-workspace-in-python/m-p/105341#M8114</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I want to create a geodatabase as workspace using python. It woks if the Geodatabase is called data.gdb. But if I change the name of the geodatabase, the FC are stored as shapefile in the external folder but not into the geodatabase&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import os&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import sys&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;from arcpy import env&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import os.path as path&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy.cartography as CA&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.overwriteOutput = True&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Building = sys.argv [1]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;DirOutPut = sys.argv[2]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.management.CreateFileGDB(sys.argv[2], "data_building.gdb", "CURRENT") &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;##With this Geodatabase name does not work. But it works with the name data.gdb, I need that the GDB has different name than data&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;results_gdb = os.path.join(DirOutPut + "\\"+"data_building.gdb")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.workspace = results_gdb&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;CA.SimplifyBuilding(Building ,"Building_symply", 0.5)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 02 Feb 2013 08:42:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/geodatabase-as-workspace-in-python/m-p/105341#M8114</guid>
      <dc:creator>AngelaBlanco</dc:creator>
      <dc:date>2013-02-02T08:42:46Z</dc:date>
    </item>
    <item>
      <title>Re: Geodatabase as workspace in Python</title>
      <link>https://community.esri.com/t5/python-questions/geodatabase-as-workspace-in-python/m-p/105342#M8115</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Too many confusing variable references going on.&amp;nbsp; I see a problem with how you are referencing os.path, you're importing as 'path'....then later in the script you're still using os.path.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;So, not sure if that's your problem, but still bad practice because how do you know how 'os.path' is being interpreted if you told Python that 'path' itself represents 'os.path' (with 'import os.path as path')??&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I suggest this, simplify your 'os' import statement (if you aren't going to use the 'path' ref anyway) and until you get a better idea, just use the single import statement as shown:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import os, sys, arcpy
arcpy.env.overwriteOutput = True
Building = sys.argv[1]
DirOutPut = sys.argv[2]
 
arcpy.CreateFileGDB_management(DirOutPut, "data_building.gdb", "CURRENT") 
arcpy.env.workspace = os.path.join(DirOutPut, "data_building.gdb")


arcpy.SimplifyBuilding_cartography(Building,"Building_symply", 0.5) 
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Try that --- not sure about the syntax of the SimplifyBuilding, but think you can take if from here....notice the toolbox aliases are after the command appended with an underscore character (e.g., '_management').&amp;nbsp; Probably other ways are acceptable, but this is the common way.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Enjoy,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Wayne&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;EDIT:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I don't see anything wrong with reference statements such as 'import arcpy.cartography as CA' coupled with your later statement 'CA.SimplifyBuilding...', but can be more confusing until you grow more accustomed to using such references.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, fetching arguments with 'sys.argv' is ok, but also consider the get parameter methods of arcpy - such as:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Building = arcpy.GetParameterAsText(0)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;See--- (and also notice the other varieties under the 'Getting and Setting Parameters' topic)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;GetParameterAsText (arcpy)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Desktop » Geoprocessing » ArcPy » ArcPy functions&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//018v00000047000000" rel="nofollow noopener noreferrer" target="_blank"&gt;http://resources.arcgis.com/en/help/main/10.1/index.html#//018v00000047000000&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 06:25:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/geodatabase-as-workspace-in-python/m-p/105342#M8115</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2021-12-11T06:25:54Z</dc:date>
    </item>
  </channel>
</rss>

