autocad 0.4.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +7 -0
  2. data/.rubocop/minitest.yml +2 -0
  3. data/.rubocop/strict.yml +4 -0
  4. data/.rubocop.yml +33 -0
  5. data/.solargraph.yml +22 -0
  6. data/.vscode/launch.json +30 -0
  7. data/CHANGELOG.md +5 -0
  8. data/CODE_OF_CONDUCT.md +132 -0
  9. data/Guardfile +66 -0
  10. data/LICENSE.txt +21 -0
  11. data/README.md +39 -0
  12. data/Rakefile +10 -0
  13. data/Steepfile +35 -0
  14. data/WASD-D-TDS-C001.dwg +0 -0
  15. data/WASD-D-TDS-C001.pdf +0 -0
  16. data/autocad.log +1 -0
  17. data/autocad_example.rb +26 -0
  18. data/event_handler.log +24 -0
  19. data/examples/example_save_pdf.rb +5 -0
  20. data/exe/autocad +3 -0
  21. data/exe/dgn2pdf +50 -0
  22. data/exe/pw_print +43 -0
  23. data/gemfiles/rubocop.gemfile +6 -0
  24. data/lib/autocad/app.rb +655 -0
  25. data/lib/autocad/arc.rb +29 -0
  26. data/lib/autocad/block.rb +141 -0
  27. data/lib/autocad/block_reference.rb +198 -0
  28. data/lib/autocad/drawing.rb +426 -0
  29. data/lib/autocad/element.rb +454 -0
  30. data/lib/autocad/enumerator.rb +24 -0
  31. data/lib/autocad/errors.rb +37 -0
  32. data/lib/autocad/event_handler.rb +30 -0
  33. data/lib/autocad/filter.rb +168 -0
  34. data/lib/autocad/layer.rb +41 -0
  35. data/lib/autocad/line.rb +55 -0
  36. data/lib/autocad/message_box.rb +95 -0
  37. data/lib/autocad/model.rb +89 -0
  38. data/lib/autocad/mtext.rb +110 -0
  39. data/lib/autocad/paths.rb +29 -0
  40. data/lib/autocad/point3d.rb +143 -0
  41. data/lib/autocad/pviewport.rb +21 -0
  42. data/lib/autocad/selection_filter.rb +180 -0
  43. data/lib/autocad/selection_set.rb +61 -0
  44. data/lib/autocad/selection_set_adapter.rb +146 -0
  45. data/lib/autocad/text.rb +74 -0
  46. data/lib/autocad/version.rb +5 -0
  47. data/lib/autocad.rb +161 -0
  48. data/olegen.rb +341 -0
  49. data/rbs_collection.lock.yaml +188 -0
  50. data/rbs_collection.yaml +19 -0
  51. data/scanner.obj +0 -0
  52. data/sig/generated/autocad/app.rbs +251 -0
  53. data/sig/generated/autocad/arc.rbs +17 -0
  54. data/sig/generated/autocad/block.rbs +63 -0
  55. data/sig/generated/autocad/block_reference.rbs +59 -0
  56. data/sig/generated/autocad/drawing.rbs +158 -0
  57. data/sig/generated/autocad/element.rbs +166 -0
  58. data/sig/generated/autocad/enumerator.rbs +15 -0
  59. data/sig/generated/autocad/errors.rbs +23 -0
  60. data/sig/generated/autocad/event_handler.rbs +14 -0
  61. data/sig/generated/autocad/filter.rbs +60 -0
  62. data/sig/generated/autocad/layer.rbs +19 -0
  63. data/sig/generated/autocad/line.rbs +25 -0
  64. data/sig/generated/autocad/message_box.rbs +81 -0
  65. data/sig/generated/autocad/model.rbs +41 -0
  66. data/sig/generated/autocad/paths.rbs +19 -0
  67. data/sig/generated/autocad/point3d.rbs +66 -0
  68. data/sig/generated/autocad/selection_filter.rbs +50 -0
  69. data/sig/generated/autocad/selection_set.rbs +37 -0
  70. data/sig/generated/autocad/selection_set_adapter.rbs +28 -0
  71. data/sig/generated/autocad/text.rbs +19 -0
  72. data/sig/generated/autocad/text_node.rbs +37 -0
  73. data/sig/generated/autocad/version.rbs +5 -0
  74. data/sig/generated/autocad/viewport.rbs +11 -0
  75. data/sig/generated/autocad.rbs +68 -0
  76. data/sig/prototype/lib/autocad/app.rbs +34 -0
  77. data/sig/prototype/lib/autocad/block.rbs +5 -0
  78. data/sig/prototype/lib/autocad/block_reference.rbs +5 -0
  79. data/sig/prototype/lib/autocad/drawing.rbs +13 -0
  80. data/sig/prototype/lib/autocad/element.rbs +9 -0
  81. data/sig/prototype/lib/autocad/enumerator.rbs +5 -0
  82. data/sig/prototype/lib/autocad/event_handler.rbs +7 -0
  83. data/sig/prototype/lib/autocad/model.rbs +5 -0
  84. data/sig/prototype/lib/autocad/paths.rbs +5 -0
  85. data/sig/prototype/lib/autocad.rbs +3 -0
  86. data/temp/autocad.dwg +0 -0
  87. data/temp/autocad.log +1 -0
  88. data/temp/event_handler.log +0 -0
  89. metadata +147 -0
