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

    Styles Class method Inquiry

    Scheduled Pinned Locked Moved Developers' Forum
    7 Posts 3 Posters 394 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.
    • W Offline
      wehby
      last edited by

      In the ruby doc for the Styles Class (http://groups.google.com/group/SketchUp-Plugins-Dev/web/Ruby-Style.html), I did not see an erase method. Is one inherited?

      Right now, the only way that I can see to delete a style using Ruby is to do the following:

      1. Create a temporary Scene for any style that you want to keep.
      2. Make sure that each of the temporary Scenes reference on of the styles that you are keeping.
      3. Purge Styles.
      4. Delete the temporary Scenes.

      Am I missing something?

      Thank you,
      wehby

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

        a Sketchup::Style is_a? Sketchup::Entity, so I just tried:

        
        m = Sketchup.active_model
        s = m.styles[0]
        m.entities.erase_entities s
        
        

        and crashed Sketchup. 😞

        Of coarse, there is

        Sketchup.active_model.styles.purge_unused
        

        Hi

        1 Reply Last reply Reply Quote 0
        • W Offline
          wehby
          last edited by

          Jim,
          This is interesting. Taking your example and testing it a little:

          
          model = Sketchup.active_model
          #returns something like; <Sketchup;;Model;0x5181b38>
          entities = model.active_entities
          #returns something like; <Sketchup;;Entities;0x5181a78>
          entities.count
          #returns; 1
          entity0=entities[0]
          #returns something like; #<Sketchup;;ComponentInstance;0x5181700>
          
          

          The only entity in the model is the Bryce model. If I add several styles and retest entities.count, I still only get 1 entity. I think the parent of styles is model.

          The downside of using purge_unused is that I first have to create scenes that use all of the styles that I don't want to purge, then delete the temporary scenes. But if that's the only way, then I guess I can deal with it.

          Does my test look right?

          -wehby

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

            wehby, your test looks right. I based my post on the following test:

            
            Sketchup.active_model.styles[0].is_a? Sketchup;;Entity
            true
            
            

            I'm sure exactly what Sketchup.active_model.entities returns. For me, entities sometimes even contains weird things like Edgeuse objects and Loop objects - things that should never be in there.

            So, don't confuse Entity with Drawingelement. Drawingelement's are things that create visible geometry - edges, faces, groups. Here's a diagram of some of the class hierarchy (from RLC on Google Groups😞

            http://sketchup.googlegroups.com/web/inherit__graph__11.png

            Sketchup is saying there is 1 entity, but maybe it really means 1 Drawingelement? I don't know.

            Hi

            1 Reply Last reply Reply Quote 0
            • W Offline
              wehby
              last edited by

              Thanks for your help on this, Jim.

              I'm working on a script that is sort of a combination of your Style Thumbnailer and my own Display Templates ruby scripts. Since my script involves loading styles into a SKP, I wanted to make sure that I provided a way of deleting the styles that I imported. That way I would not be bogging down the file with a bunch of junk. Looks like I will have to do it the hard way...

              Thanks again.

              -wehby

              1 Reply Last reply Reply Quote 0
              • R Offline
                RickW
                last edited by

                Sorry to be the bearer of further bad news, but we can't delete scenes. I've made that request (plus others), so we'll see what happens...

                RickW
                [www.smustard.com](http://www.smustard.com)

                1 Reply Last reply Reply Quote 0
                • W Offline
                  wehby
                  last edited by

                  Well, it looks like I have to either just fix my Display Templates to work in SU6 and pretend Styles don't exist (as they didn't when I first wrote the script) or write a script that uses Styles and potential flood the user's SKP with styles.

                  Do you think there might be a work around by using send_action?

                  -wehby

                  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