<?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 Plot shapefiles from gdb to an aprx file in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/plot-shapefiles-from-gdb-to-an-aprx-file/m-p/1487357#M70756</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am working on a scrip that create 2 aprx files ( by copying an existing one then change their names) and after that plot the shapefiles from 2 different gdb's to the corresponding aprx file and after that apply the symbology.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way I can do that in one script (running the code in Pyscripter not within the ArcGIS pro)&lt;BR /&gt;&lt;BR /&gt;The scrip I created can copy the features to the gdb's, change their names and copy and rename the aprx files but when I open the aprx file it's empty with no layers inside it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note: When I run it in Arc GIS Pro it show the shapefiles and copy the symbology but in this case it do it in a different aprx file not the targeted one.&lt;/P&gt;&lt;P&gt;import arcpy&lt;BR /&gt;import os&lt;BR /&gt;import shutil&lt;/P&gt;&lt;P&gt;# Enable overwriting&lt;BR /&gt;arcpy.env.overwriteOutput = True&lt;/P&gt;&lt;P&gt;# Define the source folder and area name&lt;BR /&gt;source_folder = r'C:\Users\HusamOqer\Desktop\2D 3D script\PROJECTAREA37\FinalDelivery' # Update this with your source folder path&lt;BR /&gt;Area_Name = "Dorset_"&lt;/P&gt;&lt;P&gt;empty_project_path = os.path.join(source_folder, 'Symbology', 'Project.aprx')&lt;/P&gt;&lt;P&gt;# Function to copy and rename the project file&lt;BR /&gt;def copy_and_rename_project(original_path, new_folder, new_name):&lt;BR /&gt;new_path = os.path.join(new_folder, f'{new_name}.aprx')&lt;BR /&gt;shutil.copyfile(original_path, new_path)&lt;BR /&gt;return new_path&lt;/P&gt;&lt;P&gt;# Copy and rename the project file for 2D&lt;BR /&gt;aprx_2d_path = copy_and_rename_project(empty_project_path, os.path.join(source_folder, 'Geodatabase_2D'), Area_Name + '2D')&lt;/P&gt;&lt;P&gt;# Copy and rename the project file for 3D&lt;BR /&gt;aprx_3d_path = copy_and_rename_project(empty_project_path, os.path.join(source_folder, 'Geodatabase_3D'), Area_Name + '3D')&lt;/P&gt;&lt;P&gt;# Define paths&lt;BR /&gt;folder_2d_path = os.path.join(source_folder, 'SHPrenamed_2D')&lt;BR /&gt;folder_3d_path = os.path.join(source_folder, 'SHPrenamed_3D')&lt;BR /&gt;destination_gdb_2D = os.path.join(source_folder, 'Geodatabase_2D', Area_Name + '2D.gdb')&lt;BR /&gt;destination_gdb_3D = os.path.join(source_folder, 'Geodatabase_3D', Area_Name + '3D.gdb')&lt;BR /&gt;Symbology = os.path.join(source_folder, "Symbology")&lt;/P&gt;&lt;P&gt;# Function to import shapefiles into the specified geodatabase&lt;BR /&gt;def import_shapefiles(source, destination_gdb):&lt;BR /&gt;arcpy.env.workspace = destination_gdb&lt;/P&gt;&lt;P&gt;# Ensure the destination geodatabase exists&lt;BR /&gt;if not arcpy.Exists(destination_gdb):&lt;BR /&gt;arcpy.CreateFileGDB_management(os.path.dirname(destination_gdb), os.path.basename(destination_gdb))&lt;/P&gt;&lt;P&gt;for root, dirs, files in os.walk(source):&lt;BR /&gt;for file in files:&lt;BR /&gt;if file.lower().endswith('.shp'):&lt;BR /&gt;source_shapefile = os.path.join(root, file)&lt;BR /&gt;feature_class_name = os.path.splitext(file)[0]&lt;/P&gt;&lt;P&gt;# Ensure the output feature class does not already exist&lt;BR /&gt;output_feature_class = os.path.join(destination_gdb, feature_class_name)&lt;BR /&gt;if not arcpy.Exists(output_feature_class):&lt;BR /&gt;arcpy.FeatureClassToGeodatabase_conversion(source_shapefile, destination_gdb)&lt;BR /&gt;print(f"Imported {file} into {destination_gdb}/{feature_class_name}")&lt;BR /&gt;else:&lt;BR /&gt;print(f"Skipped {file} - Feature class already exists in {destination_gdb}")&lt;/P&gt;&lt;P&gt;# Import shapefiles from SHPrenamed_3D to Geodatabase_3D&lt;BR /&gt;import_shapefiles(folder_3d_path, destination_gdb_3D)&lt;/P&gt;&lt;P&gt;# Import shapefiles from SHPrenamed_2D to Geodatabase_2D&lt;BR /&gt;import_shapefiles(folder_2d_path, destination_gdb_2D)&lt;/P&gt;&lt;P&gt;# Rename the 3D geodatabase&lt;BR /&gt;new_destination_gdb_3D = os.path.join(os.path.dirname(destination_gdb_3D), Area_Name + '3D.gdb')&lt;BR /&gt;if not arcpy.Exists(new_destination_gdb_3D):&lt;BR /&gt;arcpy.management.Rename(destination_gdb_3D, new_destination_gdb_3D)&lt;BR /&gt;else:&lt;BR /&gt;print(f"The destination geodatabase {new_destination_gdb_3D} already exists. Skipping rename.")&lt;/P&gt;&lt;P&gt;# Rename the 2D geodatabase&lt;BR /&gt;new_destination_gdb_2D = os.path.join(os.path.dirname(destination_gdb_2D), Area_Name + '2D.gdb')&lt;BR /&gt;if not arcpy.Exists(new_destination_gdb_2D):&lt;BR /&gt;arcpy.management.Rename(destination_gdb_2D, new_destination_gdb_2D)&lt;BR /&gt;else:&lt;BR /&gt;print(f"The destination geodatabase {new_destination_gdb_2D} already exists. Skipping rename.")&lt;/P&gt;&lt;P&gt;# Function to add layers from a geodatabase to a map&lt;BR /&gt;def add_layers_to_map(aprx_path, gdb_path, symbology_folder, suffix):&lt;BR /&gt;aprx = arcpy.mp.ArcGISProject(aprx_path)&lt;BR /&gt;map_obj = aprx.listMaps()[0]&lt;/P&gt;&lt;P&gt;# Loop through the feature classes in the geodatabase&lt;BR /&gt;for dirpath, dirnames, filenames in arcpy.da.Walk(gdb_path, datatype="FeatureClass"):&lt;BR /&gt;for filename in filenames:&lt;BR /&gt;layerfile = os.path.join(dirpath, filename)&lt;BR /&gt;if filename == "PoleIDAnno":&lt;BR /&gt;temp_layer = "PoleIDAnno"&lt;BR /&gt;arcpy.management.MakeFeatureLayer(layerfile, temp_layer)&lt;BR /&gt;addlayer = os.path.abspath(temp_layer)&lt;BR /&gt;else:&lt;BR /&gt;addlayer = os.path.abspath(layerfile)&lt;/P&gt;&lt;P&gt;map_obj.addDataFromPath(addlayer)&lt;/P&gt;&lt;P&gt;# Loop through the .lyr and .lyrx files in the symbology folder&lt;BR /&gt;for file in os.listdir(symbology_folder):&lt;BR /&gt;if file.endswith((".lyr", ".lyrx")):&lt;BR /&gt;lyr_path = os.path.join(symbology_folder, file)&lt;BR /&gt;lyr_name = os.path.splitext(file)[0]&lt;/P&gt;&lt;P&gt;# Check if the .lyr or .lyrx file name matches any layer name in the map&lt;BR /&gt;for lyr in map_obj.listLayers():&lt;BR /&gt;if lyr_name in lyr.name and lyr.name.endswith(suffix): # Apply symbology only if the layer ends with suffix&lt;BR /&gt;print(f"Applying symbology from {lyr_path} to layer {lyr.name}")&lt;BR /&gt;arcpy.management.ApplySymbologyFromLayer(lyr, lyr_path)&lt;BR /&gt;print("Symbology applied!")&lt;BR /&gt;break # Exit loop after finding a match&lt;/P&gt;&lt;P&gt;# Save changes to the ArcGIS Pro project&lt;BR /&gt;aprx.save()&lt;/P&gt;&lt;P&gt;# Add layers and apply symbology to the 2D project&lt;BR /&gt;add_layers_to_map(aprx_2d_path, new_destination_gdb_2D, Symbology, '_2D')&lt;/P&gt;&lt;P&gt;# Add layers and apply symbology to the 3D project&lt;BR /&gt;add_layers_to_map(aprx_3d_path, new_destination_gdb_3D, Symbology, '_3D')&lt;/P&gt;&lt;P&gt;# Cleanup unnecessary geodatabases&lt;BR /&gt;def cleanup_geodatabases(source_folder):&lt;BR /&gt;for folder_name in ['Geodatabase_2D', 'Geodatabase_3D']:&lt;BR /&gt;full_folder_path = os.path.join(source_folder, folder_name)&lt;/P&gt;&lt;P&gt;for gdb_name in os.listdir(full_folder_path):&lt;BR /&gt;gdb_path = os.path.join(full_folder_path, gdb_name)&lt;/P&gt;&lt;P&gt;# Check if the gdb_name starts with the correct Area_Name&lt;BR /&gt;if gdb_name.startswith(Area_Name):&lt;BR /&gt;print(f"Keeping geodatabase: {gdb_path}")&lt;BR /&gt;else:&lt;BR /&gt;print(f"Deleting unnecessary geodatabase: {gdb_path}")&lt;BR /&gt;arcpy.management.Delete(gdb_path)&lt;/P&gt;&lt;P&gt;# Run cleanup&lt;BR /&gt;cleanup_geodatabases(source_folder)&lt;/P&gt;</description>
    <pubDate>Fri, 07 Jun 2024 17:21:15 GMT</pubDate>
    <dc:creator>HusamOqer</dc:creator>
    <dc:date>2024-06-07T17:21:15Z</dc:date>
    <item>
      <title>Plot shapefiles from gdb to an aprx file</title>
      <link>https://community.esri.com/t5/python-questions/plot-shapefiles-from-gdb-to-an-aprx-file/m-p/1487357#M70756</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am working on a scrip that create 2 aprx files ( by copying an existing one then change their names) and after that plot the shapefiles from 2 different gdb's to the corresponding aprx file and after that apply the symbology.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way I can do that in one script (running the code in Pyscripter not within the ArcGIS pro)&lt;BR /&gt;&lt;BR /&gt;The scrip I created can copy the features to the gdb's, change their names and copy and rename the aprx files but when I open the aprx file it's empty with no layers inside it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note: When I run it in Arc GIS Pro it show the shapefiles and copy the symbology but in this case it do it in a different aprx file not the targeted one.&lt;/P&gt;&lt;P&gt;import arcpy&lt;BR /&gt;import os&lt;BR /&gt;import shutil&lt;/P&gt;&lt;P&gt;# Enable overwriting&lt;BR /&gt;arcpy.env.overwriteOutput = True&lt;/P&gt;&lt;P&gt;# Define the source folder and area name&lt;BR /&gt;source_folder = r'C:\Users\HusamOqer\Desktop\2D 3D script\PROJECTAREA37\FinalDelivery' # Update this with your source folder path&lt;BR /&gt;Area_Name = "Dorset_"&lt;/P&gt;&lt;P&gt;empty_project_path = os.path.join(source_folder, 'Symbology', 'Project.aprx')&lt;/P&gt;&lt;P&gt;# Function to copy and rename the project file&lt;BR /&gt;def copy_and_rename_project(original_path, new_folder, new_name):&lt;BR /&gt;new_path = os.path.join(new_folder, f'{new_name}.aprx')&lt;BR /&gt;shutil.copyfile(original_path, new_path)&lt;BR /&gt;return new_path&lt;/P&gt;&lt;P&gt;# Copy and rename the project file for 2D&lt;BR /&gt;aprx_2d_path = copy_and_rename_project(empty_project_path, os.path.join(source_folder, 'Geodatabase_2D'), Area_Name + '2D')&lt;/P&gt;&lt;P&gt;# Copy and rename the project file for 3D&lt;BR /&gt;aprx_3d_path = copy_and_rename_project(empty_project_path, os.path.join(source_folder, 'Geodatabase_3D'), Area_Name + '3D')&lt;/P&gt;&lt;P&gt;# Define paths&lt;BR /&gt;folder_2d_path = os.path.join(source_folder, 'SHPrenamed_2D')&lt;BR /&gt;folder_3d_path = os.path.join(source_folder, 'SHPrenamed_3D')&lt;BR /&gt;destination_gdb_2D = os.path.join(source_folder, 'Geodatabase_2D', Area_Name + '2D.gdb')&lt;BR /&gt;destination_gdb_3D = os.path.join(source_folder, 'Geodatabase_3D', Area_Name + '3D.gdb')&lt;BR /&gt;Symbology = os.path.join(source_folder, "Symbology")&lt;/P&gt;&lt;P&gt;# Function to import shapefiles into the specified geodatabase&lt;BR /&gt;def import_shapefiles(source, destination_gdb):&lt;BR /&gt;arcpy.env.workspace = destination_gdb&lt;/P&gt;&lt;P&gt;# Ensure the destination geodatabase exists&lt;BR /&gt;if not arcpy.Exists(destination_gdb):&lt;BR /&gt;arcpy.CreateFileGDB_management(os.path.dirname(destination_gdb), os.path.basename(destination_gdb))&lt;/P&gt;&lt;P&gt;for root, dirs, files in os.walk(source):&lt;BR /&gt;for file in files:&lt;BR /&gt;if file.lower().endswith('.shp'):&lt;BR /&gt;source_shapefile = os.path.join(root, file)&lt;BR /&gt;feature_class_name = os.path.splitext(file)[0]&lt;/P&gt;&lt;P&gt;# Ensure the output feature class does not already exist&lt;BR /&gt;output_feature_class = os.path.join(destination_gdb, feature_class_name)&lt;BR /&gt;if not arcpy.Exists(output_feature_class):&lt;BR /&gt;arcpy.FeatureClassToGeodatabase_conversion(source_shapefile, destination_gdb)&lt;BR /&gt;print(f"Imported {file} into {destination_gdb}/{feature_class_name}")&lt;BR /&gt;else:&lt;BR /&gt;print(f"Skipped {file} - Feature class already exists in {destination_gdb}")&lt;/P&gt;&lt;P&gt;# Import shapefiles from SHPrenamed_3D to Geodatabase_3D&lt;BR /&gt;import_shapefiles(folder_3d_path, destination_gdb_3D)&lt;/P&gt;&lt;P&gt;# Import shapefiles from SHPrenamed_2D to Geodatabase_2D&lt;BR /&gt;import_shapefiles(folder_2d_path, destination_gdb_2D)&lt;/P&gt;&lt;P&gt;# Rename the 3D geodatabase&lt;BR /&gt;new_destination_gdb_3D = os.path.join(os.path.dirname(destination_gdb_3D), Area_Name + '3D.gdb')&lt;BR /&gt;if not arcpy.Exists(new_destination_gdb_3D):&lt;BR /&gt;arcpy.management.Rename(destination_gdb_3D, new_destination_gdb_3D)&lt;BR /&gt;else:&lt;BR /&gt;print(f"The destination geodatabase {new_destination_gdb_3D} already exists. Skipping rename.")&lt;/P&gt;&lt;P&gt;# Rename the 2D geodatabase&lt;BR /&gt;new_destination_gdb_2D = os.path.join(os.path.dirname(destination_gdb_2D), Area_Name + '2D.gdb')&lt;BR /&gt;if not arcpy.Exists(new_destination_gdb_2D):&lt;BR /&gt;arcpy.management.Rename(destination_gdb_2D, new_destination_gdb_2D)&lt;BR /&gt;else:&lt;BR /&gt;print(f"The destination geodatabase {new_destination_gdb_2D} already exists. Skipping rename.")&lt;/P&gt;&lt;P&gt;# Function to add layers from a geodatabase to a map&lt;BR /&gt;def add_layers_to_map(aprx_path, gdb_path, symbology_folder, suffix):&lt;BR /&gt;aprx = arcpy.mp.ArcGISProject(aprx_path)&lt;BR /&gt;map_obj = aprx.listMaps()[0]&lt;/P&gt;&lt;P&gt;# Loop through the feature classes in the geodatabase&lt;BR /&gt;for dirpath, dirnames, filenames in arcpy.da.Walk(gdb_path, datatype="FeatureClass"):&lt;BR /&gt;for filename in filenames:&lt;BR /&gt;layerfile = os.path.join(dirpath, filename)&lt;BR /&gt;if filename == "PoleIDAnno":&lt;BR /&gt;temp_layer = "PoleIDAnno"&lt;BR /&gt;arcpy.management.MakeFeatureLayer(layerfile, temp_layer)&lt;BR /&gt;addlayer = os.path.abspath(temp_layer)&lt;BR /&gt;else:&lt;BR /&gt;addlayer = os.path.abspath(layerfile)&lt;/P&gt;&lt;P&gt;map_obj.addDataFromPath(addlayer)&lt;/P&gt;&lt;P&gt;# Loop through the .lyr and .lyrx files in the symbology folder&lt;BR /&gt;for file in os.listdir(symbology_folder):&lt;BR /&gt;if file.endswith((".lyr", ".lyrx")):&lt;BR /&gt;lyr_path = os.path.join(symbology_folder, file)&lt;BR /&gt;lyr_name = os.path.splitext(file)[0]&lt;/P&gt;&lt;P&gt;# Check if the .lyr or .lyrx file name matches any layer name in the map&lt;BR /&gt;for lyr in map_obj.listLayers():&lt;BR /&gt;if lyr_name in lyr.name and lyr.name.endswith(suffix): # Apply symbology only if the layer ends with suffix&lt;BR /&gt;print(f"Applying symbology from {lyr_path} to layer {lyr.name}")&lt;BR /&gt;arcpy.management.ApplySymbologyFromLayer(lyr, lyr_path)&lt;BR /&gt;print("Symbology applied!")&lt;BR /&gt;break # Exit loop after finding a match&lt;/P&gt;&lt;P&gt;# Save changes to the ArcGIS Pro project&lt;BR /&gt;aprx.save()&lt;/P&gt;&lt;P&gt;# Add layers and apply symbology to the 2D project&lt;BR /&gt;add_layers_to_map(aprx_2d_path, new_destination_gdb_2D, Symbology, '_2D')&lt;/P&gt;&lt;P&gt;# Add layers and apply symbology to the 3D project&lt;BR /&gt;add_layers_to_map(aprx_3d_path, new_destination_gdb_3D, Symbology, '_3D')&lt;/P&gt;&lt;P&gt;# Cleanup unnecessary geodatabases&lt;BR /&gt;def cleanup_geodatabases(source_folder):&lt;BR /&gt;for folder_name in ['Geodatabase_2D', 'Geodatabase_3D']:&lt;BR /&gt;full_folder_path = os.path.join(source_folder, folder_name)&lt;/P&gt;&lt;P&gt;for gdb_name in os.listdir(full_folder_path):&lt;BR /&gt;gdb_path = os.path.join(full_folder_path, gdb_name)&lt;/P&gt;&lt;P&gt;# Check if the gdb_name starts with the correct Area_Name&lt;BR /&gt;if gdb_name.startswith(Area_Name):&lt;BR /&gt;print(f"Keeping geodatabase: {gdb_path}")&lt;BR /&gt;else:&lt;BR /&gt;print(f"Deleting unnecessary geodatabase: {gdb_path}")&lt;BR /&gt;arcpy.management.Delete(gdb_path)&lt;/P&gt;&lt;P&gt;# Run cleanup&lt;BR /&gt;cleanup_geodatabases(source_folder)&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jun 2024 17:21:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/plot-shapefiles-from-gdb-to-an-aprx-file/m-p/1487357#M70756</guid>
      <dc:creator>HusamOqer</dc:creator>
      <dc:date>2024-06-07T17:21:15Z</dc:date>
    </item>
    <item>
      <title>Re: Plot shapefiles from gdb to an aprx file</title>
      <link>https://community.esri.com/t5/python-questions/plot-shapefiles-from-gdb-to-an-aprx-file/m-p/1494880#M70855</link>
      <description>&lt;LI-CODE lang="python"&gt;import arcpy
