• Login
sketchucation logo sketchucation
  • Login
⚠️ Libfredo 15.4b | Minor release with bugfixes and improvements Update

Select All Surfaces in a Model? Need assistance.

Scheduled Pinned Locked Moved Developers' Forum
10 Posts 3 Posters 1.1k 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.
  • J Offline
    JClements
    last edited by JClements 4 Jan 2008, 20:30

    I have a project in which I will be exporting my 3D model to AutoCAD. I am using the 3D export option because it maintains components (as blocks), circles, arcs, dimensions, leaders, layers, and editable text.

    However, "Faces in SketchUp are exported as a triangulated polyface meshwith interior splframe hidden lines (if applicable). This conversion helps to simulate the appearance of your native SketchUp file, even when all exported faces are triangular".

    I would like to export just the edge-entities, not the faces. Does someone have a script the will dig down through the entire model (into all nested entities), select the faces, and delete the faces (so they can't be exported).

    My methodology would be to: save the SU model, run the script, export the 3D model, and then either do a Restore or an Undo.

    John | Illustrator | Beaverton, Oregon

    1 Reply Last reply Reply Quote 0
    • G Offline
      gksl4
      last edited by 4 Jan 2008, 23:37

      There is a ruby script desel.rb at http://www.crai.archi.fr/RubyLibraryDepot/Ruby/em_sel_page.htm
      thanks to TBD

      1 Reply Last reply Reply Quote 0
      • F Offline
        fredo6
        last edited by 5 Jan 2008, 09:01

        Here is a simple code to select all faces at the model level

        
        def select_all_faces
                model = Sketchup.active_model
                model.selection.clear	#empty the current selection
                model.entities.each { |e| model.selection.add e if e.typename == 'Face' }
        end
        
        

        Note that you cannot select entities at different levels, for instance in the first level of the model and at the same time within groups or component instances

        1 Reply Last reply Reply Quote 0
        • J Offline
          JClements
          last edited by 5 Jan 2008, 09:12

          Fredo,

          then could the above be adapted to select all faces on the upper level, delete those faces and then edit each entity in the next level of nested entities, select and delete their faces, and then to the next level of nested entities and so on?

          John | Illustrator | Beaverton, Oregon

          1 Reply Last reply Reply Quote 0
          • F Offline
            fredo6
            last edited by 5 Jan 2008, 09:26

            If you need to earse all faces at all levels, then you must do it differently
            Here is a code sample

            
            def process_faces
            	model = Sketchup.active_model
            	model.start_operation "erase all faces"
            	process_faces_at_level model, {}
            	model.commit_operation
            end
            
            def process_faces_at_level(grp, hcomp)
            	list_entities = []
            	grp.entities.each do |entity| 
            		case entity.typename
            		when 'Group'
            			process_faces_at_level entity, hcomp
            		when 'ComponentInstance'
                                    edef = entity.definition
            			next if hcomp[edef.to_s]
            			hcomp[edef] = edef
            			process_faces_at_level edef, hcomp
            		when 'Face'
            			list_entities.push entity  # store faces in the list
            		end
            	end
            	grp.entities.erase_entities list_entities #or do what you want with the faces
            end	
            
            

            Note the specific treatment of component instances, as you must delete the face only once in its definition (which will propagate then to all instances)

            1 Reply Last reply Reply Quote 0
            • J Offline
              JClements
              last edited by 5 Jan 2008, 17:48

              Fred:

              Thank you for the code. Not only did it work, but it seemed to do so fast. :}

              One more request.

              In some models, I will want to retain the faces of any smoothed surfaces (such as those made via Push-Pull, Follow-Me, or manually softed) so I believe any Softened or Smoothed edges would have to be Unsoftened and Unsmoothed first before finding and deleting faces.

              Can you add code for an option to do this?

              John | Illustrator | Beaverton, Oregon

              1 Reply Last reply Reply Quote 0
              • F Offline
                fredo6
                last edited by 5 Jan 2008, 19:55

                I am not clear on what you want.
                Do you want to keep faces which have at least one edge smoothend or softened?
                Or do you want to change the property of these edges, and still erase all faces?

                1 Reply Last reply Reply Quote 0
                • F Offline
                  fredo6
                  last edited by 5 Jan 2008, 22:13

                  Then you need to add one line of code (in the When 'Face' section)to change the "soft" property of the edges bording the faces. This slows down the script a little bit, but I undersatnd why you need it.

                  
                  def process_faces
                  	model = Sketchup.active_model
                  	model.start_operation "erase all faces"
                  	process_faces_at_level model, {}
                  	model.commit_operation
                  end
                  
                  def process_faces_at_level(grp, hcomp)
                  	list_entities = []
                  	grp.entities.each do |entity| 
                  		case entity.typename
                  		when 'Group'
                  			process_faces_at_level entity, hcomp
                  		when 'ComponentInstance'
                  			edef = entity.definition
                  			next if hcomp[edef.to_s]
                  			hcomp[edef.to_s] = edef
                  			process_faces_at_level edef, hcomp
                  		when 'Face'
                  			list_entities.push entity  # or do what you want with the face
                  			entity.edges.each { |e| e.soft = false } #Keep smooth edges
                  		end
                  	end
                  	grp.entities.erase_entities list_entities
                  end	
                  
                  
                  
                  1 Reply Last reply Reply Quote 0
                  • J Offline
                    JClements
                    last edited by 6 Jan 2008, 02:16

                    Fred:

                    Worked again. Many thanks.

                    John

                    John | Illustrator | Beaverton, Oregon

                    1 Reply Last reply Reply Quote 0
                    • J Offline
                      JClements
                      last edited by 6 Mar 2008, 07:22

                      Change the property of these edges so that when their respective faces are delected, the edges remain.

                      John | Illustrator | Beaverton, Oregon

                      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