thnx for your answer.
there is a cases where a model can contain 2 windows linked to a door like the model below, but it doesn't appear using your code
thnx for your answer.
there is a cases where a model can contain 2 windows linked to a door like the model below, but it doesn't appear using your code
hello everyone,
i have a model and i need to detect which face contains a door, i managed to detect windows using the outer and inner loops but it doesn't work on doors as the door has an edge that is common between the face and the floor.
this is the code i use to detect windows and find to which face they belong:
model = Sketchup.active_model
ents= model.active_entities
ents.each do |f|
if f.is_a? Sketchup;;Face
inner_loops = (f.loops - [f.outer_loop])
nested_faces = []
inner_loops.each{|loop|
loop.edges[0].faces.each{|e|
nested_faces << e unless e == f
}
}
if nested_faces.empty?
UI.messagebox("Face; #{f.material.display_name} has no windows ")
else
nested_faces.each{|ff|
UI.messagebox("Face; #{f.material.display_name} contains the window #{ff.material.display_name} ")
}
end
end
end
how can i change my code so that it detects doors also ?
thnx a lot.
that's the model where i'm testing the doors' detection.
Hello everyone,
i working on a sketchup plugin and i want to ask you, is it obligatory to have the entire program in one .rb file or is it possible to have a plugin with muliple classes ?
For example class House, class Type ... and each class will contain methodes that will be used in one plugin.
so is it possible to do so ? if yes how ?
thnx in advance.
oh oky i understand now, thank you soo much this realy helped (y)
Hello TIG thnx for your answer.
i didn't really understand this part:
@unknownuser said:
PS:
You might also want to check for the two faces having the same plane, and face.normal etc unless you can be sure that the faces are 2d and coplanar, and every edge has just one or two faces..
did you meant that it will only work if the faces who contain other faces are in the same plane ? and not for faces who are in an other side ? like this image, in case of the blue face (face H) on the right it also has a face in it (face X) so would it create a problem as it's not in the same plane as the other faces ?
TIG i tried your method i used this code:
model = Sketchup.active_model
ents = model.active_entities
ents.each do |f|
if f.is_a? Sketchup;;Face
loops = f.loops-[f.outer_loop]
nested_faces=[]
loops.each{|loop|
nested_faces << loop.face
}
nested_faces.flatten!
nested_faces.uniq!
for i in (0..nested_faces.length) do
if nested_faces[i]!=nil
UI.messagebox("face #{f.material.name} in face #{nested_faces[i].material.name}")
end
end
end
end
but the messagebox shows :
face B_material is in B_material
face E_material is in E_material
face G_material is in G_material
but i want it to show :
face A_material is in B_material
so as to know both face B and A so that i can calculate the sum of their areas
how can i do that ?
thank you so much for your answer i'll try that
Hello everyone i have this 3D model on Sketchup, and i need to get the areas of diffrent faces using Ruby Sketchup API:
For example :
@unknownuser said:
-for the first face on the left, i need to say that the face has a total area of 1.55 m² which is the area of the B face + the area of the A face, and say that this face has another face (A) in it and it's area is 0.06 m².
And same for other faces (E and G).
How can i find that the face B contains the face A and not C or D ? because all face have the same material and have random x,y,z coordinates.
thank you in advance
No it's not built inside google map.
i'm creating a model of a house that exists in real life, ad i write it's address in an inputbox.
now i want to creat a plugin that shows the location of that house on google map based on the address i wrote .
hello everyone,
I'm trying to create a model of a house that exists in real life, and add an inputbox where the user can write the actual address of that house and then show location of that building in Google Maps.
i tried to install geocoder: Gem.install("geocoder")
but it doesn't find it:
Gem.install("geocoder")
Error; #<Gem;;SpecificGemNotFoundException; Could not find a valid gem 'geocoder' (>= 0) locally or in a repository>
C;/Program Files/SketchUp/SketchUp 2016/Tools/RubyStdLib/rubygems/dependency_installer.rb;301;in `find_spec_by_name_and_version'
C;/Program Files/SketchUp/SketchUp 2016/Tools/RubyStdLib/rubygems/dependency_installer.rb;110;in `available_set_for'
C;/Program Files/SketchUp/SketchUp 2016/Tools/RubyStdLib/rubygems/dependency_installer.rb;322;in `install'
C;/Program Files/SketchUp/SketchUp 2016/Tools/RubyStdLib/rubygems.rb;526;in `install'
<main>;in `<main>'
SketchUp;1;in `eval'
does this gem works only for Ruby on Rails and Sinatra .. ? is there another gem like geocoder that is used for the Ruby Sketchup API ?
thank you a lot.
hello everyone,
i tried to install Mysql using the Sketchup Ruby Console :
Gem.install("mysql")
but it gave me an install error, any help plz ?
this the errors message.
Gem.install("mysql")
Error: #<Gem::InstallError: The 'mysql' native gem requires installed build tools.
Please update your PATH to include build tools or download the DevKit
from 'http://rubyinstaller.org/downloads' and follow the instructions
at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit'
C:/Program Files/SketchUp/SketchUp 2016/Tools/RubyStdLib/rubygems/defaults/operating_system.rb:12:in rescue in block in <top (required)>' C:/Program Files/SketchUp/SketchUp 2016/Tools/RubyStdLib/rubygems/defaults/operating_system.rb:4:in
block in <top (required)>'
C:/Program Files/SketchUp/SketchUp 2016/Tools/RubyStdLib/rubygems/installer.rb:244:in call' C:/Program Files/SketchUp/SketchUp 2016/Tools/RubyStdLib/rubygems/installer.rb:244:in
block in run_pre_install_hooks'
C:/Program Files/SketchUp/SketchUp 2016/Tools/RubyStdLib/rubygems/installer.rb:243:in each' C:/Program Files/SketchUp/SketchUp 2016/Tools/RubyStdLib/rubygems/installer.rb:243:in
run_pre_install_hooks'
C:/Program Files/SketchUp/SketchUp 2016/Tools/RubyStdLib/rubygems/installer.rb:209:in install' C:/Program Files/SketchUp/SketchUp 2016/Tools/RubyStdLib/rubygems/dependency_installer.rb:372:in
block in install'
C:/Program Files/SketchUp/SketchUp 2016/Tools/RubyStdLib/rubygems/dependency_installer.rb:332:in each' C:/Program Files/SketchUp/SketchUp 2016/Tools/RubyStdLib/rubygems/dependency_installer.rb:332:in
each_with_index'
C:/Program Files/SketchUp/SketchUp 2016/Tools/RubyStdLib/rubygems/dependency_installer.rb:332:in install' C:/Program Files/SketchUp/SketchUp 2016/Tools/RubyStdLib/rubygems.rb:526:in
install'
<main>:in <main>' SketchUp:1:in
eval'
mm oky thnx it's just i'm working on a plugin and i don't want it to expire in the middle of my work
hello everyone,
I installed Sketchup Make 2016, but i get this message when i start it :
Sketchup Make 2016 User, Pro Trial, 10 days remaining
But the Sketchup Make is free right ? So why does it give a Trial countdown ?
thnx in advance
Hello,
for those who are interested i found the solution to my question:
i installed the Prawn library using the ruby console in sketchup : Gem.install("prawn")
then i used this code to generate an example of a pdf file:
require 'prawn'
Prawn::Document.generate('C:\Users\laptop-acer01\Desktop\test.pdf') do
text 'this is a test file'
text 'end of file.'
end
Hello everyone,
i'm exploring the possibilities given by Sketchup Ruby API, and i have a question is it possible to generate a Word or PDF documents that contains information extracted from Sketchup models ?
thank you so much.
Thank you for your answer i did adjust my profile, and it's my first time using sketchup and sketchup ruby api and i'm supposed to deliver a projet using those two and i searched so much randomly as i didn't know the exact methode to search about
Yeah i do need to do some Ruby API learning it's just that i want is it possible to export data in an xml file.
and i did find something about the "require" part but do i need to add some files from Nokogiri, REXML or Builder to the sketchup folder ?
i'm using sketchup Make 2014
hello Sketchup developers,
I'm working on a project which is creating a Sketchup extension that collects data and generates it as an XML file, need to create an XML file that contains data (area,
volume ...) from a sketchup house model, using sketchup Ruby API.
I found methods like Nokogiri, REXML and Builder but do they work even for the Sketchup Ruby API ? if so how ?
Does anyone have any idea or examples ?
thank you !
hello everyone ,
i need to generate an xml fil that contains Sketchup data like area, volume ... in Ruby.
for example:
<face>face 0</face>
<area>50.53</area>
.
.
.
does any one have a idea on how i can do that ?