sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    How to avoid generating line between joint?

    Scheduled Pinned Locked Moved Developers' Forum
    19 Posts 4 Posters 1.1k Views 4 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.
    • S Offline
      shirazbj
      last edited by

      Hi All,

      I use attached code to draw a ladder - two side bars joined by a few rungs at different levels.

      The problem is that there is a line between the joint of one side bar and the rungs. The joint at the other side doesn't has this line. The line means the two parts are not joint together and later will have error when I mesh them.

      Is there a way I can avoid generating this line?

      Thanks.

      Regards,

      Cean


      my_ladder.rb

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

        Why not wrap the code in a module or class and place the geometry in a group

        @group=model.active_entities.add_group
        @entities=@group.entities
        

        Since you have several def's use @entities etc so it always refers to the same group across all def's - you only need to define these once in the first running def.
        Then draw the sides and the rungs without pushpulling them [incidentally you only need the first 4 points for a rectangle the last one repeats the first and is not needed].
        Now when you have all of the shapes delete coplanar edges [in this case they are all 'coplanar' but only some of them have 2 faces] so you get one face to work with next...

        ###
        @entities.to_a.each{|e|e.erase! if e.valid? and e.class==Sketchup;;Edge and e.faces[1]}
        face=nil;@entities.to_a.each{|e|
          if e.class==Sketchup;;Face
            face=e
            break
          end#if
        }
        face.pushpull(-l*idir)
        ### etc
        

        You only need to do a model.start_operation("Ladder") once in the initial def and then do the model.commit_operation at the end of the last def...

        TIG

        1 Reply Last reply Reply Quote 0
        • utilerU Offline
          utiler
          last edited by

          Hi Cean, Can you not just delete the line you don't want? SU generally breaks lines at intersections so you should be able to just delete it.

          purpose/expression/purpose/....

          1 Reply Last reply Reply Quote 0
          • utilerU Offline
            utiler
            last edited by

            Are you sure both faces are coplaner? it appears in the photo the supports for the ladder are a little forward of the rungs; or maybe it's just the way the photo is showing it.

            One thing I learnt very early when using SU is that to make sure your drawing units are set appropriately for the modelling to be done. If there is no need for decimal places, set it right in the model settings tab. This will help with precision of the snapping function.

            purpose/expression/purpose/....

            1 Reply Last reply Reply Quote 0
            • S Offline
              shirazbj
              last edited by

              drawing attached to show where is the line


              my.gif

              1 Reply Last reply Reply Quote 0
              • S Offline
                shirazbj
                last edited by

                Hi Tig,

                Thanks for your suggestion. I am trying to understand all of that. I updated the program to draw the rungs in non- coplanar way. For this, I need to pushpull them seperately.

                Regards,

                Cean

                Hi Andrew,

                The real model I want is far more complicate than I showed here. There are much more unwanted lines like this. It's difficult to delete them all by hand and do it repeatly when I changed a parameter.

                Thanks


                ladder.gif

                1 Reply Last reply Reply Quote 0
                • S Offline
                  shirazbj
                  last edited by

                  The problem for that line is when I output a STL file, it generates a plane inside the geometry and stop me meshing for FEA simulation.

                  The photo showed here is after output STL file and viewed under GMSH.


                  mesh.gif

                  1 Reply Last reply Reply Quote 0
                  • S Offline
                    shirazbj
                    last edited by

                    Hi Andrew,

                    Tried the 'enable length snapping", seems no improvement.

                    The rung is assumed to be drawn on the surface of the left bar and end on the surface of right bar. But the two joints are shown in two different ways at two ends.

                    I was wondering if there is a 'Union' command I could use? Or the 'snapping' should look after this.

                    Regards,

                    Cean

                    1 Reply Last reply Reply Quote 0
                    • J Offline
                      Jim
                      last edited by

                      The easiest way to draw the ladder is using pushpull, but a side-effect is you having some lines you don't want. About the only alternative is to draw the shape using a mesh.

                      It might be easier to erase the lines afterward, rather than try to avoid drawing them in the first place.

                      Thom's excellent cleanup script might be of interest, however it won't delete the edges until the internal face has been removed.

                      Hi

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

                        As I said before...
                        Work inside a group.
                        Draw all of the faces at z=0...
                        Erase all edges with 2 faces [coplanar].
                        PushPull the one remaining face up as needed...
                        Result = 3D ladder with NO inner faces or stray edges... ❓

                        TIG

                        1 Reply Last reply Reply Quote 0
                        • S Offline
                          shirazbj
                          last edited by

                          Hi Tig,

                          As shown in my second photo, I made the rungs irregular in height. And I want the side bar and rungs made of PFC channel in real. So I have to extrude the side bar and rung in different direction seperately.

                          Regards,

                          Cean

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

                            No you don't ! πŸ˜’
                            First make a single 'ladder' face as I explained before... and extrude it up the maximum height.
                            Now add edges to form the rungs over the face at this topmost height, and PushPull the newly split off rung-face down to suit - at this point you won't get the internal faces problems - but you will get some coplanar edges formed on the sides where the rung is lowered... but when you are done you can test the group.entities.to_a for any edges that have edge.faces[1] - they all should - AND those whose faces are coplanar - edge.faces[0].normal==edge.faces[1].normal and .erase! them... You can of course add edges on the bottom face of the 'ladder' and PushPull those rungs up too, so that they then have no faces coplanar with the side members........
                            This is somewhat simplified outline, but it should give you the idea.

                            TIG

                            1 Reply Last reply Reply Quote 0
                            • S Offline
                              shirazbj
                              last edited by

                              I am trying to carve the ladder out from a big cube.

                              New code, new approch and new problem.


                              my_c_ladder.rb

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

                                Should work
                                @entities.to_a.each{|e|e.erase! if e.valid? and e.class==Sketchup::Edge and edge.faces[1] and edge.faces[0].normal==edge.faces[1].normal}
                                No need to ==true though.
                                but I notice you have some reversed faces so add a test like @entities.to_a.each{|e| e.erase! if e.valid? and e.class==Sketchup::Edge and edge.faces[1] and (edge.faces[0].normal==edge.faces[1].normal or edge.faces[0].normal.reverse==edge.faces[1].normal) }
                                What errors do you get ?

                                TIG

                                1 Reply Last reply Reply Quote 0
                                • S Offline
                                  shirazbj
                                  last edited by

                                  the PFC channel is not out.

                                  Not understand all this code below. Must be something wrong.

                                      @entities.to_a.each{|e|e.erase! if e.valid? and e.class==Sketchup;;Edge and edge.faces[1]==true and edge.faces[0].normal==edge.faces[1].normal}
                                  
                                  

                                  cut.gif

                                  1 Reply Last reply Reply Quote 0
                                  • S Offline
                                    shirazbj
                                    last edited by

                                    Now the problem is un-wanted face. I added labels on the photo.

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

                                      In order of your added notes...
                                      The part that is 'OK' has at least one face reversed the wrong way [blue] ?
                                      The part that isn't 'cutting though' - is the pushpull distance the same and the 'ctrl' key option set 'false' ? Also is the face you are pushpulling oriented the same way as the other one ?
                                      The thin end wall seems to arise because the pushpulled face is not exactly the same size and the hole you desire - so a thin 'rung' remains.
                                      To make the PFA profile... once all if the ladder's form is done you draw the profile of the desired 'hole' on the end face and pushpull it along the whole length until what's left is the PFA ???
                                      This should all be relatively straightforward. πŸ˜•
                                      Make it manually and then replicate the steps in your code - it's quite easy β˜€
                                      Capture.PNG

                                      TIG

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

                                        Hooray! I knew you could do it ! πŸ˜„

                                        TIG

                                        1 Reply Last reply Reply Quote 0
                                        • S Offline
                                          shirazbj
                                          last edited by

                                          Hi TIG,

                                          Finally made it and got my mesh.

                                          To cut through, need to cut from the opposite direction.
                                          To cut in (make a shell), need to cut from outside to inside.

                                          No need to do all the |e|e.erase! ... check.

                                          Thanks


                                          mesh.gif

                                          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