microstation 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. data/.autotest +23 -0
  2. data/.gemtest +0 -0
  3. data/.rspec +2 -0
  4. data/Gemfile +17 -0
  5. data/History.txt +6 -0
  6. data/Manifest.txt +60 -0
  7. data/README.txt +75 -0
  8. data/Rakefile +30 -0
  9. data/bin/dgn2pdf +37 -0
  10. data/lib/microstation.rb +88 -0
  11. data/lib/microstation/app.rb +286 -0
  12. data/lib/microstation/attributes.rb +35 -0
  13. data/lib/microstation/cad_input_queue.rb +25 -0
  14. data/lib/microstation/configuration.rb +57 -0
  15. data/lib/microstation/dir.rb +252 -0
  16. data/lib/microstation/drawing.rb +189 -0
  17. data/lib/microstation/enumerator.rb +29 -0
  18. data/lib/microstation/ext/pathname.rb +25 -0
  19. data/lib/microstation/extensions/hash.rb +27 -0
  20. data/lib/microstation/pdf_support.rb +40 -0
  21. data/lib/microstation/properties.rb +57 -0
  22. data/lib/microstation/scan/color.rb +38 -0
  23. data/lib/microstation/scan/criteria.rb +85 -0
  24. data/lib/microstation/scan/klass.rb +43 -0
  25. data/lib/microstation/scan/level.rb +38 -0
  26. data/lib/microstation/scan/line_style.rb +45 -0
  27. data/lib/microstation/scan/line_weight.rb +33 -0
  28. data/lib/microstation/scan/subtype.rb +40 -0
  29. data/lib/microstation/scan/type.rb +109 -0
  30. data/lib/microstation/scanner.rb +24 -0
  31. data/lib/microstation/tag.rb +58 -0
  32. data/lib/microstation/tag_set.rb +280 -0
  33. data/lib/microstation/template.rb +84 -0
  34. data/lib/microstation/text.rb +54 -0
  35. data/lib/microstation/text_node.rb +74 -0
  36. data/lib/microstation/ts/attribute.rb +139 -0
  37. data/lib/microstation/ts/instance.rb +112 -0
  38. data/lib/microstation/types.rb +91 -0
  39. data/lib/microstation/wrap.rb +214 -0
  40. data/plot/pdf-bw.plt +164 -0
  41. data/plot/pdf.plt +163 -0
  42. data/plot/png.plt +383 -0
  43. data/plot/tiff.plt +384 -0
  44. data/plot/wmbw.tbl +66 -0
  45. data/plot/wmcolor.tbl +62 -0
  46. data/spec/app_spec.rb +267 -0
  47. data/spec/configuration_spec.rb +122 -0
  48. data/spec/drawing_spec.rb +247 -0
  49. data/spec/drawings/new_drawing.dgn +0 -0
  50. data/spec/drawings/test.dgn +0 -0
  51. data/spec/drawings/test1.dgn +0 -0
  52. data/spec/drawings/testfile.pdf +0 -0
  53. data/spec/enumerator_spec.rb +60 -0
  54. data/spec/microstation_spec.rb +36 -0
  55. data/spec/scanner_spec.rb +155 -0
  56. data/spec/spec_app.rb +11 -0
  57. data/spec/spec_helper.rb +31 -0
  58. data/spec/tag_set_spec.rb +123 -0
  59. data/spec/text_node_spec.rb +92 -0
  60. data/spec/text_spec.rb +62 -0
  61. metadata +241 -0
