• Login
sketchucation logo sketchucation
  • Login
🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

How to delete a model imported from *.dae file by ruby.

Scheduled Pinned Locked Moved SketchUp Discussions
sketchup
4 Posts 3 Posters 558 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.
  • Y Offline
    yuyuwhy
    last edited by 15 Jan 2015, 14:19

    I have many *.dae files (about 10 thousand) that must be purged in SketchUp. So I write a plugin to deal with the *.dae files. How to delete a imported model in ruby?

    Here is my ruby scripts, but the code doesn't have any effects.

    model = Sketchup.active_model
    entities = model.active_entities
    entities.each { |singleEntity|
    entities.erase_entities singleEntity
    }

    1 Reply Last reply Reply Quote 0
    • D Offline
      driven
      last edited by 15 Jan 2015, 19:47

      what are you actually doing?

      open new drawing...
      import dae, purge, export purged dae...

      2.times{Sketchup.send_action('editUndo;')}
      

      start again...
      maybe you don't even need the 2.times....

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

      1 Reply Last reply Reply Quote 0
      • Y Offline
        yuyuwhy
        last edited by 16 Jan 2015, 00:10

        @driven said:

        what are you actually doing?

        open new drawing...
        import dae, purge, export purged dae...

        2.times{Sketchup.send_action('editUndo;')}
        

        start again...
        maybe you don't even need the 2.times....

        yes, I just need to keep repeating the process: import a dae , purge, export purged dae, and deal with the next dae.

        thank you very much...
        👍

        1 Reply Last reply Reply Quote 0
        • T Online
          TIG Moderator
          last edited by 16 Jan 2015, 13:47

          Start off by clearing everything, by using:
          model = Sketchup.active_model model.entities.clear!
          then purge the model using:
          model.definitions.purge_unused model.active_layer=model.layers[0]; model.layers.purge_unused model.materials.current=nil; model.materials.purge_unused model.styles.purge_unused ds = model.attribute_dictionaries; ds.to_a.each{|d| ds.delete(d) } if ds
          Now you have an empty SKP.

          Try doing the import AND export within a model.start_operation(...) block, BUT do not ' commit' it, rather you need to ' abort' it after each one.
          That way the import happens, the export happens but the changes to the model are undone by each ' abort'. The exported file is NOT undone by the ' abort' !

          TIG

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          1 / 1
          • First post
            3/4
            Last post
          Buy SketchPlus
          Buy SUbD
          Buy WrapR
          Buy eBook
          Buy Modelur
          Buy Vertex Tools
          Buy SketchCuisine
          Buy FormFonts

          Advertisement