<?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: Format fonts, size, style using existing layer formatting in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/format-fonts-size-style-using-existing-layer/m-p/180216#M13841</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Bumping this up. Looking for answer for the same question above. Same environment - 10.0, won't be upgrading to 10.1 soon. Want to apply label styles just like applying symbology. How do I go about it?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;TIA&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-Deepti&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 26 Oct 2012 22:15:34 GMT</pubDate>
    <dc:creator>DeeptiVB</dc:creator>
    <dc:date>2012-10-26T22:15:34Z</dc:date>
    <item>
      <title>Format fonts, size, style using existing layer formatting</title>
      <link>https://community.esri.com/t5/python-questions/format-fonts-size-style-using-existing-layer/m-p/180215#M13840</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I need to automate map creation using arcpy and pull specific fonts, styles, text alignment from a layer from an existing mxd. The existing mxd uses &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;maplex. (I understand maplex is the new engine in 10.1, but I am on 10.0. Not sure if an upgrade would solve much of this. We have to do a lot of testing &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;before we upgrade to 10.1, so I am wondering if it will help for this issue or not. )&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am creating layers using arcpy with select by attribute method, then saving as .lyr file and adding this .lyr file to a fairly basic mxd template. Here &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;are some things I have tried to apply layer styles. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;UL&gt;&lt;BR /&gt;I looked at this post &lt;A href="http://forums.arcgis.com/threads/43240-Apply-symbology-labels-hatches-in-arcpy" rel="nofollow noopener noreferrer" target="_blank"&gt;http://forums.arcgis.com/threads/43240-Apply-symbology-labels-hatches-in-arcpy&lt;/A&gt;, but I don't understand how to change datasource on a layer. I'm not a GIS analyst, I am a programmer, so I'm just not understanding how to access or change the underlying data for a layer. (for example, the data that is the result of: select BOOK_PAGE like '12345%').&lt;BR /&gt;Applying only symbology is not enough, it does not bring over these items (ApplySymbologyFromLayer_management)&lt;BR /&gt;I do not see how to use LabelClass to do this. How do I align, bold etc?&lt;BR /&gt;UpdateLayer will update my new layer with all the font styles that I want from an exported layer from the original map. But, it essentially replaces my new layer with the exported layer that I am using as source, including a data source that I'm wanting to be dynamic.&lt;BR /&gt;&lt;/UL&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is my code using UpdateLayer:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Setup database to work with
arcpy.env.workspace = "Database Connections/gis_inquire.sde/AS.Parcels"

# Create Feature Layer - all areas
base_layer = arcpy.MakeFeatureLayer_management("ASSESSORS.ParcelsWO") 

# From Feature Layer, select by criteria
parcel_selection = arcpy.SelectLayerByAttribute_management(base_layer,"NEW_SELECTION","BOOK_PAGE LIKE '12345%'")

# Save parcels feature layer to disk as a .lyr file
arcpy.SaveToLayerFile_management(parcels_layer, "F:/Documents/Project Docs/GIS/ParcelLayer.lyr")

# Read existing mxd file (template)
mxd = arcpy.mapping.MapDocument("F:/Documents/Project Docs/GIS/MAP_TEMPLATE.mxd")

# Get access to template's only data frame
df = arcpy.mapping.ListDataFrames(mxd)[0]

# Read feature layers from disk
parcellayer = arcpy.mapping.Layer(r"F:/Documents/Project Docs/GIS/ParcelLayer.lyr")

# Add my feature layers to existing template
arcpy.mapping.AddLayer(df, parcellayer, "BOTTOM")

# apply known layer attributes to new layer (APN Markers and 1PT parcel border)
# ExportStyleLayer.lyr created from ArcMap existing map using "Save as Layer File..." - hoping to get font styles from here
updateLayer = arcpy.mapping.ListLayers(mxd, parcellayer.name, df)[0]
sourceLayer = arcpy.mapping.Layer(r"F:/Documents/Project Docs/GIS/ExportStyleLayer.lyr") # a layer that represents look/labels etc that we want. 
arcpy.mapping.UpdateLayer(df, updateLayer, sourceLayer, False) # OnlySymbology=False (want all attributes of the known layer)

# change datasource?
#updateLayer.replaceDataSource(?, ?, ?)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:12:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/format-fonts-size-style-using-existing-layer/m-p/180215#M13840</guid>
      <dc:creator>RobinLuther</dc:creator>
      <dc:date>2021-12-11T09:12:54Z</dc:date>
    </item>
    <item>
      <title>Re: Format fonts, size, style using existing layer formatting</title>
      <link>https://community.esri.com/t5/python-questions/format-fonts-size-style-using-existing-layer/m-p/180216#M13841</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Bumping this up. Looking for answer for the same question above. Same environment - 10.0, won't be upgrading to 10.1 soon. Want to apply label styles just like applying symbology. How do I go about it?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;TIA&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-Deepti&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Oct 2012 22:15:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/format-fonts-size-style-using-existing-layer/m-p/180216#M13841</guid>
      <dc:creator>DeeptiVB</dc:creator>
      <dc:date>2012-10-26T22:15:34Z</dc:date>
    </item>
  </channel>
</rss>

