sketchucation logo sketchucation
    • Login
    πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Faces to components problem

    Scheduled Pinned Locked Moved Developers' Forum
    15 Posts 4 Posters 1.9k 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.
    • O Offline
      oalexis
      last edited by

      Hi I was wondering if there was an upper limit to Chris fullmer's Faces to components plugin? I'm trying to use it on a model with under 2000 tris and it keeps crashing SU. I'll attach the model so maybe someone can play around with it and see why its not working


      UAVcrysis.skp

      1 Reply Last reply Reply Quote 0
      • Chris FullmerC Offline
        Chris Fullmer
        last edited by

        More than likely its a problem with my scripting.

        I'll take a look at it and see what I find,

        Chris

        Lately you've been tan, suspicious for the winter.
        All my Plugins I've written

        1 Reply Last reply Reply Quote 0
        • O Offline
          oalexis
          last edited by

          Thanks for the swift response πŸ˜„ I hope you can figure it out. Its pretty hard to UV map in SU without your plugin

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

            Running any script that makes multiple components or groups etc will fall over if the Outliner window is open and not 'rolled up' = known bug with Outliner... Check the tool with no Outliner open ?

            TIG

            1 Reply Last reply Reply Quote 0
            • O Offline
              oalexis
              last edited by

              thats not it TIG, I never use outliner so its never open

              1 Reply Last reply Reply Quote 0
              • Chris FullmerC Offline
                Chris Fullmer
                last edited by

                I also don't have the outliner open, and it still crashes.

                If you wanted to look quickly at ths code TIG I'd be quite happy. I'm pretty sure I've narroed the problem down to the loop that adds each face to a group and then turns the group into a component.

                I really have not kept up with all the group and component snippets that have been written recently. So perhaps you have a snippet that would work better than:

                faces.each do |e|
                group = entities.add_group( e )
                group.to_component
                end
                

                Because that is scrashing on this model. And interestingly, it doesn't crash on the first face. IT normally processes 10 to 20 faces, then crashes. So far I have not figured out what the problem is 😞

                Chris

                Lately you've been tan, suspicious for the winter.
                All my Plugins I've written

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

                  I don't have a copy of the full code, BUT...

                  
                  faces.each do |e|
                    group = entities.add_group( e )
                    group.to_component 
                  end
                  
                  

                  Might be the problem ! It destroys the entities face/edges etc as you go ?
                  So some things disappear before you can process them !
                  Try something like this... assuming 'entities=model.active_entities' etc are predefined...

                  
                  groups2process=[]
                  edges2go=[]
                  ### first we 'clone' the faces...
                  faces.each{|face|
                    points=[]; face.vertices.each{|v|points<<v.position}
                    group=entities.add_group()
                    face2=group.entities.add_face(points)
                    face2.reverse! if face2.normal != face.normal
                    face2.material=face.material
                    face2.back_material=face.back_material
                    ### also clone attributes etc - you add this...
                    ### also clone materials/attributes of edges etc - you do this...
                    groups2process<<group
                    ### stuff to go...
                    edges2go<<face.edges
                    face.erase! ### it's now in the group
                  }
                  edges2go.uniq!
                  edges2go.each{|e|e.erase! if e.valid? and e.faces.length==0}
                  groups2process.each{|group|group.to_component}
                  ### this should process tidily... ;) 
                  
                  

                  TIG

                  1 Reply Last reply Reply Quote 0
                  • O Offline
                    oalexis
                    last edited by

                    anyway to put that back into the plugin? I have no idea how to use ruby... πŸ˜•

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

                      Made a few tweaks to the untested code and added undo and counter etc...

                      This quick ruby file makes 'selected faces into components' - put the file into your plugins folder, open the model, select the faces and type 'selectedfaces2components' in the ruby console...selectedfaces2components.rb

                      TIG

                      1 Reply Last reply Reply Quote 0
                      • Chris FullmerC Offline
                        Chris Fullmer
                        last edited by

                        ok, I've also tried to update my code and I think it is improved. I'm not sure if its perfect. But perhaps its better? It seems to work on the UAV model now. But if TIG's is working well, you might just stick with it. I think he re-creates your geometry, whereas I am moving the original into the components (which is not recommended, but it seems to work here). Any, hope it helps.

                        Chris


                        v 1.2

                        Lately you've been tan, suspicious for the winter.
                        All my Plugins I've written

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

                          @chris fullmer said:

                          ok, I've also tried to update my code and I think it is improved. I'm not sure if its perfect. But perhaps its better? It seems to work on the UAV model now. But if TIG's is working well, you might just stick with it. I think he re-creates your geometry, whereas I am moving the original into the components (which is not recommended, but it seems to work here). Any, hope it helps.
                          Chris

                          You can move entities wholesale into a group:
                          model.active_entities.add_group(required_entities)
                          BUT they must include 'all_connected' geometry that's 'sensitive' to the 'move' into the group - otherwise you run the risk of perhaps moving a face into a group and not its edges, if it takes its edges they might have other connected faces, then these they are screwed by loosing an edge etc etc...

                          So the safest way is to do something like this: where you group the required_stuff AND its all_connected, copy that group, explode one and then throw away everything that's in the remaining group that's not needed - e.g. keep required_stuff AND any faces' edges etc they are not in the set already...

                          TIG

                          1 Reply Last reply Reply Quote 0
                          • honoluludesktopH Offline
                            honoluludesktop
                            last edited by

                            TIG, I hacked your code to add a right click menu choice. I have a little programing expierence, but don't know Ruby. Do you mind if I mess with it in this way?

                            If thats OK with you, can you show me how to end up with one big component, or group made up of individual faces rather then all the seperate components?


                            This is the modified code

                            1 Reply Last reply Reply Quote 0
                            • honoluludesktopH Offline
                              honoluludesktop
                              last edited by

                              TIG, Thanks, Even at my rate (slow), I'll eventually learn some Ruby, and the SU API:-)

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

                                @honoluludesktop said:

                                TIG, I hacked your code to add a right click menu choice. I have a little programing expierence, but don't know Ruby. Do you mind if I mess with it in this way?
                                If that's OK with you, can you show me how to end up with one big component, or group made up of individual faces rather then all the separate components?

                                Hack as much as you want, but please ensure that any of your versions that 'get out' have explanatory text in them so as to apportion blame πŸ˜‰ and not confuse the user πŸ˜•

                                If you look at the code... We loop through each of the faces - first we add an empty group to the model.active_entities and then clone the face with it's properties into that group, then we erase the original face - remembering to leave any shared edges. Finally that group in made into the component.

                                To change it so that each of the face-group-components is added into a super-group change the lines to read

                                
                                ### outside of the loop we make a new 'supergroup'
                                supergroup=model.active_entities.add_group()
                                supergroup_entities=supergroup.entities
                                ### later in the loop for each face we change the group's 'destination'...
                                group=supergroup_entities.add_group()
                                ### rather than the previous 'model.active_entities'
                                ### etc
                                
                                

                                Now all of the face-groups [which are now actually separate components] are inside a 'super_group'.
                                At the end you can name that or change it into a component itself, thus...

                                
                                supergroup_component=supergroup.to_component
                                supergroup_component.definition.name="Face_SuperGroup#1"
                                supergroup_component.name=supergroup_component.definition.name
                                
                                

                                πŸ€“

                                TIG

                                1 Reply Last reply Reply Quote 0
                                • O Offline
                                  oalexis
                                  last edited by

                                  thanks for your help on this guys, the right click option that you made honolulu doesn't seem to work on my computer but Chris, your updated code works so thank you very much πŸ˜„

                                  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