@@ -0,0 +1,141 @@
1
+ # rbs_inline: enabled
2
+
3
+ require_relative "element"
4
+
5
+ module Autocad
6
+ class Block < Element
7
+ def each
8
+ return enum_for(:each) unless block_given?
9
+
10
+ @ole_obj.each do |ole|
11
+ yield app.wrap(ole)
12
+ end
13
+ end
14
+
15
+ def attributes? # : bool
16
+ @ole_obj.HasAttributes
17
+ end
18
+
19
+ def name # : String
20
+ @ole_obj.Name
21
+ end
22
+
23
+ def layout? # : bool
24
+ @ole_obj.IsLayout
25
+ end
26
+
27
+ def xref? # : bool
28
+ @ole_obj.IsXRef
29
+ end
30
+
31
+ def dynamic? # : bool
32
+ @ole_obj.IsDynamicBlock
33
+ end
34
+
35
+ def attribute_hash
36
+ attributes.each.with_object({}) do |a, h|
37
+ h[a.key] = a.value
38
+ end
39
+ end
40
+
41
+ def block_type
42
+ if xref?
43
+ "XRef"
44
+ elsif dynamic?
45
+ "Dynamic"
46
+ elsif layout?
47
+ "Layout"
48
+ end
49
+ end
50
+
51
+ def inspect
52
+ "<Block #{block_type}: '#{name}#' #{autocad_id}>"
53
+ end
54
+
55
+ def attributes
56
+ return [] unless attributes?
57
+
58
+ els = @ole_obj.GetAttributes
59
+ return [] if els.empty?
60
+
61
+ Attributes.new(self, els.map { |e| Attribute.new(e, app) })
62
+ end
63
+ end
64
+
65
+ class Attributes
66
+ include Enumerable
67
+ attr_reader :elements
68
+
69
+ def initialize(blk, elements)
70
+ @block = blk
71
+ @elements = elements
72
+ end
73
+
74
+ def update_element(name, value)
75
+ return unless att = find_attribute(name)
76
+
77
+ att.update(value)
78
+ end
79
+
80
+ def each(&block)
81
+ return to_enum(:each) unless block_given?
82
+
83
+ elements.each(&block)
84
+ end
85
+
86
+ def find_attribute(name)
87
+ elements.find { |a| a.key == name }
88
+ end
89
+
90
+ def [](name)
91
+ el = find_attribute(name)
92
+ el.value if el
93
+ end
94
+
95
+ def []=(name, value)
96
+ update_element(name, value)
97
+ end
98
+
99
+ def keys
100
+ @elements.map { |e| e.key }
101
+ end
102
+
103
+ def values
104
+ @elements.map { |e| e.value }
105
+ end
106
+
107
+ def to_h
108
+ result = {}
109
+ elements.each.with_object(result) do |a, h|
110
+ h[a.key] = a.value
111
+ end
112
+ result
113
+ end
114
+
115
+ def inspect
116
+ "<Attributes count#{elements.size}>"
117
+ end
118
+ end
119
+
120
+ class Attribute < Element
121
+ def write_ole(value)
122
+ @ole_obj.TextString = value
123
+ end
124
+
125
+ def read_ole(value)
126
+ @ole_obj.TextString
127
+ end
128
+
129
+ def key
130
+ @ole_obj.TagString
131
+ end
132
+
133
+ def value
134
+ @ole_obj.TextString
135
+ end
136
+
137
+ def inspect
138
+ "<Attribute #{key}: #{value}>"
139
+ end
140
+ end
141
+ end
@@ -0,0 +1,198 @@
1
+ require_relative 'element'
2
+
3
+ module Autocad
4
+ class BlockReference < Element
5
+ def block_reference?
6
+ true
7
+ end
8
+
9
+ def each
10
+ return enum_for(:each) unless block_given?
11
+
12
+ @ole_obj.each do |ole|
13
+ yield app.wrap(ole)
14
+ end
15
+ end
16
+
17
+ def external?
18
+ false
19
+ end
20
+
21
+ def insertion_point
22
+ Point3d(ole_obj.InsertionPoint)
23
+ rescue StandardError
24
+ Autocad::Error.new("error getting insertion point of block #{name}")
25
+ end
26
+
27
+ def dynamic?
28
+ @ole_obj.IsDynamicBlock
29
+ end
30
+
31
+ def has_attributes?
32
+ @ole_obj.HasAttributes
33
+ end
34
+
35
+ def name
36
+ @ole_obj.Name
37
+ end
38
+
39
+ def x_scale_factor
40
+ @ole_obj.XScaleFactor
41
+ end
42
+
43
+ def x_effective_scale_factor
44
+ @ole_obj.XEffectiveScaleFactor
45
+ end
46
+
47
+ def y_scale_factor
48
+ @ole_obj.YScaleFactor
49
+ end
50
+
51
+ def y_effective_scale_factor
52
+ @ole_obj.YEffectiveScaleFactor
53
+ end
54
+
55
+ def z_scale_factor
56
+ @ole_obj.ZScaleFactor
57
+ end
58
+
59
+ def z_effective_scale_factor
60
+ @ole_obj.ZEffectiveScaleFactor
61
+ end
62
+
63
+ def layout?
64
+ @ole_obj.IsLayout
65
+ end
66
+
67
+ def attribute_hash
68
+ attributes.each.with_object({}) do |a, h|
69
+ h[a.key] = a.value
70
+ end
71
+ end
72
+
73
+ def inspect
74
+ "<BlockReference: #{autocad_id}>"
75
+ end
76
+
77
+ def attributes
78
+ return to_enum(__callee__) unless block_given?
79
+
80
+ els = @ole_obj.GetAttributes
81
+ return [] if els.empty?
82
+
83
+ els.each { |e| yield app.wrap(e) }
84
+ end
85
+ end
86
+
87
+ class ExternalReference < BlockReference
88
+ def external?
89
+ true
90
+ end
91
+
92
+ def ins_units
93
+ @ole_obj.InsUnits
94
+ end
95
+
96
+ def ins_units_factor
97
+ @ole_obj.InsUnitsFactor
98
+ end
99
+
100
+ def inspect
101
+ "<ExternalReference: #{autocad_id}>"
102
+ end
103
+ end
104
+
105
+ class Attributes
106
+ include Enumerable
107
+ attr_reader :elements
108
+
109
+ def initialize(blk, elements)
110
+ @block = blk
111
+ @elements = elements
112
+ end
113
+
114
+ def update_element(name, value)
115
+ return unless att = find_attribute(name)
116
+
117
+ att.update(value)
118
+ end
119
+
120
+ def each(&block)
121
+ return to_enum(:each) unless block_given?
122
+
123
+ elements.each(&block)
124
+ end
125
+
126
+ def find_attribute(name)
127
+ elements.find { |a| a.key == name }
128
+ end
129
+
130
+ def [](name)
131
+ el = find_attribute(name)
132
+ el.value if el
133
+ end
134
+
135
+ def []=(name, value)
136
+ update_element(name, value)
137
+ end
138
+
139
+ def keys
140
+ @elements.map { |e| e.key }
141
+ end
142
+
143
+ def values
144
+ @elements.map { |e| e.value }
145
+ end
146
+
147
+ def to_h
148
+ result = {}
149
+ elements.each.with_object(result) do |a, h|
150
+ h[a.key] = a.value
151
+ end
152
+ result
153
+ end
154
+
155
+ def inspect
156
+ "<Attributes count#{elements.size}>"
157
+ end
158
+ end
159
+
160
+ class AttributeReference < Element
161
+ # @rbs return bool -- is the text multiline
162
+ def mtext?
163
+ ole_obj.MTextAttribute
164
+ end
165
+
166
+ def write_ole(value)
167
+ if mtext?
168
+ @ole_obj.MTextAttributeContent = value
169
+ else
170
+ @ole_obj.TextString = value
171
+ end
172
+ end
173
+
174
+ def read_ole(value)
175
+ if mtext?
176
+ @ole_obj.MTextAttributeContent
177
+ else
178
+ @ole_obj.TextString
179
+ end
180
+ end
181
+
182
+ def key
183
+ @ole_obj.TagString
184
+ end
185
+
186
+ def value
187
+ if mtext?
188
+ @ole_obj.MTextAttributeContent
189
+ else
190
+ @ole_obj.TextString
191
+ end
192
+ end
193
+
194
+ def inspect
195
+ "<Attribute #{key}: #{value}>"
196
+ end
197
+ end
198
+ end