[ArcGIS Pro] How to export to DWG with python?

951
4
10-29-2018 04:16 PM
Jean-SimonLevert
New Contributor II

Hi everyone and thx alot for your time!

Im tring to export to DWG, from a country map, a small square zone with 2 xy corners.

import arcpy

in_features = "%MyFeatures%"

output_type = "DWG_R2004"

output_file = "c:/data/world.dwg"

arcpy.ExportCAD_conversion(in_features, output_type, output_file, "USE_FILENAMES_IN_TABLES""OVERWRITE_EXISTING_FILES")

Whis this code, im able to export to DWG with no problem but it export the complete country map zone.

How can I export only a small square zone in a 2 xy area?

I tried adding:

arcpy.env.extent = arcpy.Extent(-73.536116, 45.967176 , -73.360613, 45.871700)

but everytime the .dwg is empty.

Can anyone tells me what I did wrong or what I can do to be able to export only a small zone from the country feature.

Thx alot

0 Kudos
4 Replies
DanPatterson_Retired
MVP Emeritus

Have you tried clipping before exporting?

0 Kudos
Jean-SimonLevert
New Contributor II

Is it possible to clip with one xy? 

0 Kudos
DanPatterson_Retired
MVP Emeritus

You indicated a square-ish zone which you can construct from 2 xy corners

L(eft), B(ottom)  = min(x0, x1), min(y0, y1)

R(ight), T(op)     = max(x0, x1), max(y0, y1)

point 1 = (x0, y0)

point 2 = (x1, y1)

You can construct the rectangle from the L, B, R, T pairs as needed 

Jean-SimonLevert
New Contributor II

I am totaly lost, im reading and reading but still lost... can you give a exemple of code?

Thx you so much!

0 Kudos