Help with Su v8 plugin syntax
-
Bad syntax?
. . . e.vertices.each do |e| all_file_names.push (" 0\nVERTEX\n 8\n"),comp_inst_layer if block_origin_flag==1 block_origin.push (e.position.x.to_f)+vx block_origin.push (e.position.y.to_f)+vy block_origin.push (e.position.z.to_f)+vz block_origin_flag=0 end all_file_names.push "10\n",(e.position.x.to_f)+vx all_file_names.push "20\n",(e.position.y.to_f)+vy all_file_names.push "30\n",(e.position.z.to_f)+vz all_file_names.push (" 70\n 32\n") end . . .
-
Can you copy the whole of the actual text?
-
This is probably the error:
all_components.push("0\nVERTEX\n 8\n"), comp_inst_layer
But I am not sure if you mean:
all_components.push("0\nVERTEX\n 8\n#{comp_inst_layer}")
or
all_components << "0\nVERTEX\n 8\n" << comp_inst_layer
-
Forgot to post>_< See above.
-
Jim, or anyone, What's the difference between:
all_components.push("0\nVERTEX\n 8\n#{comp_inst_layer}")
, and
all_components << "0\nVERTEX\n 8\n" << comp_inst_layer
?
"comp_inst_layer" is a integer that I need to add to the string. Will the former add a number to the string then add the line to all.components, and the latter ???? -
<<
works likepush
on Arrays, so the first one pushes a single element onto the Array; the second pushes 2 elements on the Array.Sorry, I mixed
<<
andpush
unnecessarily. Maybe this makes more sense?all_components << "0\nVERTEX\n 8\n#{comp_inst_layer}" all_components << "0\nVERTEX\n 8\n" << comp_inst_layer?
-
Thanks, I got it.
This was part of the last bit of code I wrote, only to discover that I failed to account for the location and orientation duplicated components properly. Only works if the component is not duplicated. Doesn't matter too much for how I use it, and I guess that doing it right is a bit too ambitious for my current coding ability.
Addenda 1: Sigh! The code loads, but there are a bunch of other syntax errors as reveled by the "ruby console". Well, here is my chance to learn correct syntax.
Addenda 2: OK, done. -
This is a syntax error in Ruby 1.8.6:
all_file_names.push (" 0\nVERTEX\n 8\n"),comp_inst_layer
The error tells you "unexpected ',' expecting kEND"
So the first comma on the line is between the arguments...
Ruby was expecting an END of line.. and NOT another argument...
therefore Ruby thought the first argument was the entire argument list.In Ruby 1.8.6 ... the first argument CANNOT be wrapped in parenthesis UNLESS you wrap the ENTIRE argumentlist ALSO in parenthesis, AND have no space between the end of the method name and the arglist opening (
like so:
all_file_names.push( (" 0\nVERTEX\n 8\n"),comp_inst_layer )
. -
Dan, Thanks.
Advertisement