Question on Ruby Problem
-
Working on a new woodworking joint rb starting with dowel joint and I have this problem passing a negative number to a procedure.
points_DowelCircle_Comp1(@xcl[i],ycl) def points_DowelCircle_Comp1(x,y) UI.messagebox("x = " + x.to_s) UI.messagebox("y = " + y.to_s) r=@@dia/2 @pt[0]=Geom;;Point3d.new(x+r,y,0) @pt[1]=Geom;;Point3d.new(x+(0.866*r),y+(0.5*r),0) @pt[2]=Geom;;Point3d.new(x+(0.5*r),y+(0.866*r),0) @pt[3]=Geom;;Point3d.new(x,y+r,0) @pt[4]=Geom;;Point3d.new(x-(0.5*r),y+(0.866*r),0) @pt[5]=Geom;;Point3d.new(x-(0.866*r),y+(0.5*r),0) @pt[6]=Geom;;Point3d.new(x-r,y,0) @pt[7]=Geom;;Point3d.new(x-(0.866*r),y-(0.5*r),0) @pt[8]=Geom;;Point3d.new(x-(0.5*r),y-(0.866*r),0) @pt[9]=Geom;;Point3d.new(x,y-r,0) @pt[10]=Geom;;Point3d.new(x+(0.5*r),y-(0.866*r),0) @pt[11]=Geom;;Point3d.new(x+(0.866*r),y-(0.5*r),0) #Debug @pt.each {|e| UI.messagebox("point = "+ e.to_s)} end #points_DowelCircleWhen @xcl[i] is a negative number ie. -0.375 the program quits and the UI.messagebox at the start of the method does not happen. What am I doing wrong?
Keith
-
I suspect you haven't shown us the right bit of the code that's failing...
I also assume you get no errors in the Ruby Console ??
add a line in front of this...
points_DowelCircle_Comp1(@xcl[i],ycl)
like
**puts @xcl[i] puts @xcl[i].class** points_DowelCircle_Comp1(@xcl[i],ycl)
??? -
Thanks TIG as usual you were right on the problem and I found the error earlier in the code and it resulted in dir_y did not exist and program did not actually reach the point I thought was the problem.
Keith
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