The menu item does not appear in the plugin drop down, but the script is obviously running because the ruby console is repeating an error message! I never thought picking two points on the screen could be so difficult!!
Posts
-
RE: From AutoLisp to Ruby
-
RE: Help with window hole in wall script
TIG - thanks for that. The components will be glued to the wall component/face and the
vect=cdi.transformation.zaxis.reverse
andvect.length=50.mm
worked for me.Now all I need to do is work out how to have the user settings (if changed) remembered between uses of the script within the same Sketchup session. I assume I will need to use instance variables and use getters. This is all very alien to me coming from AutoLisp!! More reading required!!
Thanks for help all.
-
RE: Help with window hole in wall script
sdmitch - To clarify, I'm trying to move the component along its Y-axis by distance olt. ie into the hole just created.
-
RE: Help with window hole in wall script
sdmitch - I'm not getting this transformation thing! I'm sure the penny will drop soon!
I've tried
cdi.glued_to=nil #cdi.transform!(trn*cdi.transformation.inverse) pg = org.offset!(ya,olt) cdi.transform!(pg)
The component moves but not where I expected!!
-
RE: Help with window hole in wall script
sdmitch - Your revised code works a treat, except the window components don't move into the reveals!
The transformation is not working and I am struggling to understand what you are doing here.
cdi.transform!(trn*cdi.transformation.inverse)
Does "trn" not cancel out "cdi.transformation.inverse" ? -
RE: Help with window hole in wall script
Many thanks for the information sdmitch. I love this forum too! I am learning a lot from the experts!
-
RE: From AutoLisp to Ruby
Sorry John
With the above code I'm getting......Error Loading File dbpick.rb
Unrecognized command idI'm running Version 8 Sketchup.
Dean -
RE: From AutoLisp to Ruby
Is the code to have the pick points snapping to geometry and inferencing involve a lot more code?
-
RE: From AutoLisp to Ruby
I think I am not understanding something as I'm getting an error....
Error: #<NoMethodError: private method `class_variable_get' called for SaM::Pick_Points:Class>This is my test code.....
require('sketchup.rb')
def pick
n = 2
Sketchup.active_model.select_tool SaM::Pick_Points.new(n)
SaM::Pick_Points.class_variable_get(:@@pts)
puts @@pts[0]
puts @@pts[1]end
module SaM # namespace it so it doesn't clash
class Pick_Points
def initialize(n)
@ipt = Sketchup::InputPoint.new
@@pts = []
@count = n
@tally = 0
end
def onLButtonDown(flags,x,y,view)@ipt.pick view,x,y @@pts << @ipt.position.to_a p @tally += 1 if @@pts.length == @count p 'done' Sketchup.active_model.select_tool(nil) end
end
end
endif (not file_loaded?("dbpick.rb"))
UI.menu("Plugins").add_item("dbpick") { pick }
end
file_loaded("dbpick.rb") -
Help with window hole in wall script
I'm new to Ruby and have written this quick and dirty script to make a hole in a wall (wall has thickness), from the boundary of a window component glued to the outside face. The script pushpull's from inside and outside to retain materials applied to each wall face, and the window component insets as a bonus!
The script will only work for rectangular window/door components on vertical walls which are orthagonal with global axes, which is the majority of cases!
The script works fine with wall 'faces', but I'm having trouble punching holes in walls that are part of a group. Also, in the rare cases I might have a non-orthogonal wall ie 45 degrees to x-plane the routine doesn't work if I change the axes to align with the wall prior to running the routine!
I would appreciate any guidance with the above. I'm sure I'm missing something basic. Apologies in advance for this!! : )My code so far is attached.
-
From AutoLisp to Ruby
Hi
Having written many AutoLisp routines over the years, I've recently turned my hand to Sketchup Ruby. I must admit to finding it a bit more difficult to grasp the object orientated computing than I imagined. Maybe it's my age! Hopefully, slowly but surely I'll get the hang of it, with the help from you guys in this forum.
I was hoping to find some "recipes" for achieving tasks, but my search on the Internet has not been successful. If anyone knows of such useful code snippets, I would grateful.
Example:- get the user to pick one or two points on screen and store these as variables. In Lisp, this one maybe two lines of code but looking at line.rb as an example this looks to be very complicated for a ruby newbie! Could anyone assist with the basics?
I have other questions, but I won't bombard the forum all at once!! : )
Any help with the above would be most appreciated.