sketchucation logo sketchucation
    • Login
    1. Home
    2. simsimzone
    3. Posts
    โ„น๏ธ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
    S
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 5
    • Groups 1

    Posts

    Recent Best Controversial
    • RE: Merging two or more faces

      @tt_su said:

      Grouping and exploding will be very slow. And add_group with existing entities has been prone to erros and crashes.

      But Mr.tt-su, when I use entities.intersect_with it doesn't work, can you explain why?
      After all I'm using grouping just once because my plugin I'm creating right now is dealing with just two faces, not like the sample I gave.

      [EDIT]
      I'v tried your plugin and it seems it works only for a ready intersected in the model faces,
      if I have two faces say from my sample face1 and face2, then your plugin can't work on them unless they are intersected in the model first, if you draw two simple intersected rectangles in sketchup and say selected them, then you plugin can work, hope you get my point.

      My problem till now is that I have two intersected faces but they are not intersected with the model and I want to merge them.

      one option gave by TIG to use entities.intersect_with method but failed with me, I don't know exactly the arguments of this function.

      posted in Developers' Forum
      S
      simsimzone
    • RE: Merging two or more faces

      dears, I came up with simple method to merge faces:

      ` #f1,f2 are the input faces
      #returns the final merged face
      def union_faces (f1,f2)
      #return nil if !f1.coplanar_to?(f2)
      ent = Sketchup.active_model.entities
      g2 = ent.add_group([f1, f2])
      g1 = ent.add_group(g2)
      g2.explode()
      g1.entities.grep(Sketchup::Edge).each do |e|
      e.erase! if e.valid? && e.faces.length > 1
      end
      faces = g1.entities.grep(Sketchup::Face)
      ret = faces.first
      g1.explode()
      return ret
      end

      def test
      model = Sketchup.active_model
      ent = model.entities
      sel = model.selection
      face1 = ent.add_face([0, 0, 0], [1000, 0, 0], [1000, 200, 0], [0, 200, 0])
      face2 = ent.add_face([1000, 0, 0], [1200, 0, 0], [1200, 1000, 0], [1000, 1000, 0])
      union1 = union_faces(face1, face2)
      face3 = ent.add_face([0, 1000, 0], [1200, 1000, 0], [1200, 1200, 0], [0, 1200, 0])
      union2 = union_faces(union1, face3)
      face4 = ent.add_face([0, 200, 0], [200, 200, 0], [200, 1000, 0], [0, 1000, 0])
      union3 = union_faces(union2, face4)
      face5 = ent.add_face([1500, -1000, 0], [1700, -1000, 0], [1700, 2000, 0], [1500, 2000, 0])
      union4 = union_faces(union3, face5)
      sel.add(union4)
      end
      
      test()`
      

      I think Group.explode will heal and intersect with the parent.

      Please check my method and reply.. I didn't sleep last night ๐Ÿ˜ฒ

      posted in Developers' Forum
      S
      simsimzone
    • RE: Merging two or more faces

      I'v tried this: ๐Ÿ˜‰

      ` model = Sketchup.active_model
      ent = model.entities
      sel = model.selection
      g1 = ent.add_group()
      g2 = g1.entities.add_group()
      face1 = g2.entities.add_face(
      	[0, 0, 0], [20, 0, 0], [20, 20, 0], [0, 20, 0])
      face2 = g2.entities.add_face(
      	[5, -5, 0], [10, -5, 0], [10, 25, 0], [5, 25, 0])
      g2.explode()
      g1.entities.grep(Sketchup::Edge).each do |e|
      	e.erase! if e.faces.length > 1
      end
      g1.explode()`
      

      Here I put my faces in a group which is also inside another group, then exploded the inner group which did the trick and then did my logic to remove the unwanted edges, then arbitrarily exploded the outer group.

      posted in Developers' Forum
      S
      simsimzone
    • RE: Merging two or more faces

      Dear Mr. TIG:
      I'v already tried this, but everytime I run the script, it shows me a different result, sometimes right and sometimes wrong intersection.
      I really don't know why...

      posted in Developers' Forum
      S
      simsimzone
    • Merging two or more faces

      Dear guys, I have two questions:
      1- when I add faces using ent.add_face, and supposing their geometry are intersected,then they won't intersect. I'v noticed this by drawing intersected lines too, seems I'm missing some kind of lastly operation.

      2- suppose question 1 is unsolved, how to merge these two faces together to become one face instead.

      ` ent = Sketchup.active_model.entities
      face1 = ent.add_face([0, 0, 0], [20, 0, 0], [20, 20, 0], [0, 20, 0])
      face2 = ent.add_face([5, -5, 0], [10, -5, 0], [10, 25, 0], [5, 25, 0])`
      

      I want to call some function say:
      face3 = merge(face1, face2)

      posted in Developers' Forum
      S
      simsimzone
    • 1 / 1