crystalscad 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/crystalscad/CrystalScad.rb +64 -4
- data/lib/crystalscad/version.rb +1 -1
- metadata +2 -2
@@ -217,9 +217,32 @@ module CrystalScad
|
|
217
217
|
|
218
218
|
# 2d primitives
|
219
219
|
class Square < Primitive
|
220
|
+
def initialize(*args)
|
221
|
+
super(args)
|
222
|
+
@x,@y = args[0][:size].map{|l| l.to_f}
|
223
|
+
end
|
224
|
+
|
220
225
|
def to_rubyscad
|
221
226
|
return RubyScadBridge.new.square(@args)
|
222
227
|
end
|
228
|
+
|
229
|
+
def center_xy
|
230
|
+
@transformations << Translate.new({x:-@x/2,y:-@y/2})
|
231
|
+
self
|
232
|
+
end
|
233
|
+
alias center center_xy
|
234
|
+
|
235
|
+
def center_x
|
236
|
+
@transformations << Translate.new({x:-@x/2})
|
237
|
+
self
|
238
|
+
end
|
239
|
+
|
240
|
+
def center_y
|
241
|
+
@transformations << Translate.new({y:-@y/2})
|
242
|
+
self
|
243
|
+
end
|
244
|
+
|
245
|
+
|
223
246
|
end
|
224
247
|
|
225
248
|
def square(args)
|
@@ -272,6 +295,32 @@ module CrystalScad
|
|
272
295
|
end
|
273
296
|
end
|
274
297
|
|
298
|
+
class AdvancedPrimitive < Primitive
|
299
|
+
|
300
|
+
|
301
|
+
def initialize(attributes)
|
302
|
+
@attr = attributes.collect { |k, v| "#{k} = \"#{v}\"" }.join(', ')
|
303
|
+
super
|
304
|
+
end
|
305
|
+
|
306
|
+
def to_rubyscad
|
307
|
+
"#{@operation}(#{@attr});"
|
308
|
+
end
|
309
|
+
|
310
|
+
end
|
311
|
+
|
312
|
+
|
313
|
+
class Text < AdvancedPrimitive
|
314
|
+
def initialize(attributes)
|
315
|
+
@operation = "text"
|
316
|
+
super(attributes)
|
317
|
+
end
|
318
|
+
end
|
319
|
+
|
320
|
+
def text(args={})
|
321
|
+
return Text.new(args)
|
322
|
+
end
|
323
|
+
|
275
324
|
|
276
325
|
class CSGModelling < Primitive
|
277
326
|
def initialize(*list)
|
@@ -365,15 +414,28 @@ module CrystalScad
|
|
365
414
|
|
366
415
|
|
367
416
|
class Import < Primitive
|
368
|
-
def initialize(
|
417
|
+
def initialize(args)
|
369
418
|
@transformations = []
|
419
|
+
|
420
|
+
if args.kind_of? String
|
421
|
+
filename = args
|
422
|
+
else # assume hash otherwise
|
423
|
+
filename = args[:file]
|
424
|
+
@layer = args[:layer]
|
425
|
+
end
|
426
|
+
|
427
|
+
|
370
428
|
# we need to convert relative to absolute paths if the openscad output is not in the same directory
|
371
429
|
# as the crystalscad program.
|
372
430
|
@filename = File.expand_path(filename)
|
373
431
|
end
|
374
432
|
|
375
433
|
def to_rubyscad
|
376
|
-
|
434
|
+
layer = ""
|
435
|
+
if @layer
|
436
|
+
layer = ",layer=\"#{@layer}\""
|
437
|
+
end
|
438
|
+
return RubyScadBridge.new.import("file=\""+@filename.to_s+"\"#{layer}") # apparently the quotes get lost otherwise
|
377
439
|
end
|
378
440
|
end
|
379
441
|
|
@@ -440,7 +502,6 @@ module CrystalScad
|
|
440
502
|
super(object, attributes)
|
441
503
|
end
|
442
504
|
end
|
443
|
-
|
444
505
|
|
445
506
|
def color(args)
|
446
507
|
return Color.new(self,args)
|
@@ -469,7 +530,6 @@ module CrystalScad
|
|
469
530
|
return Projection.new(self,args)
|
470
531
|
end
|
471
532
|
|
472
|
-
|
473
533
|
|
474
534
|
# Stacks parts along the Z axis
|
475
535
|
# works on all Assemblies that have a @height definition
|
data/lib/crystalscad/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crystalscad
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-06-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rubyscad
|