Are you familiar with regular expressions?
azuby
Are you familiar with regular expressions?
azuby
If I remember right, I had a fully installed Ruby on my PC and took the REXML lib from it. The directory contains 55 files and five folders. I loaded it this way from my script:
require 'rexml/document' unless defined? REXML
If you also want to load this way you have to make sure that the Ruby interpreter search in the right place. Put the REXML folder to Plugins or Tools folder - should work with the above code.
To make sure that your script only runs if REXML is loaded, put this condition to your codee:
if defined? REXML
# YOUR CODE HERE
else
UI.messagebox "REXML is missed, can't load plugin."
end
Sorry for my late answer - I'm moving from town to town at the moment.
azuby
I also coded something similar this night reusing the code form "Select all with same orientation" (SAWSO) It's should be simple to integrate the functionality to select more than one line, Chris.
azuby
Maybe you want to try FFlipper - http://errorinitus.de > Downloads - at the moment, it explodes components No time to fix
Does the following:
azuby
You could overwrite the add_toolbar and toolbar_names methods of Sketchup. But you have to make sure that your plugin is the first loaded.
azuby
Hey folks,
does anyone of you can explain, why all validation procs (Menu#set_validation_proc) are called numerous times when I only move the mouse? (Sketchup 6 and 7)
azuby
Next thought: Using mailto and open the directory containing the .skp file. Unfortunately the user has to drag'n'drop the file into the email window.
azuby
@jim said:
Thomas, what if a definition exists in the DefinitionList but does not have an instance in the model? Do you still want its entities? I guess it depends of what the use of the collection is.
Use ComponentDefinition#instances:
Sketchup.active_model.definitions.each do |d|
if inss = d.instances # line is correct!
inss.each do |ins|
# ...
end
end
end
azuby
$stdout points to an IO object. A File object is an IO object too:
File.ancestors #=> [File, IO, File::Constants, Enumerable, Object, Kernel]
azuby
Sorry man - it was just the term "using classes as objects", this is meta-programming. In most of the scripts the programmers use classes to build objects.
Modules are kind of light classes, because you can not make objects of them on the direct way.
azuby
Kernel#puts is much more complex. it would be better using the splat operator:
def puts *arg
#...
end
You also could switch $stdout.
azuby
In case of Ruby you are right: classes are objects:
Class.is_a? Class #=> true
Class.ancestors #=> [Class, Module, Object, Kernel]
Class.object_id #=> ...
class A; end
A.is_a? Class #=> true
A.ancestors #=> [A, Object, Kernel]
A.object_id #=> ...
But for programming, classes are blueprints for building objects. You have to ask yourself, why you do not use objects and so do not make use of classes. It's a question that points on the programming paradigm you use.
azuby
Sketchup 7 uses Ruby 1.8.0 like Sketchup 6 does. Type VERSION to see the version number into the Ruby Console.
azuby
It's from here: http://betaforum.sketchup.com/showthread.php?t=80231 - lee7000 and RickW.
azuby
I agree: Sketchup Ruby (1.8.0) is just a basic thing. "True" Ruby (>= 1.8.6) has lots of great libs.
(PLEAC Ruby - kind of documentation)
azuby
I see, you do NOT care about Ruby, jj. You do not look for information - instead YOUR only wish seems to be having Python for improving Sketchup. No problem with that, but it is only YOUR wish.
Ruby has GUI support for:
TK
wxWidgets
Qt
GTK
Fox
WebDialogs for Sketchup
Multi line consoles:
WebConsole - http://sketchuptips.blogspot.com/2007/08/plugin-webconsolerb.html
d/Code - http://www.errorinitus.de/ => Software
Your first steps could be using a bridge between Ruby and Python (or use the Sketchup SDK to write your own lib):
Ruby/Python - http://www.goto.info.waseda.ac.jp/~fukusima/ruby/python/doc/index.html
Ruby-Python-Bridge - http://www.vyperlogix.com/ruby-python-bridge/
pyRuby-Python-Bridge - http://pypi.python.org/pypi/pyRuby-Python-Bridge/1.7
azuby
Sketchup challenge
Ruby(0): +1, you can use it with Sketchup
Ruby(1): +1, it is used by many people to improve Sketchup
Sketchup challenge - result:
Ruby 2:0 Python
Conclusion: I think, I should use Ruby to improve Sketchup instead wasting time explaining all the advantages of progamming language XYZ. Let's call it: Pragmatic programming.
Btw. The rubyfied school example:
class SchoolMember
def initialize name, age
@name = name
@age = age
end
def to_s
"Name; \"#{@name}\" Age; \"#{@age}\""
end
end
class Teacher < SchoolMember
def initialize name, age, salary
super name, age
@salary = salary
end
def to_s
super + " Salary; \"#{@salary}\""
end
end
class Student < SchoolMember
def initialize name, age, marks
super name, age
@marks = marks
end
def to_s
super + " Marks; \"#{@marks}\""
end
end
t = Teacher.new 'Mrs. Jones', 40, 30000
s = Student.new 'Jack', 23, 75
[t, s].each { |m| puts m }
Hope, you like the short lines.
azuby
Sketchup.active_model.materials.each { |mat| p mat }
works fine. Result:
#<Sketchup;;Material;0xf2a5110>
#<Sketchup;;Material;0xf2a50e0>
#<Sketchup;;Material;0xf2a50b0>
#<Sketchup;;Material;0xf2a5080>
#<Sketchup;;Material;0xf2a5050>
#<Sketchup;;Material;0xf2a5020>
#<Sketchup;;Material;0xf2a4ff0>
#<Sketchup;;Material;0xf2a4fc0>
azuby
Don't know, but wouldn't be a difficult thing:
# get the input
# ...
r = Regexp.new input
# iterate over the elements
# checking name
# adding to selection, if name fits
azuby