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.