sketchucation logo sketchucation
    • Login
    โš ๏ธ Attention | Having issues with Sketchucation Tools 5? Report Here

    Intersecting 2 Groups Question

    Scheduled Pinned Locked Moved Developers' Forum
    13 Posts 3 Posters 371 Views 3 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.
    • K Offline
      kyyu
      last edited by

      @tig said:

      Try ent.intersect_with(true, tr, ent, tr, false, [face,lines])
      You do realize that the resulting geometry goes directly into the model's active_entities?
      Why no put that into a group - at least initially?
      Note, since it always returns 'nil' there's no point in assigning a reference to this operation with int=...

      Thanks, TIG. I haven't thought of it that way before, when trying to intersect two groups. That way worked. I used "intersect_with" with several past plugins, but still trying to understand it fully. Just doing some basic testing of general cases. So it doesn't matter, if the geomtry is simply going into the models's active_entities.

      It doesn't always return 'nil'. Your way returns the new edges. That paticular case I was asking about returns 'nil'. And didn't work, in certian situations, like I expected. But using face.entities as reciever also returns the new edges, and works exactly the way I expect. The only difference I can see is possibly face.entities has a face in there, whereas lines.entities doesn't? Using lines.entities as reciever seems to returns 'nil'.

      -Kwok

      1 Reply Last reply Reply Quote 0
      • TIGT Online
        TIG Moderator
        last edited by

        http://code.google.com/apis/sketchup/docs/ourdoc/entities.html#intersect_with says 'intersect_with' returns 'nil' always... ๐Ÿ˜•

        TIG

        1 Reply Last reply Reply Quote 0
        • K Offline
          kyyu
          last edited by

          @tig said:

          http://code.google.com/apis/sketchup/docs/ourdoc/entities.html#intersect_with says 'intersect_with' returns 'nil' always... ๐Ÿ˜•

          And we all know the are no mistakes in the API docs. ๐Ÿ˜› But seriously, I know in practice that it's not true. I have a plugin that slices up a solid and add the edges returned each time, into an array. Looks something like this:

          while @x < @total
          	int = intersect_with_plane(plane)
          	int.each do |i|
          		@@cary << i
          	end
          	@x += @inc
          	move_plane(plane, @inc)
          end
          
          def intersect_with_plane(plane)
          	t = Geom;;Transformation.new 
          	int = @@plane_ent.intersect_with(true, plane.transformation, @@ent, t, false, @@g)
          end
          
          1 Reply Last reply Reply Quote 0
          • TIGT Online
            TIG Moderator
            last edited by

            So you are saying that entities.intersect_with() return the geometry that's added ? ๐Ÿ˜•
            I have tested this and I can confirm that you are correct - geo=entities.intersect_with(.....) will return an array 'geo' of any newly made geometry - in direct contravention of what the API notes say ! ๐Ÿ˜ฎ
            Have you posted a comment in the API section ? ๐Ÿ˜’

            TIG

            1 Reply Last reply Reply Quote 0
            • K Offline
              kyyu
              last edited by

              @tig said:

              So you are saying that entities.intersect_with() return the geometry that's added ? ๐Ÿ˜•
              I have tested this and I can confirm that you are correct - geo=entities.intersect_with(.....) will return an array 'geo' of any newly made geometry - in direct contravention of what the API notes say ! ๐Ÿ˜ฎ
              Have you posted a comment in the API section ? ๐Ÿ˜’

              No I haven't posted a comment. I am a beginner, found the docs very confusing at the beginning and don't take them literally. In the past, I've had to test stuff to see what they actually do. Plus I sometimes figure(or partly figure) out something, then forget it and later have to relearn it. On top of that, I don't have a google account. I may be force to get one someday, but I don't like them trying to link to my youtube account. And some lame stuff they did, when I had google video. If I went and posted "It doesn't always return 'nil'", don't think that would be very useful.

              But I can show proof, with an example. You can use that test file I posted above and move the face group up onto the lines group. Then run this script. In the picture, I've selected the 37 edges that were created. You can see in the ruby console, an array was returned with 37 edges.

              model = Sketchup.active_model
              ent = model.entities
              sel = model.selection
              
              face = (ent.to_a.select {|e| e.is_a? Sketchup;;Group and e.name=="face"})[0]
              lines = (ent.to_a.select {|e| e.is_a? Sketchup;;Group and e.name=="lines"})[0]
              puts face; puts lines
              lent = lines.entities
              fent = face.entities
              tr = Geom;;Transformation.new
              ltr = lines.transformation
              ftr = face.transformation
              int = fent.intersect_with(true, ftr, ent, tr, false, lines)
              puts int
              puts int.class
              puts int.length
              

              int returning an array of edges.png

              1 Reply Last reply Reply Quote 0
              • TIGT Online
                TIG Moderator
                last edited by

                I posted an anonymous comment in the API.
                Put simply, the entities.intersect_with() method returns an array of the newly created geometry [faces/edges] or 'nil' if there is none, the guide is wrong as it says it returns 'nil' [always].

                TIG

                1 Reply Last reply Reply Quote 0
                • K Offline
                  kyyu
                  last edited by

                  Thanks, TIG. Lots of times, a beginner is not cofident enough to jump in there and make too many comments, even on this forum. Did you still need a google account, to post that anonymous comment in the API?

                  1 Reply Last reply Reply Quote 0
                  • TIGT Online
                    TIG Moderator
                    last edited by

                    I do have a Google account... but Google Apps has recently messed around with lots of accounts and settings... so I ended up being 'anonymous' anyway ๐Ÿ˜’

                    TIG

                    1 Reply Last reply Reply Quote 0
                    • jolranJ Offline
                      jolran
                      last edited by

                      Very interesting experiment and find. I wonder how missleading sometimes the API really is?
                      And what reference should beginners use if not the API?

                      1 Reply Last reply Reply Quote 0
                      • TIGT Online
                        TIG Moderator
                        last edited by

                        Use the API site but read the notes at the ends, as there are many corrections by users...
                        If in doubt ask in the Developers' forum - especially if you think you have found something odd.
                        Test your new tools methods in small steps so you can see what is returned or what is made at each step...

                        TIG

                        1 Reply Last reply Reply Quote 0
                        • jolranJ Offline
                          jolran
                          last edited by

                          OK. thanks. I have missed the notes part.

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

                          Advertisement