sketchucation logo sketchucation
    • Login
    1. Home
    2. CEIT81729
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
    C
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 11
    • Posts 19
    • Groups 1

    CEIT81729

    @CEIT81729

    10
    Reputation
    1
    Profile views
    19
    Posts
    0
    Followers
    0
    Following
    Joined
    Last Online

    CEIT81729 Unfollow Follow
    registered-users

    Latest posts made by CEIT81729

    • RE: How to see the results of this method?

      But it seems no way to calculate the area...

      posted in Developers' Forum
      C
      CEIT81729
    • How to see the results of this method?
      def sum_area( material, entities, tr = Geom;;Transformation.new )
        area = 0.0
        for entity in entities
          if entity.is_a?( Sketchup;;Group )
            area += sum_area( material, entity.entities, tr * entity.transformation )
          elsif entity.is_a?( Sketchup;;ComponentInstance )
            area += sum_area( material, entity.definition.entities, tr * entity.transformation )
          elsif entity.is_a?( Sketchup;;Face ) && entity.material == material
            # (!) The area returned is the unscaled area of the definition.
            #     Use the combined transformation to calculate the correct area.
            #     (Sorry, I don't remember from the top of my head how one does that.)
            #
            # (!) Also not that this only takes into account materials on the front
            #     of faces. You must decide if you want to take into account the back
            #     size as well.
            area += entity.area
          end
        end
        area
      end
      

      Thank you for your help!

      posted in Developers' Forum
      C
      CEIT81729
    • How do I change this code?(deduct the overlapping area)

      I want to deduct the overlapping area between componentinstance and componentinstance in model.
      How do I change this code?
      Thank you for your help!

      mod = Sketchup.active_model # Open model
      ent = mod.entities # All entities in model
      sel = mod.selection # Current selection

      as = mod.definitions["column"].instances
      bs = mod.definitions["beam"].instances

      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 "column #{hit[0]} intersects beam #{hit[1]}" }


      00.skp

      posted in Developers' Forum
      C
      CEIT81729
    • RE: How do I change the code?

      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!

      posted in Developers' Forum
      C
      CEIT81729
    • How do I change the code?

      mod = Sketchup.active_model
      ent = mod.entities

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

      It can't run...
      How do I change the code?

      posted in Developers' Forum
      C
      CEIT81729
    • Collision Detection

      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

      posted in Developers' Forum
      C
      CEIT81729
    • How to detect collisions between ComponentInstance?

      Hello everyone

      How to detect collisions between ComponentInstance?

      e.g:
      if name = "column" all component collision name = "beam" all component
      do something...
      else
      do something...
      end

      Thank you for your answer!

      posted in Dynamic Components sketchup
      C
      CEIT81729
    • How to detect collisions between ComponentInstance?

      Hello everyone

      How to detect collisions between ComponentInstance?

      e.g:
      if name = "column" all component collision name = "beam" all component
      do something...
      else
      do something...
      end

      Thank you for your answer!

      posted in Developers' Forum
      C
      CEIT81729
    • Automatically Calculate the Component's Area and Volume

      Hello everyone:

      I want to know how to automatically calculate the component's area and volume in the dynamic attributes.

      p.s:Non-use formula input.

      Such as following example.

      Thank you for your answer. πŸ‘


      Component dynamic attributes

      posted in Developers' Forum
      C
      CEIT81729
    • Detect object intersect

      Hello everyone

      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]
      bb = Geom::BoundingBox.new.add(g.bounds.intersect(grp[i].bounds))
      if bb.valid?
      puts "#{g.name.to_s} and #{grp[i].name.to_s} intersect"
      else
      puts "#{g.name.to_s} and #{grp[i].name.to_s} do not intersect"
      end
      bb.clear
      }
      end

      I want to know how to calculate the model of dynamic properties of all objects (such as "Lenx", "Leny" ,"Lenz"...etc) after the object intersected the other object.

      The case description like this:

      First, detect all objects intersect situations like the above code
      Second, if name = "column" objects intersect name = "beam" objects(just a simple example)
      then, "column" objects dynamic properties("Lenx") deduction "beam" objects dynamic properties("Leny")

      Thank you for your advice and help πŸ‘


      Collision detection


      Objects dynamic properties

      posted in Developers' Forum
      C
      CEIT81729