taking content from arrays to open a .3ds file

S

stephanie borg

This is part of my program. what it is intented to do is get the first
line of a txt file which is saved in a[0]. this will be the name of a
3ds model which than has to be imported in sketchup, but to do so, .3ds
has to be added to the name. Something is wrong with my code I know it's
something in the first line show but I can't figure how to write it
correctly.

machine = "a[0].3ds"
model = Sketchup.active_model
show_summary = true
status = model.import machine, show_summary


Thanks
 
J

J. K.

hello,

i may be misunderstanding what you want to do, but if not - try
something like this:

a = ["foo", "bar"]
machine = a[0] + ".3ds"
puts machine

=> foo.3ds

or...

a = ["foo", "bar"]
machine = "#{a[0]}.3ds"
puts machine

=> foo.3ds

- j
 
S

stephanie borg

What it's outputing is :

foo
3ds

I can't seem to get them in the same line!!
 
H

Haruka YAGNI

Your string may have "\n" at last.
How about this?


machine = "#{a[0].strip}.3ds"

String#strip removes whitespaces
 
S

stephanie borg

yesss yesss yesss it worked!!!! thankss all of you!! This forum is
really helpful! Thanks again everybody! :)
 
A

Anurag Priyam

What it's outputing is :
foo
.3ds

I can't seem to get them in the same line!!

Probably your a[0] contains a new line.

Sorry. Accidentally hit send before typing in the complete response.

Try String#chomp method.

"{a[0].chomp}.3ds"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top