Error in code
-
Hi,
I was trying out the beginning ruby 1 exercise and I got this eval for line 11 which reads:11:in 'is_a?': wrong number of arguments(0 for 1)
following is the code I copied to ruby console:
` model = Sketchup.active_model
entities = model.active_entities
selection = model.selectionedges = []
faces = []
comps = []
groups = []entities.each do |e|
edges.push e if e.is_a? == "Edge"
faces.push e if e.is_a? == "Face"
comps.push e if e.is_a? == "ComponentInstance"
groups.push e if e.is_a? == "Group"
endputs "Total Edges : " + edges.length.to_s
puts "Total Faces : " + faces.length.to_s
puts "Total Components : " + comps.length.to_s
puts "Total Groups : " + groups.length.to_s
puts "Total Entities : " + entities.length.to_s`The model is a sphere called beginning ruby.
My question is "where is the error in the code?"
Thanks.
-
.is_a?is a method, so you use it like this.is_a?(Sketchup::Edge) -
I went here for methods, but couldn't find ".is_a", should I look elsewhere?
-
.is_a?is a Ruby method - not a Sketchup method. http://ruby-doc.org/core/classes/Object.html#M000373 -
@honoluludesktop said:
I went here for methods, but couldn't find ".is_a", should I look elsewhere?
This is the more recent online API documentation:
http://code.google.com/apis/sketchup/docs/index.html -
OK Thomas, Jim, thanks. Hmm... This will take more effort to learn then I thought:-) I won't even ask for a guess as to how long.
-
Get comfortable with Ruby, then apply that to the API documentation. Read other people's code, and most importantly - try things yourself, and ask questions when they don't work.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement