sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    🫛 Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download

    Import dwg elements to Layer0

    Scheduled Pinned Locked Moved SketchUp Discussions
    sketchup
    14 Posts 6 Posters 610 Views 6 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.
    • pbacotP Offline
      pbacot
      last edited by

      I select the component and paste the script in ruby console. Nothing happens. The console returns:

      #<Sketchup;;Entities;0x007fde7b0884a8>
      

      MacOSX MojaveSketchUp Pro v19 Twilight v2 Thea v3 PowerCADD

      1 Reply Last reply Reply Quote 0
      • D Offline
        driven
        last edited by

        @pbacot said:

        I select the component and paste the script in ruby console. Nothing happens...

        Sam's script works on raw geometry...

        This one should drill down and gives a countdown as Status Text, so you know it's working...

        Tig's plugin is probably better and may be faster...

        
        ##---------------------------------------------------------------------------------------
        # move to Layer0
        t1 = Time.now
        model = Sketchup.active_model
        defs = model.definitions
        grps_comps =[]
        defs.each{|d|
                    next if d.image?
                    ins=[]
                    d.instances.each{|i|ins << i.name}
                    grps_comps << d.instances unless ins.empty?
                  }
        draw_elements = []
        count = 0
        grps_comps.each{|c| draw_elements << [c[0].definition.entities.find_all{|e| e.valid?}] }
        
        model.start_operation("move to 0")
        draw_elements.flatten!.each{|e|  count+=1
                        e.layer='Layer0'  rescue next
                        Sketchup;;set_status_text((" #{count} of #{draw_elements.length}" ),SB_PROMPT)
        # break if count == 10
                  }
          model.commit_operation
        
        puts Time.now - t1
        ##---------------------------------------------------------------------------------------
        

        john

        learn from the mistakes of others, you may not live long enough to make them all yourself...

        1 Reply Last reply Reply Quote 0
        • sdmitchS Offline
          sdmitch
          last edited by

          @pbacot said:

          I select the component and paste the script in ruby console. Nothing happens. The console returns:

          #<Sketchup;;Entities;0x007fde7b0884a8>
          

          Sorry, I took raw geometry to mean all entities not in a group or component. Also, the script works on the model not a selection.

          Since this is an import, I would assume that all definitions exist because at least one instance was created during the import process. Therefore, you should only need to modify the layer of the entities in the definition which will automatically redefine each instance.

          So, again for the model and not a selection

          Sketchup.active_model.definitions.each{|cd|cd.entities.each{|e|e.layer='Layer0'}}
          
          

          Nothing is worthless, it can always be used as a bad example.

          http://sdmitch.blogspot.com/

          1 Reply Last reply Reply Quote 0
          • pbacotP Offline
            pbacot
            last edited by

            Thanks! This seems to be working, but seems to have the same problem as "default layer" plugin. Taking a long time. I am running it while I have breakfast and see what happens. Wish there were a right way to use dwg files. SU is really behind in all aspects of working with these files.

            MacOSX MojaveSketchUp Pro v19 Twilight v2 Thea v3 PowerCADD

            1 Reply Last reply Reply Quote 0
            • D Offline
              driven
              last edited by

              @pbacot said:

              ...Taking a long time...

              it took about 18 minutes to do 297345 edges/faces in my test file...

              the problem is it has to find every one and move them one at a time...

              you could run it in the background and work on a different instance of SU, on a different model...

              I do that sometime when rendering, like they can on a PC...

              john

              learn from the mistakes of others, you may not live long enough to make them all yourself...

              1 Reply Last reply Reply Quote 0
              • cottyC Offline
                cotty
                last edited by

                Maybe (?) TIGs LayerWatcher can help here too?
                http://sketchucation.com/plugin/1496-tig_layerwatcher

                my SketchUp gallery

                1 Reply Last reply Reply Quote 0
                • BoxB Offline
                  Box
                  last edited by

                  No doubt cleaning up the DWG before import would help.

                  1 Reply Last reply Reply Quote 0
                  • pbacotP Offline
                    pbacot
                    last edited by

                    It took something like about that long.

                    I have times when I am importing my own work in dwg and I can do some things beforehand. How do you "cleanup" objects being on LayerO? with blocks on assigned layers in CAD? You can't really, if your CAD doesn't support that.

                    What would be best is that blocks keep their layers and entities import at layerO, just like SketchUp is supposed to be used. However the opposite is how SU makes imports.

                    The case I am working on is cleaning up someone file that was given to me. The third scenario is receiving a cad file from another source to import. Part of the "cleanup" should be automatic.

                    If one is just going to give up on the imported layers (for blocks-components) then the fastest thing to do is just delete the imported layers. Entities then go to Layer0 instantaneously.

                    MacOSX MojaveSketchUp Pro v19 Twilight v2 Thea v3 PowerCADD

                    1 Reply Last reply Reply Quote 0
                    • D Offline
                      driven
                      last edited by

                      Peter, if you PM me an example 'layered' dxf, there is an idea i would like to try...

                      may come to nothing...

                      john

                      learn from the mistakes of others, you may not live long enough to make them all yourself...

                      1 Reply Last reply Reply Quote 0
                      • srxS Offline
                        srx
                        last edited by

                        Have you try to import using FreeDXF plugin? It does great job with layers.

                        www.saurus.rs

                        1 Reply Last reply Reply Quote 0
                        • pbacotP Offline
                          pbacot
                          last edited by

                          No I haven't tried that plugin. I'll take a look. Usually I receive dwg files but I can ask for DXF. Peter

                          MacOSX MojaveSketchUp Pro v19 Twilight v2 Thea v3 PowerCADD

                          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