Collision Detection
-
Hello everyone
The following figure...
a and b intersect
b and c intersect
a and c not intersectI get Leny, Lenz from dynamic attributes(inch)
How not to let the detected twice?(a&b and b&a)
Thank you for your help!
mod = Sketchup.active_model
ent = mod.entities
grp = ent.grep(Sketchup::ComponentInstance)
for i in 0...grp.length - 1
grp.each{ |g| next if g == grp[i] # skip comparing to self
bb = Geom::BoundingBox.new.add(g.bounds.intersect(grp[i].bounds))
if bb.valid?#gg = g.get_attribute("dynamic_attributes","lenx","")
gg1 = g.get_attribute("dynamic_attributes","leny","")
gg2 = g.get_attribute("dynamic_attributes","lenz","")
#puts gg#.to_cm
puts gg1#.to_cm
puts gg2#.to_cm#gg3 = grp[i].get_attribute("dynamic_attributes","lenx","")
gg4 = grp[i].get_attribute("dynamic_attributes","leny","")
gg5 = grp[i].get_attribute("dynamic_attributes","lenz","")
#puts gg3#.to_cm
puts gg4#.to_cm
puts gg5#.to_cmq = gg1.to_i * gg2.to_i - gg4.to_i * gg5.to_i
puts q
#puts "#{g.name} and #{grp[i].name} intersect"
else
puts "#{g.name} and #{grp[i].name} do not intersect"
end
bb.clear
}
end

Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement