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

    Getting the file of a component

    Scheduled Pinned Locked Moved Developers' Forum
    6 Posts 2 Posters 647 Views 2 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.
    • R Offline
      rubine
      last edited by

      I store a component as an skp file on my computer. Is there a chance to get that skp file (if I have the component definition of the component)?? (So, I do not want to search for the file by typing in the path, but by using the relevant component in the model)

      Could someone help me, please?

      1 Reply Last reply Reply Quote 0
      • TIGT Offline
        TIG Moderator
        last edited by

        You can load an external component - you need to know its path.

        http://download.sketchup.com/sketchuphelp/gsu6_ruby/Docs/Ruby-DefinitionList.html#load

        You then place it...

        http://download.sketchup.com/sketchuphelp/gsu6_ruby/Docs/Ruby-Model.html#place_component

        TIG

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

          well, actually I do not want to load it, but to store/save it in a file (skp file).
          There is a method for Model objects to be stored. Can I somehow typecast the component object in a model object so that I can use the save method (of class Model)??
          Or is there any other possibility to save the component in the local file system?

          1 Reply Last reply Reply Quote 0
          • TIGT Offline
            TIG Moderator
            last edited by

            I see...

            You can only save_as manually. Open the compo browser, click the little-house-icon option to list the model's comps and hover the mouse over the one you want, now right-click and save_as to save it...

            You have come up with a question about a "ComponentDefinition.save_as" method that has been around for a while. It doesn't exist in the current API and looking at the SDK it's not easily made either. Wait for v7 API ? ...

            TIG

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

              do you see a chance to rebuild the "create component" with ruby?
              i.e. writing your own "create component" method (creating a ComponentDefinition)

              1 Reply Last reply Reply Quote 0
              • TIGT Offline
                TIG Moderator
                last edited by

                @rubine said:

                do you see a chance to rebuild the "create component" with ruby?
                i.e. writing your own "create component" method (creating a ComponentDefinition)

                You can easily make and place components with ruby methods, such as.

                Definitionlist.add("componentdefinitionname")

                ComponentDefinition.entities

                Group.entities

                Group.to_component

                entities have lots of 'add' methods: http://download.sketchup.com/sketchuphelp/gsu6_ruby/Docs/Ruby-Entities.html#add_instance

                You can't 'save_as' components in current Ruby - but you can do it manually.

                I've discovered that in the SDK there's a kind of ...Group.SaveAs() method that would allow us to write something like a dll or a socket that could then access that function. In a script you'd have to say something like:
                require 'GroupExporter.so'
                ...
                GroupExporter.new(group,filepath)
                ...
                This would then save a specified group to a .skp file at a specified name/location. These kinds of variables can be got/set in earlier bits of Ruby coding...
                To get it to export a Component all we'd need to do is make a temporary group, that's then named after the component-definition and even with a copy of its description if any (that way the final exporter component matches the original in the model...). Then to that group's entities we add an instance of the component (and explode it inside the group?). We then use GroupExporter.new(group,filepath) and finally erase the group to tidy up. If we want it done 'silently' we can specify the filepath - say as the model's folder_path/group_name.skp - or we could prompt for a component name and/or location...

                All I need now is someone who can make this dll/so with the SDK - my C++ is too poor to do it...

                TIG

                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