"Cannot convert argument to Geom::Vector3d" error

"Cannot convert argument to Geom::Vector3d" error

Postby Pixero » Tue May 21, 2019 9:48 am

I get a: "Cannot convert argument to Geom::Vector3d" error and I can't see what I'm doing wrong here:
Code snippet:
Code: Select all
sel.each{|e|
      tr = e.transformation
      ip = tr.origin

      xa = tr.xaxis
      ya = tr.yaxis

      a_vector = Geom::Vector3d.new(a_center.x-ip.x, a_center.y-ip.y, 1)

      if(@@axis == "X")
         obj_axis = xa # I've tried with this...
         obj_axis = Geom::Vector3d.new(xa) # ...this...
         obj_axis = Geom::Vector3d.new(xa.to_a) # ...and this
      elsif(@@axis == "Y")
         #obj_axis = ya
         obj_axis = Geom::Vector3d.new(ya.to_a)
      end#if      
      
      angle = a_vector.angle_between obj_axis ### ArgumentError: Cannot convert argument to Geom::Vector3d
                # do more stuff here...
}
0
User avatar
Pixero 
 

Re: "Cannot convert argument to Geom::Vector3d" error

Postby TIG » Tue May 21, 2019 12:24 pm

Before the line starting angle...
Add in these to see what the arguments you pass are
# out the possible obj_axis permutations and retest...

p e
p tr

p a_vector
p obj_axis

p a_vector.to_a
p obj_axis.to_a


If one or both of them are NOT vectors, then we've got somewhere...
1
TIG
User avatar
TIG 
Global Moderator
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 



 

Return to Developers' Forum

Who is online

Users browsing this forum: tamachan and 8 guests

Visit our sponsors: