I wrote this one a while back:
http://www.crai.archi.fr/RubylibraryDepot/Ruby/EM/rot90.rb
Rotates by 90 degrees around your choice of red|green|blue axes with a right click selection (can be mapped to a shortcut key). CB.
I wrote this one a while back:
http://www.crai.archi.fr/RubylibraryDepot/Ruby/EM/rot90.rb
Rotates by 90 degrees around your choice of red|green|blue axes with a right click selection (can be mapped to a shortcut key). CB.
When you create an object from the class, you have to specify which module it should come from. This code works fine for me:
module Mod1
class Test
def id
puts "Mod1 Test"
end
end
end
module Mod2
class Test
def id
puts "Mod2 Test"
end
end
end
t1 = Mod1;;Test.new
t2 = Mod2;;Test.new
t1.id
t2.id
Result:
Mod1 Test
Mod2 Test
Note that I create two objects (t1 and t2), one of each class. I get away with the classes having the same name because they live in different modules. CB.
vec1.angle_between(vec2) always returns a positive value. I struggled with this when trying to create a transform to make one object parallel with another. What I ended up doing was rotate by the angle returned by angle_between, and then checking the result to see if the objects were indeed parallel. If not, I would instead rotate by the opposite (negative) value. CB.
Sorry about bumping my own thread, but I'd really like to solve this one. The built-in rectangle tool does exactly what I want. You can see it by watching the VCB. Even though you are at a diagonal distance from the the first point, it snaps to even numbers in the cartesian directions.
I started with the line tool sample, but I modifed the VCB code to display the x and y offset values rather than the striaght-line length. But they are always some odd value with a ~. CB.
Thanks Tig. My tools are specific to a very specialized group of users (timber framers), so they'll know what should be selected. I think having the tool grayed out on the menu is all I need to do. CB.
Yes, validation_proc is the correct solution for me. Don't even start the tool if we're not in the correct state. Thanks, Jim. CB.
I'm creating a tool, and there are certain situations where it's inappropriate to use the tool (the user does not have the correct type of component selected). I can display an error message easily enough, but how do I then quit the tool? CB.
@thomthom said:
I think that as a component/group is opened for editing, all co-ordinates are made global.
That explains much.
@thomthom said:
Su7.0 introduced a method to help on this matter: http://code.google.com/apis/sketchup/docs/ourdoc/model.html#edit_transform
And I'll have to transform them all back myself, I guess. Thanks, Thomas.
I want to manipulate the component definition for the component the user is currently editing (which is nested 2 layers deep). If I do this:
ci = model.active_path.last
cd = ci.definition
I get a valid component definition of the type I am expecting, but if I examine the geometry in the cd, all of the locations returned are in the global coordinate system - I expected them to be in the local system: relative to the origin of the component I'm editing. This is strange. Can anyone explain what's going on here?
I'm developing a tool where I'm locating a point that's offset in two directions from a starting point. I started with the example line tool, and things are working pretty well, but the snapping isn't what I would like. It snaps to the nearest 1/8", but in the 'diagonal' distance from the starting point. The x,y values I snap to are thus not multiples of 1/8". The built-in rectangle tool behaves like I want my tool to behave: it snaps to the grid in two dimensions. Does anyone know the trick for this? CB.
Clearly I was overthinking it! Thanks, Thomas.
I guess Martin's way is fine. It won't create a second face, will it? Yes, I'm creating it on an exisiting face. Looping through the geometry was straightforward - it's not that large a component.
The linetool example shows how to extract a single value from the VCB. I need to extract 2, just like the rectangle tool does, in "x,y" format. Is there an easy trick for that? CB.
Or how about this brillaint (late) insight: I used the center point of the circle to add it, so I suppose I could now look for the face that point is on (DOH!). CB.
I modified a component definition using entites.add_circle, now how do I find the disc-shaped face I just created?
I'm noticing that when I orbit to a new position, a guide line may disappear. If I change my orientation slightly, it will come back. Very annoying, since I'm trying to construct geometry using these lines. This is new in version 7.1. CB.
This one is killing me! Can someone tell me how to back down from 7.1 to 7.0? CB.
Hi Pauline.
If I understand correctly, your problem is executing a "require" command from the console window? If so, here are 2 things to keep in mind:
@unknownuser said:
require 'reglue.rb'
false
require 'C:/Program Files (x86)/Google/Google SketchUp 7/Plugins/reglue.rb'
true
I wrote a script called reglue.rb that you can find at the ruby library depot. It's specific to my own needs, but perhaps you can adapt it to yours. In my case, the object you are gluing to is the parent of the component being reglued.