import os
import shutil

## Folder Structure:
# Source
# ├── Project_2D.aprx
# ├── Project_3D.aprx
# ├── Databases
# │   ├── db_2D.gdb
# │   └── db_3D.gdb
# ├── Layers
# │   ├── layer_2D.lyrx
# │   └── layer_3D.lyrx
# └── Shapefiles
#     ├── shape_2D.shp
#     └── shape_3D.shp

# Target
# ├── db_2D.gdb
# ├── db_3D.gdb
# ├── Project_2D.aprx
# └── Project_3D.aprx

    
class Builder:
    def __init__(self, source: os.PathLike, suffixes: list[str]= ["2D", "3D"]):
        self.suffixes = suffixes
        self._projects = \
            {
                prj.split('.')[0]: arcpy.mp.ArcGISProject(os.path.join(source, prj))
                for prj in os.listdir(source)
                if prj.endswith(".aprx")
            }
        self._shapefiles = \
            {
                sf.split('.')[0]: os.path.join(source, "Shapefiles", sf)
                for sf in os.listdir(os.path.join(source, "Shapefiles"))
                if sf.endswith(".shp")
            }
        self._layers = \
            {
                lyr.split('.')[0]: os.path.join(source, "Layers", lyr)
                for lyr in os.listdir(os.path.join(source, "Layers"))
                if lyr.endswith(".lyrx")
            }
        self._databases = \
            {
                db.split('.')[0]: os.path.join(source, "Databases", db)
                for db in os.listdir(os.path.join(source, "Databases"))
                if db.endswith(".gdb")
            }
        return
    
    def create(self, target: os.PathLike):
        """ Create a new project from the source folder 
        target: str, path to the target folder
        """
        for suffix in self.suffixes:
            print(f"Creating {suffix} project")
            # create/get target project
            project = self._get_new_project(target, suffix)
            print(f"Creating {suffix} database")
            # create/get target database
            target_db = self._get_target_db(target, suffix)
            project.updateDatabases(
                [
                    {
                        'databasePath': target_db,
                        'isDefaultDatabase': True,
                    },
                ]
            )
            # Copy shapefiles into gdb and create layers
            print(f"Creating {suffix} layers")
            self._build_layer(suffix, project, target_db)
            project.save()
        return

    def _build_layer(self, suffix, project, target_db):
        for sf_name, sf in self._shapefiles.items():
            if not sf_name.endswith(suffix): continue
            # Create New Feature Class
            new_feature = arcpy.conversion.FeatureClassToFeatureClass(sf, target_db, sf_name)
            # Get Matching LYRX file
            new_feature_symbology = self._layers[sf_name]
            # Get first map and add data
            new_layer = project.listMaps()[0].addDataFromPath(new_feature)
            # Apply Symbology
            arcpy.management.ApplySymbologyFromLayer(new_layer, new_feature_symbology)
        return
    
    def _get_target_db(self, target, suffix):
        for db_name, db in self._databases.items():
            if not db_name.endswith(suffix): continue
            return shutil.copytree(db, os.path.join(target, f"{db_name}.gdb"))
        raise ValueError(f"No database for {suffix} found in source folder")

    def _get_new_project(self, target, suffix):
        for prj_name, prj in self._projects.items():
            if not prj_name.endswith(suffix): continue
            new_project_path = os.path.join(target, f"{prj_name}.aprx")
            # Copy Project and Set copy to active project
            shutil.copy(prj.filePath, new_project_path)
            return arcpy.mp.ArcGISProject(new_project_path)
        raise ValueError(f"No project for {suffix} found in source folder")
    
