• Login
sketchucation logo sketchucation
  • Login
🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Collision Detection

Scheduled Pinned Locked Moved Developers' Forum
1 Posts 1 Posters 568 Views 1 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    CEIT81729
    last edited by 2 Nov 2015, 09:09

    Hello everyone

    The following figure...
    a and b intersect
    b and c intersect
    a and c not intersect

    I 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_cm

    q = 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


    01.jpg


    11.skp

    1 Reply Last reply Reply Quote 0
    • 1 / 1
    1 / 1
    • First post
      1/1
      Last post
    Buy SketchPlus
    Buy SUbD
    Buy WrapR
    Buy eBook
    Buy Modelur
    Buy Vertex Tools
    Buy SketchCuisine
    Buy FormFonts

    Advertisement