module Microstation
/ // MessageId: DISP_E_PARAMNOTFOUND // // MessageText: // // Parameter not found. // ##define DISP_E_PARAMNOTFOUND HRESULT_TYPEDEF(0x80020004L)
require_relative 'ts/tagset_trait' require_relative 'graphics' require_relative 'ts/instance'
Constants
- Error
- FileNotFound
- MultipleUpdateError
- NonDGNFile
- Ole_Types
- ROOT
- TEMPLATES_PATH
- VERSION
Public Class Methods
change_drawing(...)
click to toggle source
starts an app with drawing, opens a temp copy of the drawing and yields it saves the drawing with with name or output_dir same name
@param dgn @yield [Drawing]
# File lib/microstation.rb, line 95 def change_drawing(...) App.change_drawing(...) end
default_app_options()
click to toggle source
# File lib/microstation.rb, line 52 def default_app_options @default_app_options end
default_app_options=(opts)
click to toggle source
# File lib/microstation.rb, line 56 def default_app_options=(opts) @default_app_options = opts end
default_drawing_options()
click to toggle source
# File lib/microstation.rb, line 44 def default_drawing_options {read_only: true, error_proc: default_error_proc} end
default_error_proc()
click to toggle source
# File lib/microstation.rb, line 40 def default_error_proc @default_error_proc ||= ->(e,f){ puts "Couldn't open drawing #{f}" } end
default_error_proc=(p)
click to toggle source
# File lib/microstation.rb, line 48 def default_error_proc=(p) @default_error_proc = p end
dgn2pdf(dir,outdir = dir)
click to toggle source
@param dir [String] the directory of drawing [dgn,dwg] to convert @param outdir [String] the output dir for converted pdf files
# File lib/microstation.rb, line 124 def dgn2pdf(dir,outdir = dir) drawings = drawings_in_dir(dir) with_drawings(drawings) do |drawing| drawing.save_as_pdf(name: drawing.name,dir: outdir) end end
directory(path)
click to toggle source
# File lib/microstation/directory.rb, line 3 def self.directory(path) Directory.new(path) end
drawings_in_dir(dir)
click to toggle source
gets all dwg and dgn dfiles in a directory @param dir
# File lib/microstation.rb, line 101 def drawings_in_dir(dir) dirpath = Pathname.new(dir).expand_path drawings = Pathname.glob("#{dirpath}/*.d{gn,wg,xf}") end
dump_template_info(dgn, dir: nil, tagset_filter: nil, visible: false)
click to toggle source
# File lib/microstation.rb, line 115 def dump_template_info(dgn, dir: nil, tagset_filter: nil, visible: false) drawing = Pathname(dgn).expand_path output_dir = dir || drawing.parent template = TemplateInfo.new(drawing,tagset_filter: tagset_filter, visible: visible) template.dump(output_dir) end
dump_template_info_for_dir(dir, options={})
click to toggle source
# File lib/microstation.rb, line 106 def dump_template_info_for_dir(dir, options={}) drawings = drawings_in_dir(dir) raise "no drawings in dir #{dir}" if drawings.empty? with_drawings(drawings) do |drawing| template = TemplateInfo.new(drawing,options) template.dump(dir) end end
get_all_text(file)
click to toggle source
# File lib/microstation.rb, line 166 def get_all_text(file) App.open_drawing(file) do |d| d.get_all_text end end
get_text(file, &block)
click to toggle source
# File lib/microstation.rb, line 160 def get_text(file, &block) App.open_drawing(file) do |d| d.get_text(&block) end end
needs_extending?(ole)
click to toggle source
# File lib/microstation/wrap.rb, line 3 def self.needs_extending?(ole) ole.class == WIN32OLE && (not ole.respond_to? :text?) end
open_drawing(...)
click to toggle source
starts app, opens drawing, and yields the drawing before closing drawing and quitting the app
# File lib/microstation.rb, line 138 def open_drawing(...) App.open_drawing(...) end
plot_driver_directory()
click to toggle source
# File lib/microstation.rb, line 66 def plot_driver_directory root + "plot" end
root()
click to toggle source
# File lib/microstation.rb, line 62 def root ROOT end
run(...)
click to toggle source
# File lib/microstation.rb, line 197 def run(...) App.run(...) end
run_templates_in_dir(...)
click to toggle source
# File lib/microstation.rb, line 131 def run_templates_in_dir(...) App.run_templates_in_dir(...) end
save_as_pdf(d)
click to toggle source
# File lib/microstation.rb, line 32 def save_as_pdf(d) run do |app| drawing = app.current_drawing drawing.save_as_pdf(dir: d) drawing.close end end
save_current_drawing(dir, exit: true)
click to toggle source
# File lib/microstation.rb, line 172 def save_current_drawing(dir, exit: true) if exit run do |app| drawing = app.current_drawing drawing.copy(dir: dir) drawing.save_as_pdf(dir: dir) drawing.close end else app = App.new drawing = app.current_drawing drawing.copy(dir: dir) drawing.save_as_pdf(dir: dir) app end end
save_current_drawing_as_pdf(dir)
click to toggle source
# File lib/microstation.rb, line 189 def save_current_drawing_as_pdf(dir) App.run do |app| drawing = app.current_drawing drawing.save_as_pdf(dir: dir) drawing.close end end
scan_text(file,&block)
click to toggle source
# File lib/microstation.rb, line 154 def scan_text(file,&block) App.open_drawing(file) do |d| d.scan_text(&block) end end
use_template(template,context, options ={} )
click to toggle source
# File lib/microstation.rb, line 70 def use_template(template,context, options ={} ) def context.binding binding end options = {readonly: true} App.run do |app| tmpfile = Tempfile.new('drawing') app.new_drawing(tmpfile,template) do |drawing| drawing.scan_text do |text| compiled_template = ERB.new(text) new_text = compiled_template.result(context.binding) text = new_text end end end tempfile.read end
win_fs()
click to toggle source
# File lib/microstation/app.rb, line 37 def self.win_fs @windows_fs ||= Windows::FileSystem.new end
with_drawings(...)
click to toggle source
# File lib/microstation.rb, line 150 def with_drawings(...) App.with_drawings(...) end
with_drawings_in_dir(dir,...)
click to toggle source
opens all the drawings in a drawing by calling open drawing
# File lib/microstation.rb, line 144 def with_drawings_in_dir(dir,...) drawings = drawings_in_dir(dir) with_drawings(drawings,...) end