@@ -0,0 +1,91 @@
1
+ module Microstation
2
+
3
+ module Types
4
+
5
+ Line = 3
6
+ Shape = 6
7
+ Text = 17
8
+ TextNode = 7
9
+ Curve = 11
10
+
11
+ end
12
+
13
+ Ole_Types = {
14
+ CellLibraryHeader: 1,
15
+ CellHeader: 2,
16
+ Line: 3,
17
+ LineString: 4,
18
+ GroupData: 5,
19
+ Shape: 6,
20
+ TextNode: 7,
21
+ DigSetData: 8
22
+ DesignFileHeader: 9,
23
+ LevelSymbology: 10,
24
+ Curve: 11,
25
+ ComplexString: 12,
26
+ Conic: 13,
27
+ ComplexShape: 14,
28
+ Ellipse: 15,
29
+ Arc: 16,
30
+ Text: 17,
31
+ }
32
+
33
+
34
+
35
+
36
+ end
37
+
38
+ msdElementTypeCellLibraryHeader 1 (&H1)
39
+ msdElementTypeCellHeader 2 (&H2)
40
+ msdElementTypeLine 3 (&H3)
41
+ msdElementTypeLineString 4 (&H4)
42
+ msdElementTypeGroupData 5 (&H5)
43
+ msdElementTypeShape 6 (&H6)
44
+ msdElementTypeTextNode 7 (&H7)
45
+ msdElementTypeDigSetData 8 (&H8)
46
+ msdElementTypeDesignFileHeader 9 (&H9)
47
+ msdElementTypeLevelSymbology 10 (&HA)
48
+ msdElementTypeCurve 11 (&HB)
49
+ msdElementTypeComplexString 12 (&HC)
50
+ msdElementTypeConic 13 (&HD)
51
+ msdElementTypeComplexShape 14 (&HE)
52
+ msdElementTypeEllipse 15 (&HF)
53
+ msdElementTypeArc 16 (&H10)
54
+ msdElementTypeText 17 (&H11)
55
+ msdElementTypeSurface 18 (&H12)
56
+ msdElementTypeSolid 19 (&H13)
57
+ msdElementTypeBsplinePole 21 (&H15)
58
+ msdElementTypePointString 22 (&H16)
59
+ msdElementTypeCone 23 (&H17)
60
+ msdElementTypeBsplineSurface 24 (&H18)
61
+ msdElementTypeBsplineBoundary 25 (&H19)
62
+ msdElementTypeBsplineKnot 26 (&H1A)
63
+ msdElementTypeBsplineCurve 27 (&H1B)
64
+ msdElementTypeBsplineWeight 28 (&H1C)
65
+ msdElementTypeDimension 33 (&H21)
66
+ msdElementTypeSharedCellDefinition 34 (&H22)
67
+ msdElementTypeSharedCell 35 (&H23)
68
+ msdElementTypeMultiLine 36 (&H24)
69
+ msdElementTypeTag 37 (&H25)
70
+ msdElementTypeDgnStoreComponent 38 (&H26)
71
+ msdElementTypeDgnStoreHeader 39 (&H27)
72
+ msdElementType44 44 (&H2C)
73
+ msdElementTypeMicroStation 66 (&H42) See ApplicationElement
74
+ msdElementTypeRasterHeader 87 (&H57)
75
+ msdElementTypeRasterComponent 88 (&H58)
76
+ msdElementTypeRasterReference 90 (&H5A)
77
+ msdElementTypeRasterReferenceComponent 91 (&H5B)
78
+ msdElementTypeRasterFrame 94 (&H5E)
79
+ msdElementTypeTableEntry 95 (&H5F)
80
+ msdElementTypeTable 96 (&H60)
81
+ msdElementTypeViewGroup 97 (&H61)
82
+ msdElementTypeView 98 (&H62)
83
+ msdElementTypeLevelMask 99 (&H63)
84
+ msdElementTypeReferenceAttachment 100 (&H64)
85
+ msdElementTypeMatrixHeader 101 (&H65)
86
+ msdElementTypeMatrixIntegerData 102 (&H66)
87
+ msdElementTypeMatrixDoubleData 103 (&H67)
88
+ msdElementTypeMeshHeader 105 (&H69)
89
+ msdElementTypeReferenceOverride 108 (&H6C)
90
+ msdElementTypeNamedGroupHeader 110 (&H6E)
91
+ msdElementTypeNamedGroupComponent 111 (&H6F)
@@ -0,0 +1,214 @@
1
+ module Microstation
2
+
3
+ def self.needs_extending?(ole)
4
+ ole.class == WIN32OLE && (not ole.respond_to? :text?)
5
+ end
6
+
7
+ class TaggedElement
8
+
9
+ class Set
10
+
11
+ attr_reader :element
12
+
13
+ def initialize(name,element)
14
+ @name = name
15
+ @element = element
16
+ end
17
+
18
+ def name
19
+ @name
20
+ end
21
+
22
+ def elements=(elements)
23
+ elements.each do |ele|
24
+ ele.base_element = @element
25
+ end
26
+ @elements = elements
27
+ end
28
+
29
+ def find_attribute(name)
30
+ @elements.find{|a| a.name == name.to_s}
31
+ end
32
+
33
+ def [](name)
34
+ find_attribute(name)
35
+ end
36
+
37
+ def attributes
38
+ @elements.map{|e| e.name}
39
+ end
40
+
41
+ def update_element(name,value)
42
+ find_attribute(name)._update(value)
43
+ end
44
+
45
+ def element_value(name)
46
+ find_attribute(name).value
47
+ end
48
+
49
+ def to_hash
50
+ result = {}
51
+ @elements.each do |ele|
52
+ result[ele.name] = ele.value unless (ele.value == "" || ele.value.nil?)
53
+ end
54
+ result
55
+ end
56
+
57
+ def stringify_keys(hash)
58
+ result = {}
59
+ hash.each do |key,value|
60
+ result[key.to_s] = value
61
+ end
62
+ result
63
+ end
64
+
65
+ def update(value_hash)
66
+ value_hash = stringify_keys(value_hash)
67
+ valid_atts = attributes & value_hash.keys
68
+ valid_atts.each do |att|
69
+ update_element(att,value_hash[att])
70
+ end
71
+ end
72
+
73
+ def method_missing(meth,*args,&block)
74
+ # binding.pry
75
+ base = meth.to_s.sub("=", "")
76
+ if attributes.include?(base)
77
+ if meth.match /(=)/
78
+ update_element(base,*args)
79
+ else
80
+ element_value(base.to_s)
81
+ end
82
+ else
83
+ super(meth,*args,&block)
84
+ end
85
+ end
86
+
87
+ end
88
+
89
+ def initialize(ole=nil)
90
+ @ole_obj = ole
91
+ @tag_sets = []
92
+ end
93
+
94
+ def add_tagset(name,elements)
95
+ ts = TaggedElement::Set.new(name,self)
96
+ ts.elements = elements
97
+ @tag_sets << ts
98
+ ts
99
+ end
100
+
101
+ def get_tagset(name)
102
+ @tagsets.find{|ts| ts.name == name}
103
+ end
104
+
105
+
106
+ end
107
+
108
+ class Element
109
+
110
+
111
+ def self.convert_item(item)
112
+ return item unless item.class == WIN32OLE
113
+ case item.Type
114
+ when Microstation::MSD::MsdElementTypeText
115
+ Microstation::Text.new(item)
116
+ when Microstation::MSD::MsdElementTypeTextNode
117
+ Microstation::TextNode.new(item)
118
+ when Microstation::MSD::MsdElementTypeTag
119
+ Microstation::Tag.new(item)
120
+ else
121
+ new(item)
122
+ end
123
+ end
124
+
125
+ def self.ole_object?
126
+ ole.class == WIN32OLE
127
+ end
128
+
129
+
130
+ attr_reader :ole_obj
131
+
132
+ def initialize(ole)
133
+ @ole_obj = ole
134
+ @original = ole_value
135
+ end
136
+
137
+ def update_ole(value)
138
+ end
139
+
140
+ def ole_value
141
+ end
142
+
143
+ def text?
144
+ ole_obj.Type == Microstation::MSD::MsdElementTypeText
145
+ end
146
+
147
+ def text_node?
148
+ ole_obj.Type == Microstation::MSD::MsdElementTypeTextNode
149
+ end
150
+
151
+ def has_tags?
152
+ ole_obj.HasAnyTags
153
+ end
154
+
155
+ def textual?
156
+ text? || text_node?
157
+ end
158
+
159
+ def microstation_id
160
+ ole_obj.Id || ole_obj.ID64
161
+ end
162
+
163
+ def Type
164
+ ole_obj.Type
165
+ end
166
+
167
+ def microstation_type
168
+ Type
169
+ end
170
+
171
+ def method_missing(meth,*args,&block)
172
+ if meth.to_s =~ /^[A-Z]/
173
+ result = ole_obj.send(meth,*args,&block)
174
+ Element.convert_item(result)
175
+ else
176
+ super(meth,*args,&block)
177
+ end
178
+ end
179
+
180
+ def _update(value)
181
+ oldvalue = @original
182
+ return if value == oldvalue
183
+ begin
184
+ update_ole(value)
185
+ @ole_obj.Redraw Microstation::MSD::MsdDrawingModeNormal
186
+ @ole_obj.Rewrite
187
+ @original = value
188
+ rescue
189
+ _update(oldvalue)
190
+ end
191
+ end
192
+
193
+ end
194
+ end
195
+
196
+ module Microstation
197
+
198
+ module Wrap
199
+
200
+
201
+ def wrap(item)
202
+ Element.convert_item(item)
203
+ end
204
+
205
+ # def text?(item)
206
+ # item.Type == Microstation::MSD::MsdElementTypeText
207
+ # end
208
+
209
+ # def text_node?(item)
210
+ # item.Type == Microstation::MSD::MsdElementTypeTextNode
211
+ # end
212
+
213
+ end
214
+ end
@@ -0,0 +1,164 @@
1
+ ;----------------------------------------------------------------------
2
+ ;
3
+ ; Portable Document file (PDF) Plotter Driver Configuration file
4
+ ;
5
+ ; Current Revision:
6
+ ; $RCSfile: pdf.plt,v $
7
+ ; $Revision: 1.1.2.16.2.1 $ $Date: 2004/03/23 21:07:42 $
8
+ ;
9
+ ;----------------------------------------------------------------------
10
+
11
+ ;======================================================================
12
+ ;
13
+ ; >>>>> WARNING WARNING WARNING WARNING WARNING WARNING <<<<<
14
+ ;
15
+ ; Plotter driver configuration files are now stored in two directories:
16
+ ;
17
+ ; $(_USTN_WORKSPACEROOT)/System/plotdrv/
18
+ ; $(_USTN_WORKSPACEROOT)/Standards/plotdrv/
19
+ ;
20
+ ; System/plotdrv/ should be reserved for .plt files delivered by
21
+ ; MicroStation and other Bentley products. Standards/plotdrv/ is
22
+ ; provided as a place for you to store customized .plt files. To
23
+ ; simplify plotter selection from the Plot dialog, you may also
24
+ ; elect to store frequently-used .plt files in Standards/plotdrv/
25
+ ; even if you do not customize them.
26
+ ;
27
+ ; To minimize the risk of losing your changes during a product
28
+ ; reinstallation, do not edit the files in the System/plotdrv/
29
+ ; directory. Instead, copy the necessary files to Standards/plotdrv/
30
+ ; and edit them there. If the .plt file depends on other files, such
31
+ ; as PostScript prolog (*.pro) files, copy them to the same directory.
32
+ ;
33
+ ;======================================================================
34
+ ; Construction/active points are plotted by default. Comment out the next line
35
+ ; if you do not want points plotted.
36
+
37
+ point_size = 0.03
38
+ default_extension = 'pdf' ; default extension for plotfiles
39
+ document_set
40
+ model = mdl
41
+ driver = pdf
42
+ autocenter ; Automatically center plot on page
43
+
44
+ ;num_pens = 255 ; required record, must precede any "pen" records.
45
+ num_pens = 1 ; Monochrome
46
+ change_pen = both
47
+
48
+ ; Remove this record if no border is desired.
49
+ ; Refer to the documentation for available border qualifiers.
50
+ border /filename /time /text_height=0.35
51
+
52
+ ; Substitute the name of a pentable file to be loaded when this driver is selected
53
+ ;pentable=\dir\file.tbl
54
+
55
+ ;=================================================================
56
+ ;Turn the Book Marks on and off
57
+ CmdName /appname="pdf" /command="BookMarks" /qualifier="On"
58
+ ;CmdName /appname="pdf" /command="BookMarks" /qualifier="Off"
59
+ ;on by default
60
+ ;=================================================================
61
+
62
+ ;=================================================================
63
+ ;Turn the Level/File optional content on and off
64
+ ;CmdName /appname="pdf" /command="FileOptionalContent" /qualifier="On"
65
+ CmdName /appname="pdf" /command="FileOptionalContent" /qualifier="Off"
66
+ ;off by default
67
+ ;=================================================================
68
+
69
+ ;=================================================================
70
+ ;Turn Engineering links on and off
71
+ CmdName /appname="pdf" /command="EngineeringLinks" /qualifier="On"
72
+ ;CmdName /appname="pdf" /command="EngineeringLinks" /qualifier="Off"
73
+ ;on by default
74
+ ;=================================================================
75
+
76
+ ;=================================================================
77
+ ;pick the version of pdf you want to support
78
+ CmdName /appname="pdf" /command="version" /qualifier="Acrobat 6 (PDF 1.5)/Viewable in Acrobat 5"
79
+ ;CmdName /appname="pdf" /command="version" /qualifier="Acrobat 6 (PDF 1.5)"
80
+ ;CmdName /appname="pdf" /command="version" /qualifier="Acrobat 5 (PDF 1.4)"
81
+ ;=================================================================
82
+
83
+ ;=================================================================
84
+ ;uncomment the line and change the qualifier to your password
85
+ ;if you wish to protect the output pdf file.
86
+ ;NOTE the pdf file will not view with out the password
87
+ ;But then is unprotected
88
+ ;CmdName /appname="pdf" /command="userpassword" /qualifier="my_password"
89
+ ;=================================================================
90
+
91
+ ;=================================================================
92
+ ;RGB Raster compression
93
+ ;CmdName /appname="pdf" /command="RGBRasterCompression" /qualifier="jpeg"
94
+ CmdName /appname="pdf" /command="RGBRasterCompression" /qualifier="zipped"
95
+ ;zipped by default
96
+ ;=================================================================
97
+
98
+ ;=================================================================
99
+ ;Searchable Text
100
+ CmdName /appname="pdf" /command="SearchableText" /qualifier="on"
101
+ ;CmdName /appname="pdf" /command="SearchableText" /qualifier="off"
102
+ ;on by default
103
+ ;=================================================================
104
+
105
+
106
+ ; ENGLISH resolution and SIZE records
107
+ size=(44,34)/num=0/off=(0,0)/name="ANSI E"
108
+ size=(22,17)/num=0/off=(0,0)/name="ANSI C"
109
+ size=(17,11)/num=0/off=(0,0)/name="ANSI B"
110
+ size=(11,8.5)/num=0/off=(0,0)/name="ANSI A"
111
+ size=(34,22)/num=0/off=(0,0)/name="ANSI D"
112
+ resolution(IN)=(0.001666666666666666666667,0.001666666666666666666667) ;600DPI
113
+
114
+ ; METRIC resolution and SIZE records
115
+ ;size=(1189,841)/num=0/off=(0,0)/name="ISO A0"
116
+ ;size=(841,594)/num=0/off=(0,0)/name="ISO A1"
117
+ ;size=(594,420)/num=0/off=(0,0)/name="ISO A2"
118
+ ;size=(420,297)/num=0/off=(0,0)/name="ISO A3"
119
+ ;size=(297,210)/num=0/off=(0,0)/name="ISO A4"
120
+ ;resolution(MM)=(0.04233333333333333333333,0.04233333333333333333333); 600DPI
121
+
122
+ ; The style records define how the design file line codes (styles)
123
+ ; are to be plotted. Values are in plotter units (resolutions).
124
+ ; Values determine pen down/up movements, where (10,28) for a dot
125
+ ; pattern leaves the pen down for 10 units and up for 28 units. The
126
+ ; /nohardware switch causes software stroking with these values.
127
+ ; This example has the /nohardware option commented
128
+ ; out, so the printer will draw the styles.
129
+
130
+ style(1)=(18, 18) ;/nohardware ;style = dot
131
+ style(2)=(37, 37) ;/nohardware ;style = med dash
132
+ style(3)=(75, 75) ;/nohardware ;style = long dash
133
+ style(4)=(75, 37, 18, 37) ;/nohardware ;style = dot-dash
134
+ style(5)=(27, 27) ;/nohardware ;style = short dash
135
+ style(6)=(75, 37, 18, 37, 18, 37) ;/nohardware ;style = dash-dot-dot
136
+ style(7)=(75, 27, 32, 27) ;/nohardware ;style = long dash - short dash
137
+
138
+ stroke_tolerance=9.0
139
+ largest_polygon=200000
140
+ linecap = 0 ; 0=butt, 1=round, 2=square
141
+ linejoin = 0 ; 0=mitered, 1=round, 2=bevel
142
+ miter_limit = 3.0 ; larger values mean longer spikes
143
+ ; 1=none, 1.415=90deg, 2=60deg, 10=11deg etc.
144
+
145
+ ; Specify the mapping of MicroStation line weights to line thickness on paper.
146
+ ; Units are MM, IN, or DOTS (the default)
147
+
148
+ weight_strokes(mm)=(0.250, 0.375, 0.500, 0.625, 0.750, 0.875, 1.000, 1.125, \
149
+ 1.250, 1.375, 1.500, 1.625, 1.750, 1.875, 2.000, 2.125, \
150
+ 2.250, 2.375, 2.500, 2.625, 2.750, 2.875, 3.000, 3.125, \
151
+ 3.250, 3.375, 3.500, 3.625, 3.750, 3.875, 4.000, 4.125)
152
+
153
+
154
+
155
+ ; The following options control raster plotting.
156
+ isv_raster=1 ; Plots the raster image, 1=On 0=Off Default=1
157
+ pixel_resolution=300 ; Resolution of pixels on output (dpi) Default=300
158
+ contrast=50 ; Contrast in percent, between 0-100 Default=50
159
+ brightness=50 ; Brightness in percent, between 0-100 Default=50
160
+ raster_fence=1 ; Clip the raster to fence, 1=On 0=Off Default=1
161
+ grayscale=0 ; Plot in gray scale, 1=On 0=Off Default=0
162
+ no_dgnraster=0 ; MS plot of 87/88, 1=Don't plot 0=Plot Default=0
163
+ background = 0 ; 0=white,1=black,2=color Default=0
164
+ no_rasterref=0 ; MS plot of 90's, 1=Don't plot 0=Plot Default=0