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

    Get materials from definition (through file operation).

    Scheduled Pinned Locked Moved Developers' Forum
    9 Posts 3 Posters 147 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.
    • jolranJ Offline
      jolran
      last edited by

      Sorry could not describe the topic better.

      Don't know how trivial this question is, but is there any way to get a collection of materials from a component definition's path(file). I.e without loading it into Sketchup.

      I'm guessing no, but one never knows..

      Might add, this will be done from inside a webdialog. Or sent like some sort of value to webdialog.

      If it's not doable or to complicated then I guess doing a js-callback and load in the desired comp.definition in Sketchup is more feasable. Then deleting the definition with this snippet I found from TIG.

      model.start_operation("Delete Definition")
        definition.entities.erase_entities(definition.entities.to_a)
      model.commit_operation
      
      

      I rather ask now, then finding out later it could have been done much simpler..

      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        Option 1. Use the C++ SDK to load the process the .skp file.

        Option 2. Reverse engineer the .skp file format. (Not really realistic - I've tried it.)

        Option 3. Do load the component, and erase it - as you suggested.

        Thomas Thomassen β€” SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund

        1 Reply Last reply Reply Quote 0
        • Dan RathbunD Offline
          Dan Rathbun
          last edited by

          @jolran said:

          ... is there any way to get a collection of materials from a component definition's path(file). I.e without loading it into Sketchup ?

          THAT seems like an oxymoronic question.

          I'm not here much anymore.

          1 Reply Last reply Reply Quote 0
          • jolranJ Offline
            jolran
            last edited by

            Option 1 and 2 appears to be a lot of more work than option 3 πŸ˜„ .

            I think I'll try option 3 first and see how it goes.

            Thank you Thomthom.

            Dan.

            Yes, I agree, but there are no dumb questions, just dumb people πŸ˜„

            1 Reply Last reply Reply Quote 0
            • thomthomT Offline
              thomthom
              last edited by

              @dan rathbun said:

              THAT seems like an oxymoronic question.

              Not really, the C++ SDK is there - so it's possible.

              Thomas Thomassen β€” SketchUp Monkey & Coding addict
              List of my plugins and link to the CookieWare fund

              1 Reply Last reply Reply Quote 0
              • Dan RathbunD Offline
                Dan Rathbun
                last edited by

                @jolran said:

                @Dan, Yes, I agree, but there are no dumb questions, just dumb people πŸ˜„

                oxymoron (definition) has nothing to do with being dumb.

                How can you know what the path is, to the file, that a ComponentDefinition would be loaded from, unless it is already loaded as a member of the DefinitionList collection, ... that you access, to call it's path() method upon, to get the path to it's file .. and 'round and 'round, and again and again, etc., etc ... ?

                I'm not here much anymore.

                1 Reply Last reply Reply Quote 0
                • jolranJ Offline
                  jolran
                  last edited by

                  Hi Dan, sorry for the missunderstanding.
                  I should have explained further, but usually when I do, things get more messy.

                  Anyway, in short the path IS known.

                  I already have a premade collection of components in a plugin/folder.
                  From there I rebuild the path string from several selections(#id's) in the webdialog.

                  Like: path = File.join(File.dirname(FILE), "somefolder/skp_comps/#{folder}/#{comp_name}.skp")

                  So, Sketchup.active_model.definitions.load(path)
                  will of course load the definition to Sketchup.

                  But, yes the path is always only a string and not a drawingelement until entering Sketchup if that is what you meant..

                  I was hoping one could do something when the path was known, but I think Thomthom already answered that question.

                  1 Reply Last reply Reply Quote 0
                  • Dan RathbunD Offline
                    Dan Rathbun
                    last edited by

                    @jolran said:

                    I already have a premade collection of components in a plugin/folder.

                    OK.. then why not ALSO have a premade collection of Materials in a "plugins/folder/materials" directory ?

                    I'm not here much anymore.

                    1 Reply Last reply Reply Quote 0
                    • jolranJ Offline
                      jolran
                      last edited by

                      @unknownuser said:

                      OK.. then why not ALSO have a premade collection of Materials in a "plugins/folder/materials" directory ?

                      Might be better to grab the materials from components in this case.

                      The idea is that the end user should be able to add new components to that folder and everything updates.

                      Anyway, I "sort of" have it working already now with option 3 (wich was pointed out earlier).

                      Thanks for the suggestion.

                      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