Module: Faa::Cleanup
- Included in:
- Autocad::Drawing
- Defined in:
- lib/faa/cleanup.rb
Instance Method Summary collapse
-
#add_title_block(scale: 1.0) ⇒ Object
Adds the FAA border to layout.
-
#cleanup_model ⇒ Object
Clean up the model space by removing translation text and title blocks.
-
#cleanup_title_block ⇒ Object
After deleting title block in model space, asks you to select a region to cleanup the rest of title block (attributes).
-
#faa_title_block ⇒ Object
Get the FAA title block if it exists.
-
#fix_layout ⇒ Object
Fix the layout by setting up proper viewports and plot configuration.
-
#get_title_attributes ⇒ Object
Get attributes from the title block.
-
#remove_translation_text ⇒ Object
Remove any text containing “TRANSLATION”.
Instance Method Details
#add_title_block(scale: 1.0) ⇒ Object
Adds the FAA border to layout
63 64 65 66 67 68 69 70 |
# File 'lib/faa/cleanup.rb', line 63 def add_title_block(scale: 1.0) path = app.support_path_files.find { |f| f.basename.to_s == 'faaDborder.dwg' } return unless path block = layout.add_block_reference(path, pt: [0, 0, 0], scale: scale) regen block end |
#cleanup_model ⇒ Object
Clean up the model space by removing translation text and title blocks
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/faa/cleanup.rb', line 41 def cleanup_model to_model_space remove_translation_text title_block = model_block_references.find { it.name == "TITLEB" } border = model_block_references.find { it.name == "border" } border&.delete title_objs = title_block.explode if title_block if title_objs title_objs.each do |o| o.delete rescue nil end end title_block.delete if title_block regen app.zoom_extents end |
#cleanup_title_block ⇒ Object
After deleting title block in model space, asks you to select a region to cleanup the rest of title block (attributes)
75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/faa/cleanup.rb', line 75 def cleanup_title_block to_model_space prompt("Select the region of title block to delete") get_region ss = create_selection_set("_atts_") ss.select_on_screen ss.each { |o| o.delete(false) } ss.delete regen app.zoom_extents rescue nil end |
#faa_title_block ⇒ Object
Get the FAA title block if it exists
119 120 121 |
# File 'lib/faa/cleanup.rb', line 119 def faa_title_block block_references.find { |b| b.name == "faatitle" } end |
#fix_layout ⇒ Object
Fix the layout by setting up proper viewports and plot configuration
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/faa/cleanup.rb', line 91 def fix_layout ps = paper_space ps. layout = paper_space_layout active_layout = layout layout.copy_plot_configuration pdf_plot_config block = add_title_block(scale: 1.0, layout: layout) if block # to do add it to layer puts "added title block" end # Use layout.add_pviewport which calculates size based on paper size and margins pv = layout.(:scale_to_fit) unless pv active_layout = layout end app.zoom_extents regen layout.update(plot_type: :layout) end |
#get_title_attributes ⇒ Object
Get attributes from the title block
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/faa/cleanup.rb', line 28 def get_title_attributes block_refs = block_reference_selection_set title_block = block_refs.find do |br| br.name.casecmp?("faatitle") end return unless title_block title_block.attributes_hash end |
#remove_translation_text ⇒ Object
Remove any text containing “TRANSLATION”
125 126 127 128 129 |
# File 'lib/faa/cleanup.rb', line 125 def remove_translation_text objs = select_text_containing("*TRANSLATION*") objs.each { |o| o.delete } app.zoom_extents end |