• Login
sketchucation logo sketchucation
  • Login
ℹ️ GoFundMe | Our friend Gus Robatto needs some help in a challenging time Learn More

[Plugin] Hatchfaces (v1.8 beta) UPDATED 15-Dec-2012

Scheduled Pinned Locked Moved Plugins
360 Posts 41 Posters 228.5k Views
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.
  • J Offline
    jolran
    last edited by 16 Aug 2011, 14:48

    Much better TIG!
    There are still some issues. Pic says all. Now I was gonna put this "is as" a method at the end no, passing arguments? There won't be any problem with putting declarations inside a method I persume. I mean for ex model=Sketchup.active_model..

    It works perfectly on Y axis. X axis it flips upside down. Off axis, a little troublesome..

    The definition has quite a lot of transformations πŸ˜„ might take a while before I understand what's going on, and can track issues.

    Performance is good. Havent tested on super heavy geometry.


    cutmethod2.jpg

    1 Reply Last reply Reply Quote 0
    • J Offline
      jolran
      last edited by 16 Aug 2011, 16:58

      Going through your script trying to get a grasp on it. It's comparing axis to vectors a lot, no? I wonder would it be more predictable to use crossproducts where possible? I don't know, from for ex face.normal? Just a wild guess.

      1 Reply Last reply Reply Quote 0
      • J Offline
        jolran
        last edited by 16 Aug 2011, 17:58

        Talking to myself mostly... Another pic(will delete older pics later on, in case I'm overusing this function a little to much).

        I think we are hitting some bug here. Isent this strange behavior?


        comp_behavior2.jpg

        1 Reply Last reply Reply Quote 0
        • J Offline
          jolran
          last edited by 16 Aug 2011, 17:59

          TIG, yes I got true on all of those.

          Did a little test! Placed the face at origin and the component on top. Changed the transformation to 0 rotation=NO transformation. Transformation is not needed when placed on ORIGIN, of course. Did the test on both the created component instance, and on a new freshly inserted instance. And voila it glues, and cuts the face.

          Test nr2 I removed ANY transformation made on the component, (after group.to_component).Still on ORIGIN.
          And it worked as well??? Of course this only works when the component is lying flat at 0 position.

          Is this some sort of bug? Cause I get the impression you can only invoke cutting behavior IF you do it on 0,0,0 and 0 rotation= ORIGIN ❓

          Maybe the problem has to do with what position you create the component from group(group.to_component).
          And it's position relative to insertion-point.

          SO what's the fix? Transform the group to ORIGIN. Make the comp and remove it back to where it was?
          Seams a very strange solution but can't figure out the logic in this one..

          I guess just have to find a transformation that get the group to origin flat from ALL postions, do the behavior and transform back with an inversion of that transformation.

          **Edited:**As it turns out TIG's rotation transformation is all that's needed(first rotation), if it only get's translated to the ground at 0.
          Now, this must be done in 1 transformation OR multiplied because I am going to use THIS transformation.inverted to get back to the face. PFFIooUUH. Don't have a grasp of this transformation stuff yet. It's quite complex to understand when doing multiple transformation's.

          1 Reply Last reply Reply Quote 0
          • T Offline
            TIG Moderator
            last edited by 16 Aug 2011, 17:59

            I'm absolutely sure we can streamline this code a lot - I threw it together to show it was 'do-able'...........

            TIG

            1 Reply Last reply Reply Quote 0
            • J Offline
              jolran
              last edited by 16 Aug 2011, 17:59

              I trying to understand what you are getting at. πŸ˜„ The cutting behavior is still not working.
              Unless face is on "ground" an I apply NO transformation or O rotation(same thing).

              Blue Z axis should point in the face.normal direction? To have a chance invoking inst.glued_to=face
              Well It does, after your rotations, and the instance is glued to the face.

              But must not the World axis origin be at the instance to get cutting behavior?

              To do that: move group to global(world?) origin. Reset any rotations= group made flat. THEN make instance from group and move back to face?? I know it sounds strange but why is the inputpoint at orgin if inserting an instance(copy) of the result?

              1 Reply Last reply Reply Quote 0
              • J Offline
                jolran
                last edited by 16 Aug 2011, 18:00

                Are you testing at ORIGIN by a chance? Or does it work for you in all positions? Another pic..

                EDITED After some rigorous testing, I have a strong feeling the entities inside the group is off according to the group. Must experiment more with rotation axis etc, but time is running out for this.. Must move on.
                Give it another day..

                1 Reply Last reply Reply Quote 0
                • T Offline
                  TIG Moderator
                  last edited by 16 Aug 2011, 18:01

                  You seem to be invoking it at a weird point - use it after all of the other processes leave the exploded-instances/trimmed group...

                  TIG

                  1 Reply Last reply Reply Quote 0
                  • J Offline
                    jolran
                    last edited by 16 Aug 2011, 18:15

                    @unknownuser said:

                    I threw it together to show it was 'do-able'...........quote]

                    πŸ˜„

                    @unknownuser said:

                    I'm absolutely sure we can streamline this code a lot -

                    Honestly, I don't know if I can be of much assistance in that regard. There's so much going on with rotations and stuff I get a migraine. I can of course try, but just by touching the computer you will beat me to it πŸ˜„

                    So, you don't think theres any trouble in the starting of the script, where I create the instances from definition?

                    Do you want my sample W.I.P code to see if there is trouble elsewhere? It's without menys and linehatching..
                    And quite documented..

                    @unknownuser said:

                    You seem to be invoking it at a weird point

                    I don't know. At the end? As a definition passing group and face. Maybe thats wrong timing..

                    1 Reply Last reply Reply Quote 0
                    • T Offline
                      TIG Moderator
                      last edited by 17 Aug 2011, 12:32

                      Here's some shorter updated code that I think now works better to make a selected 'group' that has its faces overlaid onto a 'face' into a cutting component...

                      ### turns the 'group' into a component glued/cutting 'face'
                      def g2cut(group, face)
                        ###
                        model=Sketchup.active_model
                        ###
                        model.start_operation('g2cut')
                        ents=model.entities
                        gents=group.entities
                        bbc=group.bounds.center
                        norm=face.normal
                        ve=group.transformation.origin.vector_to(bbc)
                        tr=Geom;;Transformation.translation(ve)
                        group.transform!(tr)
                        tr=Geom;;Transformation.translation(ve.reverse)
                        gents.transform_entities(tr, gents.to_a)### centered
                        tr=Geom;;Transformation.new(bbc, norm)
                        group.transform!(tr)
                        gents.transform_entities(tr.inverse, gents.to_a)
                        ve=group.transformation.origin.vector_to(bbc)
                        tr=Geom;;Transformation.translation(ve)
                        group.transform!(tr)
                        ve=ORIGIN.vector_to(bbc)
                        ve.transform!(group.transformation.inverse)
                        tr=Geom;;Transformation.new(ve)
                        gents.transform_entities(tr, gents.to_a)
                        ### make component
                        inst=group.to_component
                        defn=inst.definition
                        be=defn.behavior
                        be.is2d=true
                        be.cuts_opening=true
                        be.snapto=0
                        inst.glued_to=face
                        ###
                        ### complete these items...
                        #defn.name=
                        #inst.name=
                        #inst.layer=
                        ###
                        model.commit_operation
                        ###
                      end
                      ###
                      

                      Please try it out... again remember that you don't need the start/commit operation parts IF it's to be embedded into a wider set of code...

                      TIG

                      1 Reply Last reply Reply Quote 0
                      • J Offline
                        jolran
                        last edited by 17 Aug 2011, 15:33

                        After some testing. I've only had 1 incident so far when the axis.center wasn't on face, on an extreme angle. Otherwise it seams to be working πŸ˜„

                        Now, when axis align better on face(thanks to TIG), one can explode and the materials merge on face underneath more consistent.

                        It's a perfect modeling tool. 😲
                        Textures will transfer as well. And I suppose the option of saving a component with textures gives many possibilities.
                        There are some experiments to be made, to see what can be done....

                        1 Reply Last reply Reply Quote 0
                        • J Offline
                          jolran
                          last edited by 22 Aug 2011, 07:35

                          A lot of experiments going on. I welcome ideas and possible options that could be added or improved πŸ’­
                          look at the dialogs what is planned, already.

                          Got the tiling going pretty nicely. (Not from file yet) It's quite slow if having complex patterns. Fewer (tile) copies is considerably faster regardless of the sum of edges πŸ˜• So crosshatching may be restricted to linehatches only. Rather create more patterns=larger library than doing a 2nd computation? Patterns with faces is slowest.

                          Since the goal is to have a big library of hatches, they may be difficult to remember by name. So I guess webdialog is the best solution. Im not to sure about that one yet, though. Havent done any webdialogs, yet. It might be a very step learning curve to get it right for all plattforms ❓ On the pic there is a inputbox version with dropdownlist. For round 1 that might be the solution, there are a lot of quirks to sort out first..

                          http://sketchupapi.blogspot.com/2011/07/gofaster-parameter.html
                          FYI: saw this post on API blog and performed som tests with this method(not the pic, more complex pattern), and boy what an speed increase!
                          On test 1: 5.226 seconds
                          On test 2: 2.793 seconds! Just typing "true" in the model.start_operation('bla bla', true)
                          On test 3: 2.496 seconds. Same test as 2, but outliner closed.

                          There are some issues with this method though..

                          http://forums.sketchucation.com/viewtopic.php?f=180&t=25305

                          This is of course interesting as well. But maybe before doing any performance increases I will work on the features.


                          dialogs.jpg

                          1 Reply Last reply Reply Quote 0
                          • J Offline
                            jolran
                            last edited by 22 Aug 2011, 11:17

                            Excellent TIG!

                            So far so good! Havent failed yet. Works in off axis, strange rotations etc.

                            Needs some more testing of course, but THANK YOU! THANK YOU!
                            Things can probably move forward now.

                            Oh Yeah, and the code is much more streamlined, as you call it. πŸ‘

                            1 Reply Last reply Reply Quote 0
                            • K Offline
                              kaas
                              last edited by 23 Aug 2011, 09:34

                              Hello Jolran,

                              First of all; thanks again a million for your effort and to those who are helping you! It's a much much welcomed addition to Sketchup! I can't wait to test it out! πŸ‘

                              I think your Photoshop dialog already has all the options we could want. Maybe you could add a target layer-option for the hatches? The visual webdailog of course would be the most user-friendly but I wouldn't mind the non-visual dialog. You could always print out the patterns + names on a sheet of paper instead.

                              @jolran said:

                              Got the tiling going pretty nicely. (Not from file yet) It's quite slow if having complex patterns.

                              I wouldn't be too much concerned with the performance. The time for the calculation of hatches will be much less compared to having to draw them yourself by hand! The plugin itself always be a great time-saver and will save us from dull repetitive work.

                              Greetings,

                              Max

                              1 Reply Last reply Reply Quote 0
                              • J Offline
                                jolran
                                last edited by 23 Aug 2011, 10:57

                                Hi Kaas!

                                Finaly someone answered πŸ˜„

                                @unknownuser said:

                                Maybe you could add a target layer-option for the hatches?

                                That should be possible. You do mean put the hatch in a layer already existing in the model?
                                Anyway I think layers are pretty flexible to work with.

                                @unknownuser said:

                                You could always print out the patterns + names on a sheet of paper instead.

                                That is a good solution, if going for inputboxes. I guess file browser is also possible, like TIG's 2d tools hatches.

                                Thank you for the inputs, and please don't hesitate to add more requests.

                                1 Reply Last reply Reply Quote 0
                                • K Offline
                                  kaas
                                  last edited by 23 Aug 2011, 11:58

                                  @jolran said:

                                  You do mean put the hatch in a layer already existing in the model?

                                  Yes. Most people will work with a template file which already contains standard layers, styles, scenes etc. I guess there is no need to over-complicate the code at this stage for adding new layers on the fly.

                                  1 Reply Last reply Reply Quote 0
                                  • J Offline
                                    jolran
                                    last edited by 23 Aug 2011, 13:52

                                    @unknownuser said:

                                    I guess there is no need to over-complicate the code at this stage for adding new layers on the fly.

                                    I don't swear by it, but it should be relatively straightforward to get a list of layers pop up in the inputbox.
                                    I think it is a good idea you have, otherwise ALL hatches will end up into 1 layer unless moved manualy.
                                    Putting "hatchlayer" as default in inputbox means one won't have to select layers if happy with that layer.

                                    I put this on the todo list πŸ˜„

                                    1 Reply Last reply Reply Quote 0
                                    • J Offline
                                      jolran
                                      last edited by 9 Sept 2011, 19:26

                                      Good evening.

                                      Things are moving forward, but have been hooked on webdialogs and speed performance lately.

                                      All in all, all features I can think of is implemented. Loading from file and tiling with some options to it, is ok.(not from some dialog, in script)

                                      The "tech" part:
                                      Some sort of dialog has to be made. I'm thinking webdialog, but quite scared of diving into that part actually πŸ˜•
                                      But it will be difficult using dropdownlist with a long list. And I don't know if a list can be updated automatically if user add new components ❓ I guess UI.openpanel can only be used for images?

                                      Also performance is an issue.. Things can get quite slow sometimes, maybe to slow..

                                      The plugin tiles the group in 1 direction inside group1. Then it copies group1 in the cross direction.

                                      Copying groups are fast. Exploding and intersections is slow. I don't know if there is any way to speed up thoose things.
                                      Is there any way to copy and tile entities collection without using groups ❓

                                      Have also been experimenting with textures+lines combinations to "get away" with less geometry, but the result is less then satisfactory. Look pics:

                                      More artistic questions arise, what is needed from hatches anyway?
                                      Have been looking for ISO standards but can't find information regarding exact size of patterns. If you look at Doublecad for ex. When creating a hatch, the sizes of pattern often need to be adjusted. So what is the scaling standards? This could be of importance regarding speed. Cause, the bigger patter=less geometry >> speed increase.

                                      Any tips would be welcome. πŸ˜„


                                      texvsvector.jpg

                                      1 Reply Last reply Reply Quote 0
                                      • T Offline
                                        TIG Moderator
                                        last edited by 9 Sept 2011, 22:26

                                        If you go down the texture route then my 2dTools '2dHatching' already does much of this [without scaling etc]... with a fairly comprehensive list of tileable .PATT clone .jpg files...

                                        TIG

                                        1 Reply Last reply Reply Quote 0
                                        • J Offline
                                          jolran
                                          last edited by 10 Sept 2011, 06:54

                                          Yeah, thanks. I have been looking at your plugin, TIG. There is no point in reinventing the wheel that's rolling well, so I will go the "line hatching" way. If it wasen't clear, I'm not convinced textures are good enough for CD's. Inconsistency in line widths..

                                          So far as I can see, 2dtools imports a jpg texture, while hatchfaces will be working with skp.files.
                                          And if I understand API docs right, you can only use images for UI:openpanel.

                                          The strategy I'm having is to have 1 color method for linehatching and another non-color method.
                                          Non color method will be standard-mode, and it's there where I aim to increase speed somehow.

                                          πŸ’­ Plan A is to find a solution to create all edges inside 1 group without the need for exploding, then use face-classify to remove unwanted edges.

                                          Plan B is create groups, intersect with face-clone(gents) and remove unwanted edges with face-classify points. That way there is no need to explode large amounts of groups. But intersection can be quite slow...

                                          Plan A need some thinking, and there is quite a lot of unnecessary geometry created as well. A big square, size of diagonal to compensate for rotations around center...
                                          It's difficult to do rotations prior to tiling. Unless doing zick-zack copying πŸ˜•

                                          1 Reply Last reply Reply Quote 0
                                          • 1
                                          • 2
                                          • 10
                                          • 11
                                          • 12
                                          • 13
                                          • 14
                                          • 17
                                          • 18
                                          • 12 / 18
                                          • First post
                                            Last post
                                          Buy SketchPlus
                                          Buy SUbD
                                          Buy WrapR
                                          Buy eBook
                                          Buy Modelur
                                          Buy Vertex Tools
                                          Buy SketchCuisine
                                          Buy FormFonts

                                          Advertisement