def main():
    source = r"&amp;lt;source&amp;gt;"
    target = r"&amp;lt;target&amp;gt;"
    builder = Builder(source, suffixes=['2D', '3D'])
    builder.create(target)
    return

def main2():
    source = r"&amp;lt;source&amp;gt;"
    targets = [r"&amp;lt;target1&amp;gt;", r"&amp;lt;target2&amp;gt;", r"&amp;lt;target3&amp;gt;", r"&amp;lt;target4&amp;gt;"]
    builder = Builder(source)
    for target in targets:
        builder.create(target)
    return

if __name__ == "__main__":
    main()
    #main2()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was having a hard time following your program flow, but I attempted to re-implement it in a slightly more modular way. Now all you need to do is add methods to the builder object ten call them in order in that create function to add steps. The __init__ function relies on the Source folder to be structured as shown in the comment at the top of the code, but changing those `for &amp;lt;object&amp;gt; in os.path.join(&amp;lt;root&amp;gt;, &amp;lt;subfolder&amp;gt;, &amp;lt;arcobject&amp;gt;)` to something else should be easy.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jun 2024 12:08:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/plot-shapefiles-from-gdb-to-an-aprx-file/m-p/1494880#M70855</guid>
      <dc:creator>HaydenWelch</dc:creator>
      <dc:date>2024-06-19T12:08:24Z</dc:date>
    </item>
  </channel>
</rss>

