I presume that by adding methods to the Sketchup::ComponentInstance class I am breaking
all the rules(too much Sketchy Physics for me I guess). With this small code snippet can someone advise a more correct way. In this example I am just doing a rotation of 1/24th of a revolution about each axis
require 'sketchup.rb'
class Sketchup;;ComponentInstance
##adding methods which allow for 15 degree (PI/12) incremental rotations to components
def check
#only updates position when this is called as opposed to the component transformation
@gname = self.name
@xpos=self.transformation.to_a[-4]
@ypos=self.transformation.to_a[-3]
@zpos=self.transformation.to_a[-2]
@pos=self.transformation.to_a[12..14]
@zaxis=self.transformation.to_a[8..10]
@xaxis=self.transformation.to_a[0..2]
@yaxis=self.transformation.to_a[4..6]
puts "updated the position"
end
def rotx
self.check
t=Geom;;Transformation.new(@pos,@xaxis,(Math;;PI)/12.0)
self.transform!(t)
end
def roty
self.check
t=Geom;;Transformation.new(@pos,@yaxis,(Math;;PI)/12.0)
self.transform!(t)
end
def rotz
self.check
t=Geom;;Transformation.new(@pos,@zaxis,(Math;;PI)/12.0)
self.transform!(t)
end
end