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

    How to insert a component instance from a definition.

    Scheduled Pinned Locked Moved Developers' Forum
    6 Posts 2 Posters 322 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.
    • honoluludesktopH Offline
      honoluludesktop
      last edited by

      If the model has a component definition (no instance), is there a way to insert an instance of that definition via the api?

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

        Entities.add_instance
        http://code.google.com/intl/no/apis/sketchup/docs/ourdoc/entities.html#add_instance

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

        1 Reply Last reply Reply Quote 0
        • honoluludesktopH Offline
          honoluludesktop
          last edited by

          There is no instance of the component in the model, only the definition.

          1 Reply Last reply Reply Quote 0
          • honoluludesktopH Offline
            honoluludesktop
            last edited by

            Its like when you open the Windows > Component's window and you see instances that have been previously deleted, but can still be inserted into the model.

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

              Yes? Entities.add_instance is what you use then.

              model = Sketchup.active_model definition = model.definition[0] # getting a reference to a ComponentDefinition tr = Geom::Transformation.new model.entities.add_instance( definition, tr )

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

              1 Reply Last reply Reply Quote 0
              • honoluludesktopH Offline
                honoluludesktop
                last edited by

                OK, thanks. I must have done it wrong, when I tried to use entities.add_instance previously. I will work on it tomorrow.

                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