I tried to find all faces that one point is inside them and write the following code for it.
#finding all faces in the model
defs = Sketchup.active_model.definitions
list =[]
defs.each { |d|
next if d.image?
ins=[]
d.instances.each{ |i| ins << i }
list << d.instances unless ins.empty?
}
f_list = []
list.each { |c| c[0].definition.entities.grep(Sketchup::Face).find_all { |e| f_list << e } }
#finding faces that pt0 is inside
f_list.each do |f|
if f.parent.is_a? (Sketchup::ComponentDefinition)
pt0_tr = [pt0.x, pt0.y, pt0.z]
grp = f.parent.instances[0]
tr = grp.transformation
pt0_tr.transform! tr.inverse
if grp.parent.is_a? (Sketchup::ComponentDefinition)
# How can I find grp.parent.transformation and ....
end
pt0_faces << f if (f.classify_point(pt0_tr) == 1) || (f.classify_point(pt0_tr) == 4)
end
end
if the face has one group in its instance path it works well but I don’t know what should I do if the face has more than one group or component in its instance path. Your help will be highly appreciated.