hi tig,
thanx a lot, i inserted the new import routine and tried different variantion.
ruby gives back:
load '01.rb'
true
Error: #<NameError: undefined local variable or method lines' for #<Object:0x3d31654 @v_b="90", @v_a="300", @v_c="100">> C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/01.rb:96:in
draw_stairs'
C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/01.rb:48
C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/01.rb:96:in call' C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/01.rb:96 load '01.rb' true Error: #<NoMethodError: undefined method
/' for "300":String>
C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/01.rb:173:in draw_stairs' C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/01.rb:48 C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/01.rb:96:in
call'
C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/01.rb:96
so the situation is:
i am created an object in skp, which can be controlled in diverse dimension by an input menue (parameters)
when the object is created, i save the parameters in a text file (parttemp2.txt):
content of parttemp2.txt now for testing:
300
90
100
it seems, that reloading these numbers gives back STRINGS and not numbers
as <ou also said, i would like to handle these imported parameters by
parameter01 = lines[0]
parameter02 = lines[1]
and so on.
but it simply does not work now for me. have to study more about formats (you know, i am on ruby since few days)
this is the whole pert of the code: (where WIDTH shall become the value of line 0 in the text-file)
require 'sketchup.rb'
#require 'offset.rb'
#require 'makesoftsmooth.rb'
.
Sketchup.send_action "showRubyPanel:"
#Add a menu item to launch our plugin.
UI.menu("PlugIns").add_item("01-ZF-Stairs"){
UI.messagebox("Outdoor-Stairs - Script - 131011-V 0.1j - Zdenek Fajfrlik")
#result = UI.messagebox "New Definition?", MB_YESNO
#if result == 6 # Yes
UI.messagebox("New Definition")
end
#count = 0
#File.open('C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/zf/partemp.txt', 'r') do |f1|
#while line = f1.gets
#puts line
#width = f1.gets
#end
#end
file = 'C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/zf/partemp2.txt'
lines=[]
IO.readlines(file).each{|line|
line.chomp! ### removes the '\n' from the end of the line
next if line.empty? ### this traps for empty lines
lines << line
}
you need to set up instance variables, @v_a etc, so they get referenced outside of the {} block, plain v_a won't be referenced outside and would therefore be inaccessible...
v='@v_a'
lines.each{|e|
eval("#{v}='#{e}'")
v.next!
}
Call
draw_object
}
def draw_object
#***************************************************************************
#delete previous model
model = Sketchup.active_model
entities = model.active_entities
entities.to_a.each { | entity| entity.erase! }
#***************************************************************************
set start default values for MENUE 1-4
width = @v_a
lwidthplus = @v_b
rwidthplus = @v_c
#width = 500
#lwidthplus = 10
#rwidthplus = 10
stairs = 10
run = 30
rise = 13
thickness = 3
fill = 4
overlap = 6
il = 6
rc = 3
re = 0
stepdevidex = 1
sl = 100
sr = 100
mr = 80
pmod = 3
pradius = 15
thradius = 20
mhradius = 4
lines = 4
ro = 4
rol = 5
ror = 5
wangenbreitel = 30
wangenhoehel = 10
wangeslopel = 45.0
rampoffsetl = 50
rampoffsetly = 30
rampoffsetlz = 99.0
wangenbreiter = 30
wangenhoeher = 10
wangesloper = 45.0
rampoffsetr = 50
rampoffsetry = 30
rampoffsetrz = 99.0
#***************************************************************************
thank you very very much for your time and helping!
STAN