Forum: Ruby Undefined method error

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Greg F. (Guest)
on 2009-05-30 21:32
Hello,

I am encountering the following runtime error:

load('C:\\SketchUp\gfVirtualWMS.rb')
Error: #<NoMethodError: C:/Program Files/Google/Google SketchUp
6/Plugins/gfMakePallet01.rb:59:in `gfMakePallet01': undefined method
`material=' for nil:NilClass>
C:/Program Files/Google/Google SketchUp 6/Plugins/gfMakePallet01.rb:59

The code snippet is as follows:

require 'sketchup'

def gfMakePallet01 (x,y,z,w,l,h,theColor,itemNo,lotNo,qoh,expDate)

model = Sketchup.active_model

value = model.set_attribute "link_data", "url", 115
attrdicts = model.attribute_dictionaries
attrdict = attrdicts["link_data"]
dict_name="link_data"
dicts=model.attribute_dictionaries
if( dicts!= nil and dicts[dict_name] )
  dict_key_url = model.get_attribute(dict_name, "url")
else
  UI.messagebox("No URL set for this ")
end


  materials = model.materials
  m = materials.add "Joe"
  m2 = materials.add "Fred"
  #m.texture="c:\\Program Files\\Google\\Google SketchUp
6\\Materials\\Tile\\Tile_Navy.skm"
  #m2.texture="c:\\Program Files\\Google\\Google SketchUp
6\\Materials\\Metal\\Metal_Panel.skm"
  color = m.color = theColor
  #texture = m.texture
  #color = texture.average_color
  #if (color)
  #  UI.messagebox color
  #else
  #  UI.messagebox "Failure"
  #end

  entities = model.entities

  edges = []
  model.start_operation "Make Pallet"

  # left side plane
  pt1 = Geom::Point3d.new(x,y+l,z)
  pt2 = Geom::Point3d.new(x,y,z)
  pt3 = Geom::Point3d.new(x,y,z+h)
  pt4 = Geom::Point3d.new(x,y+l,z+h)
  edges[0] = entities.add_line(pt1, pt2)
  edges[1] = entities.add_line(pt2, pt3)
  edges[2] = entities.add_line(pt3, pt4)
  edges[3] = entities.add_line(pt4, pt1)
  face = entities.add_face edges
  face.material = m

Thank you for your assistance.

Greg
Robert K. (Guest)
on 2009-05-31 13:12
(Received via mailing list)
On 30.05.2009 19:33, Greg Frazier wrote:

> I am encountering the following runtime error:
>
> load('C:\\SketchUp\gfVirtualWMS.rb')
> Error: #<NoMethodError: C:/Program Files/Google/Google SketchUp
> 6/Plugins/gfMakePallet01.rb:59:in `gfMakePallet01': undefined method
> `material=' for nil:NilClass>
> C:/Program Files/Google/Google SketchUp 6/Plugins/gfMakePallet01.rb:59
>
> The code snippet is as follows:

> Thank you for your assistance.

And your question was?

Kind regards

  robert
Greg F. (Guest)
on 2009-05-31 18:32
Robert K. wrote:
> On 30.05.2009 19:33, Greg Frazier wrote:
>
>> I am encountering the following runtime error:
>>
>> load('C:\\SketchUp\gfVirtualWMS.rb')
>> Error: #<NoMethodError: C:/Program Files/Google/Google SketchUp
>> 6/Plugins/gfMakePallet01.rb:59:in `gfMakePallet01': undefined method
>> `material=' for nil:NilClass>
>> C:/Program Files/Google/Google SketchUp 6/Plugins/gfMakePallet01.rb:59
>>
>> The code snippet is as follows:
>
>> Thank you for your assistance.
>
> And your question was?
>
> Kind regards
>
>   robert

Robert.  I solved the problem.  There was a stray method firing off in
the Plugins window when SketchUp launched.  Thank you

Greg
This topic is locked and can not be replied to.