Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I ended up having my plotting program <strong>create a very basic Autocad script</strong>. I referred to <a href="https://stackoverflow.com/questions/5666056/matplotlib-extracting-data-from-contour-lines">this question</a> about extracting x,y data from a contour plot to write the Autocad script. Here is the relevant function:</p> <pre><code>def make_autocad_script(outfile_name, contour): ''' Creates an Autocad script which contains polylines for each contour. Args outfile_name: the name of the Autocad script file. contour: the contour plot that needs to be exported to Autocad. ''' with open(outfile_name, 'w', newline='') as outfile: writer = csv.writer(outfile, delimiter=',', ) # each collection is associated with a contour level for collection in contour.collections: # If the contour level is never reached, then the collection will be an empty list. if collection: # Set color for contour level outfile.write('COLOR {}\n'.format(random.randint(1,100))) # Each continuous contour line in a collection is a path. for path in collection.get_paths(): vertices = path.vertices # pline is an autocad command for polyline. It interprets # the next (x,y) pairs as coordinates of a line until # it sees a blank line. outfile.write('pline\n') writer.writerows(vertices) outfile.write('\n') </code></pre> <p>I send <code>make_autocad_script</code> the <code>outfile</code> and <code>contour</code> plot that I need, and in Autocad I import the script. This plots each contour as a random color, but that could be replaced with whatever color you wanted.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload