Raise error if layer is empty

master
Dan Howe 7 years ago
parent 7b4fb8f7fa
commit b5a314588c

@ -24,10 +24,6 @@ Convert specific layer:
""" """
__author__ = "D. Howe"
__version__ = "0.2.0"
__email__ = "d.howe@wrl.unsw.edu.au"
import os import os
import sys import sys
import numpy as np import numpy as np
@ -96,6 +92,13 @@ def convert(dxf_name, layer_name):
# Add to dataframe # Add to dataframe
points = pd.DataFrame(data) points = pd.DataFrame(data)
# Ensure dataframe is not empty
if points.shape[0] == 0:
if layer_name:
raise ValueError('No objects found on layer {}'.format(layer_name))
else:
raise ValueError('No objects found.')
# Check if there are z coordinates # Check if there are z coordinates
if 'z' not in points.columns: if 'z' not in points.columns:
points['z'] = np.nan points['z'] = np.nan

Loading…
Cancel
Save