Hello,
I am having a problem for days and I just can't figure it out. I have this code:
the first text ("CENÁRIO") is working just fine when it change the text element on my mxd. However, the situation below is not working. If I put only the string "Condição" the ç and the ã goes just fine, but when I add it with the variable "cond" it goes nuts and puts strange simbols instead (see picture below).
Attachment 23773
As you can see, the "CENÁRIO" WORKED just fine...
I looked some topics here on the forum and tryied everything. In the begining of my code I have the
I also have tryed put an "u" before the text like:
Can some tell me what is happening?
The full script I take the cond information from a txt file. The full code is:
Thank you
I am having a problem for days and I just can't figure it out. I have this code:
Code:
cenario = "1"
num = MP.ListLayoutElements(mxd, "TEXT_ELEMENT")[6]
num.text = "CENÁRIO " + cenario
cond = "Sizigia"
textoGeral = MP.ListLayoutElements(mxd, "TEXT_ELEMENT")[9]
textoGeral.text = "Condição" + cond
Attachment 23773
As you can see, the "CENÁRIO" WORKED just fine...
I looked some topics here on the forum and tryied everything. In the begining of my code I have the
Code:
#!/usr/bin/python
# coding: utf-8
Code:
textoGeral.text = u"Condição" + cond
The full script I take the cond information from a txt file. The full code is:
Code:
#!/usr/bin/python
# coding: utf-8
import arcpy
import arcpy.mapping as MP
from datetime import datetime
startTime = datetime.now()
mxd = MP.MapDocument(r"p:\5270069_vli_tuf_dragagem_feL3\navigation\results\GIS_geral\Cenario_Basico_Santos_piacaguera_3.mxd")
DF1 = MP.ListDataFrames(mxd)[0]
Zoom1 = MP.ListDataFrames(mxd)[1]
Zoom2 = MP.ListDataFrames(mxd)[2]
projeto = raw_input("Digite o caminho com a pasta do projeto contendo os txts: ")
caminho_navios = projeto + "navios.txt"
f = open(caminho_navios,"r")
data = f.readlines()
numcenarios = len(data)
#Lendo o txt e separando as info
for i in range(0,numcenarios):
vez = data[i].split('\t')
cenario = vez[0]
navio = vez[1]
tipo = vez[2]
rebocador = vez[3]
condicao = vez[4]
vento = vez [5]
trackplot = vez[6]
#Changing layout elements...
numero_projeto = MP.ListLayoutElements(mxd, "TEXT_ELEMENT")[4]
numero_projeto.text = numProjeto
num = MP.ListLayoutElements(mxd, "TEXT_ELEMENT")[6]
num.text = "CENÁRIO " + cenario
titulo_final = MP.ListLayoutElements(mxd, "TEXT_ELEMENT")[7]
titulo_final.text = titulo
textoGeral = MP.ListLayoutElements(mxd, "TEXT_ELEMENT")[9]
textoGeral.text = "Condição" + condicao
# textoGeral = MP.ListLayoutElements(mxd, "TEXT_ELEMENT")[9]
# textoGeral.text = "Condição: " + condicao
#Exportando pra PDF
print "Exportando mapa do cenario " + cenario
MP.ExportToPNG(mxd, projeto + "TUF_Cenario_" + cenario + ".png")
print "PNG Exportado"
MP.ExportToPDF(mxd, projeto + "TUF_Cenario_" + cenario + ".pdf")
print "PDF Exportado"
#Salvando copia do MXD
mxd.saveACopy(projeto + "TUF_Cenario" + cenario + ".mxd")
print "Cenario " + cenario + " Finalizado"
print "Esta rotina demorou " + str(datetime.now()-startTime) + " horas"