Thank you, Jim. Yes, I had previously tried various limits, e.g. 100, 3,000, and they worked fine. So, I then used the importer without restrictions and ran into this problem. I let the import run overnight an it remained hung.
I think my output statement in the loop after every 500 objects would be a way of showing life, unless the Ruby Console is also frozen. Here’s a snipped showing my “puts” statement:
# CREATE POLYGONS -----------------------------------------------------------------------
def spirix_shapefile_import_create_polygons()
if(@@display_bb == 'Yes')
group = @@model.entities.add_group
group.entities.add_edges(Geom::Point3d.new(0,0,0),Geom::Point3d.new((@@bbox[2] - @@bbox[0]) * scale_x(@@bbox[1]),0,0),Geom::Point3d.new((@@bbox[2] - @@bbox[0]) * scale_x(@@bbox[1]),(@@bbox[3] - @@bbox[1]) * scale_y(@@bbox[3]),0),Geom::Point3d.new(0,(@@bbox[3] - @@bbox[1]) * scale_y(@@bbox[3]),0),Geom::Point3d.new(0,0,0))
end
for i in 0...@@imax
# keep track of large loads
if (i % 500 == 0)
puts "At " + @@timestamp.to_s + " " + i.to_s
end
if(@@use_data == 1)
@@height = @@data[@@hdr_length + i * @@rec_length + @@offset,@@data_len].to_f * @@scale
end
Side question: when SketchUp hangs, is the Ruby Console hung as well?
Another commentator wondered about the file read. It looks like the entire file is read in one operation around lines 346+:
# GET SHAPEFILE DATA --------------------------------------------------------------------
def spirix_shapefile_import_get_data()
file = @@basename + '.shx'
input = File.open(file,'rb')
@@index = input.read(File.size?(file))
input.close
@@type = @@index[32,4].unpack('L').first
if(@@index[0,4].unpack('N').first != 9994)
puts "*.shx is not a valid shapefile! Header record has " + @@index[0,4].unpack('N').first.to_s + "."
exit
elsif(@@type != 5 && @@type != 15 && @@type != 3)
puts "*.shx does not contain polygons or polylines! Header record has " + @@type.to_s + "."
exit
end
file = @@basename + '.shp'
input = File.open(file,'rb')
@@geom = input.read(File.size?(file))
input.close
It looks like all the contents of the shapefile are read into the variable geom and this occurs before the processing loop where I inserted the “puts” debugging line.