POST
|
how can add or remove tool in the context menu like duplicate vertical or replace multipatch i am using ArcGIS pro 2.9
... View more
06-28-2022
08:37 AM
|
0
|
0
|
164
|
POST
|
i need help model builder to duplicate feature parallel with specified distance i have a script in arcpy but i can not run coz i did not understand the code : import arcpy, math
infc=r'..\SCRARCH\clone.shp'
def CopyParallel(plyP,sLength):
part=plyP.getPart(0)
lArray=arcpy.Array();rArray=arcpy.Array()
for ptX in part:
dL=plyP.measureOnLine(ptX)
ptX0=plyP.positionAlongLine (dL-0.01).firstPoint
ptX1=plyP.positionAlongLine (dL+0.01).firstPoint
dX=float(ptX1.X)-float(ptX0.X)
dY=float(ptX1.Y)-float(ptX0.Y)
lenV=math.hypot(dX,dY)
sX=-dY*sLength/lenV;sY=dX*sLength/lenV
leftP=arcpy.Point(ptX.X+sX,ptX.Y+sY)
lArray.add(leftP)
rightP=arcpy.Point(ptX.X-sX, ptX.Y-sY)
rArray.add(rightP)
array = arcpy.Array([lArray, rArray])
section=arcpy.Polyline(array)
return section
with arcpy.da.UpdateCursor(infc,("Shape@","Width")) as cursor:
for shp,w in cursor:
twoLines=CopyParallel(shp,w)
cursor.updateRow((twoLines,w))
... View more
05-29-2022
05:33 AM
|
0
|
0
|
449
|
POST
|
using arcgis for autocad 2019 version 400.2 iam using arcgis online and autocad, sometime error suddenly happened after i finished my work while i clicked sync i don't what is wrong i do when the error occurred
... View more
02-26-2022
08:10 AM
|
0
|
1
|
347
|
POST
|
after i put the bracket it showed me this message error AttributeError: 'list' object has no attribute 'listElements' import arcpy, os
arcpy.env.overwriteOutput = True
aprx = arcpy.mp.ArcGISProject("CURRENT")
df = aprx.listMaps()[0]
layerName = arcpy.GetParameterAsText(0)
fieldName = arcpy.GetParameterAsText(1)
imgLocation = arcpy.GetParameterAsText(2)
whereList = []
layerFile = df.listLayers(layerName)[0]
layerFile.definitionQuery = ""
print ((df.name))
with arcpy.da.SearchCursor(layerName, fieldName) as cursor:
for row in cursor:
for item in row:
whereList.append(item)
for wl in whereList:
layerFile.definitionQuery = fieldName + "= '" + wl + "'"
#new_extent = layerFile.getExtent()
lay = aprx.listLayouts("Layout 1")
mf = lay.listElements("Layers Map Frame","New Data Frame Map Frame")
new_extent = mf.camera.setExtent(mf.getLayerExtent(layerFile, False, True))
#df.extent = new_extent
#df.scale *= 1.5
for lyt in aprx.listLayouts("Layout 1"):
for elm in lyt.listElements("TEXT_ELEMENT"):
if elm.name == "Text":
elm.text = wl
name = ''
for char in wl:
if char.isalpha():
name+=char
outFile = imgLocation + "\\" + name + ".pdf"
arcpy.mp.ExportToPDF(aprx, outFile, "PAGE_LAYOUT")
del aprx the two data frame called as you see in the screen shot blow :
... View more
09-19-2021
12:56 AM
|
0
|
0
|
1412
|
POST
|
syntax error in line 31: import arcpy, os
arcpy.env.overwriteOutput = True
aprx = arcpy.mp.ArcGISProject("CURRENT")
df = aprx.listMaps()[0]
layerName = arcpy.GetParameterAsText(0)
fieldName = arcpy.GetParameterAsText(1)
imgLocation = arcpy.GetParameterAsText(2)
whereList = []
layerFile = df.listLayers(layerName)[0]
layerFile.definitionQuery = ""
print ((df.name))
with arcpy.da.SearchCursor(layerName, fieldName) as cursor:
for row in cursor:
for item in row:
whereList.append(item)
for wl in whereList:
layerFile.definitionQuery = fieldName + "= '" + wl + "'"
#new_extent = layerFile.getExtent()
lay = aprx.listLayouts("Layout")
mf = lay.listElements("Layers Map Frame","New Data Frame Map Frame")
new_extent = mf.camera.setExtent(mf.getLayerExtent(layerFile, False, True)
#df.extent = new_extent
#df.scale *= 1.5
for lyt in aprx.listLayouts("Layout"):
for elm in lyt.listElements("TEXT_ELEMENT"):
if elm.name == "Text":
elm.text = wl
... View more
09-18-2021
04:57 PM
|
0
|
0
|
1457
|
POST
|
error in arcgis pro invalid syntax line 31 import arcpy, os
arcpy.env.overwriteOutput = True
aprx = arcpy.mp.ArcGISProject("CURRENT")
df = aprx.listMaps()[0]
layerName = arcpy.GetParameterAsText(0)
fieldName = arcpy.GetParameterAsText(1)
imgLocation = arcpy.GetParameterAsText(2)
whereList = []
layerFile = df.listLayers(layerName)[0]
layerFile.definitionQuery = ""
print ((df.name))
with arcpy.da.SearchCursor(layerName, fieldName) as cursor:
for row in cursor:
for item in row:
whereList.append(item)
for wl in whereList:
layerFile.definitionQuery = fieldName + "= '" + wl + "'"
#new_extent = layerFile.getExtent()
lay = aprx.listLayouts("Layout")
mf = lay.listElements("Layers Map Frame","New Data Frame Map Frame")
new_extent = mf.camera.setExtent(mf.getLayerExtent(layerFile, False, True)
#df.extent = new_extent
#df.scale *= 1.5
for lyt in aprx.listLayouts("Layout"):
for elm in lyt.listElements("TEXT_ELEMENT"):
if elm.name == "Text":
elm.text = wl
... View more
09-18-2021
04:48 PM
|
0
|
0
|
532
|
POST
|
i don't know what is the erorr exactly line 31 for lyt in aprx.listLayouts("Layout"): SyntaxError: invalid syntax import arcpy, os
arcpy.env.overwriteOutput = True
aprx = arcpy.mp.ArcGISProject("CURRENT")
df = aprx.listMaps()[0]
layerName = arcpy.GetParameterAsText(0)
fieldName = arcpy.GetParameterAsText(1)
imgLocation = arcpy.GetParameterAsText(2)
whereList = []
layerFile = df.listLayers(layerName)[0]
layerFile.definitionQuery = ""
print ((df.name))
with arcpy.da.SearchCursor(layerName, fieldName) as cursor:
for row in cursor:
for item in row:
whereList.append(item)
for wl in whereList:
layerFile.definitionQuery = fieldName + "= '" + wl + "'"
#new_extent = layerFile.getExtent()
lay = aprx.listLayouts("Layout")
mf = lay.listElements("Layers Map Frame","New Data Frame Map Frame")
new_extent = mf.camera.setExtent(mf.getLayerExtent(layerFile, False, True)
#df.extent = new_extent
#df.scale *= 1.5
for lyt in aprx.listLayouts("Layout"):
for elm in lyt.listElements("TEXT_ELEMENT"):
if elm.name == "Text":
elm.text = wl
... View more
09-18-2021
04:45 PM
|
0
|
0
|
1440
|
POST
|
how can i set camera object extent instead of get extent import arcpy, os
arcpy.env.overwriteOutput = True
aprx = arcpy.mp.ArcGISProject("CURRENT")
df = aprx.listMaps()[0]
layerName = arcpy.GetParameterAsText(0)
fieldName = arcpy.GetParameterAsText(1)
imgLocation = arcpy.GetParameterAsText(2)
whereList = []
layerFile = df.listLayers(layerName)[0]
layerFile.definitionQuery = ""
print ((df.name))
with arcpy.da.SearchCursor(layerName, fieldName) as cursor:
for row in cursor:
for item in row:
whereList.append(item)
for wl in whereList:
layerFile.definitionQuery = fieldName + "= '" + wl + "'"
#new_extent = layerFile.getExtent()
new_extent = df.camera.setExtent(df.getLayerExtent(layerFile, False, True))
df.extent = new_extent
df.scale *= 1.5
for elm in arcpy.mp.ListLayoutElements(mxd, "TEXT_ELEMENT", "title"):
if elm.name == "title":
elm.text = wl
name = ''
for char in wl:
if char.isalpha():
name+=char
outFile = imgLocation + "\\" + name + ".pdf"
arcpy.mp.ExportToPDF(mxd, outFile, "PAGE_LAYOUT")
del aprx
... View more
09-18-2021
08:46 AM
|
0
|
0
|
533
|
POST
|
import arcpy, os
arcpy.env.overwriteOutput = True
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd)[0]
layerName = arcpy.GetParameterAsText(0)
fieldName = arcpy.GetParameterAsText(1)
imgLocation = arcpy.GetParameterAsText(2)
whereList = []
layerFile = arcpy.mapping.Layer(layerName)
layerFile.definitionQuery = ""
print df.name
with arcpy.da.SearchCursor(layerName, fieldName) as cursor:
for row in cursor:
for item in row:
whereList.append(item)
for wl in whereList:
arcpy.RefreshActiveView()
mxd.save()
layerFile.definitionQuery = fieldName + "= '" + wl + "'"
new_extent = layerFile.getExtent()
df.extent = new_extent
df.scale *= 1.5
for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "title"):
if elm.name == "title":
elm.text = wl
arcpy.RefreshActiveView()
outFile = os.path.join(imgLocation, wl + ".pdf")
arcpy.AddMessage(outFile)
outFile = imgLocation + "\\" + wl + ".pdf"
arcpy.mapping.ExportToPDF(mxd, outFile, "PAGE_LAYOUT")
del mxd
... View more
09-18-2021
06:35 AM
|
0
|
7
|
1484
|
POST
|
i have the same issues and want to convert the script from arcmap to arcgis pro import arcpy, os
arcpy.env.overwriteOutput = True
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd)[0]
layerName = arcpy.GetParameterAsText(0)
fieldName = arcpy.GetParameterAsText(1)
imgLocation = arcpy.GetParameterAsText(2)
whereList = []
layerFile = arcpy.mapping.Layer(layerName)
layerFile.definitionQuery = ""
print df.name
with arcpy.da.SearchCursor(layerName, fieldName) as cursor:
for row in cursor:
for item in row:
whereList.append(item)
for wl in whereList:
arcpy.RefreshActiveView()
mxd.save()
layerFile.definitionQuery = fieldName + "= '" + wl + "'"
new_extent = layerFile.getExtent()
df.extent = new_extent
df.scale *= 1.5
for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "title"):
if elm.name == "title":
elm.text = wl
arcpy.RefreshActiveView()
outFile = os.path.join(imgLocation, wl + ".pdf")
arcpy.AddMessage(outFile)
outFile = imgLocation + "\\" + wl + ".pdf"
arcpy.mapping.ExportToPDF(mxd, outFile, "PAGE_LAYOUT")
del mxd
... View more
09-18-2021
03:25 AM
|
0
|
0
|
725
|
POST
|
it worked, thanks so much i made a post as you said to make anyone help me to convert the script to arcgis pro becouse of dynamic table in the linke blow: https://community.esri.com/t5/python-questions/convert-script-python-work-with-quot-export-layout/m-p/1099539#M62477
... View more
09-17-2021
02:36 PM
|
0
|
0
|
537
|
POST
|
this my script python doing loop defination query and export layout pdf file the purpose from converting is using dynamic table which in arcgis pro beacouse in arcmap required extension so i want to covert to run this model in arcgis pro my code : import arcpy, os
arcpy.env.overwriteOutput = True
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd)[0]
layerName = arcpy.GetParameterAsText(0)
fieldName = arcpy.GetParameterAsText(1)
imgLocation = arcpy.GetParameterAsText(2)
whereList = []
layerFile = arcpy.mapping.Layer(layerName)
layerFile.definitionQuery = ""
print df.name
with arcpy.da.SearchCursor(layerName, fieldName) as cursor:
for row in cursor:
for item in row:
whereList.append(item)
for wl in whereList:
arcpy.RefreshActiveView()
mxd.save()
layerFile.definitionQuery = fieldName + "= '" + wl + "'"
new_extent = layerFile.getExtent()
df.extent = new_extent
df.scale *= 1.5
for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "title"):
if elm.name == "title":
elm.text = wl
arcpy.RefreshActiveView()
outFile = os.path.join(imgLocation, wl + ".pdf")
arcpy.AddMessage(outFile)
outFile = imgLocation + "\\" + wl + ".pdf"
arcpy.mapping.ExportToPDF(mxd, outFile, "PAGE_LAYOUT")
del mxd
... View more
09-17-2021
01:18 PM
|
0
|
0
|
410
|
POST
|
firstly i would like to thank a lot for your effort i made in mxd save and overwrite beacouse the code write from the field have char like )(.\ and the code run out while was running so saving mxd to know the last extent while the cod was run what iam thinking now to put the function .strip() int outfile name to clear char like this ()\|?
... View more
09-17-2021
01:06 PM
|
0
|
2
|
803
|
POST
|
i made test and change the lebel to "title" as you see in the screen shot but the pdf exportefd without chang e the dynamic lebel can you retest the code and see it again my final look code is this import arcpy, os
arcpy.env.overwriteOutput = True
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd)[0]
layerName = arcpy.GetParameterAsText(0)
fieldName = arcpy.GetParameterAsText(1)
imgLocation = arcpy.GetParameterAsText(2)
whereList = []
layerFile = arcpy.mapping.Layer(layerName)
layerFile.definitionQuery = ""
print df.name
with arcpy.da.SearchCursor(layerName, fieldName) as cursor:
for row in cursor:
for item in row:
whereList.append(item)
for wl in whereList:
arcpy.RefreshActiveView()
mxd.save()
layerFile.definitionQuery = fieldName + "= '" + wl + "'"
new_extent = layerFile.getExtent()
df.extent = new_extent
df.scale *= 1.5
for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"):
if elm.text == "title":
elm.text = wl
arcpy.RefreshActiveView()
outFile = os.path.join(imgLocation, wl + ".pdf")
arcpy.AddMessage(outFile)
outFile = imgLocation + "\\" + wl + ".pdf"
arcpy.mapping.ExportToPDF(mxd, outFile, "PAGE_LAYOUT")
del mxd
... View more
09-17-2021
11:24 AM
|
0
|
0
|
814
|
Title | Kudos | Posted |
---|---|---|
1 | 01-07-2021 02:27 PM | |
1 | 01-07-2021 02:54 PM |
Online Status |
Offline
|
Date Last Visited |
08-07-2022
07:00 AM
|