How do I change the code?
-
mod = Sketchup.active_model
ent = mod.entitiesq = Sketchup.active_model.selection.add(
Sketchup.active_model.definitions["aaa"].instances )a = Sketchup.active_model.selection.add(
Sketchup.active_model.definitions["bbb"].instances )bb = Geom::BoundingBox.new.add(q.bounds.intersect(a.bounds))
if bb.valid?
puts "a"
else
puts "b"
endIt can't run...
How do I change the code? -
Seems like you want to find the intersections of instances.
First remember that the instances might be in different entities contexts...
Using the selection is not always going to work as you expect...
Better to get a list of the definitions' instancesas = mod.definitions["aaa"].instances bs = mod.definitions["bbb"].instancesnow iterate one list and check intersections in the other.
hits = {} ### empty hash as.each{|a| es = a.parent.entities hits[a]=[] bs.each{|b| next unless es = b.parent.entities ### same context bb = a.bounds.intersect(b.bounds) hits[a] << b if bb && bb.valid? } } hits.each{|hit| puts "AAA #{hit[0]} intersects BBB #{hit[1]}" } -
TO TIG:
Thank you for your reply!
If I want to get the component's dynamic attributes(lenx, leny...) by multiple components collision detection?
and I will deduction of the overlapping area(multiple components) after...
(1)multiple components collision detection
(2)get the component's dynamic attributes(lenx, leny...)Thank you for your help!
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