Is it possible to create a command to import an item into sketchup?

I don’t think an extension is necessary since there are at least three native ways of doing this, the simplest being to have (multiple) windows explorers open with the view set to thumbnails::

windowsexpolorerdraganddrop

The second best might be to add certain folders with components as a local collection:

SketchUpCollection

Learn more, here:
https://help.sketchup.com/en/sketchup/adding-premade-components-and-dynamic-components#organize-collections

ofcourse, depending on your situation (eg. are you part of a large organisation or not, or do you need to have access to those collections on different platforms or machines, one can leverage collections in the 3D Warehouse:

https://help.sketchup.com/en/3d-warehouse/creating-and-sharing-collections

or see this post:

1 Like

Wouldn’t doing this increase the loading time of SketchUp?

It would increase the loading time of sketchup indeed.

There were some reports where this had impact on downloading components, Mac platform specific.
There are a bunch of collections in the standard installation folders, I wonder if deleting them would have impact.

On windows, I don’t see a difference, but my collections might not be large enough.

Closing the Component dialog before closing SketchUp might have influence, too.

After all, it’s just adding some paths in the preferences json, when you open the collection, it’s time to generate the thumbnails, I would presume.

On Mac, I have always tend to believe that (re)starting SketchUp several times after adding collections would speed up things, as if the Operating System indexes certain aspects (most used apps and paths)

Did a quick test with extension on folders in external drive. Thumbnails are saved in selected folder. Paths aren’t created until folder is selected. Slower to generate thumbnails but probably not slower to load.

I was saying this related to this I read SketchUp takes a while to start up - #8 by colin

I need to go through the links provided still, but the workflow I was trying to achieve is we have a group of designers that don’t use SketchUp. They source items and add them to this database per project. I’m starting build a decent catalog of components that we reuse, but it would be easier for me if I could easily import those components straight from this database that they create and drop the already modeled components directly into my open SketchUp file. Think one monitor has this database up the other has SketchUp, drag and drop or click on something that imports it. The flip side is that then they can browse all the existing components in this database to make choices, again they don’t have SU or Trimble accounts to browse from there.

What format are they “adding” to this database in?

They add entries to a database, url links to actual products, unmodled at that point.

So you are looking for a way to convert a url link, presumably to a manufacturers web page that opens in a browser with text and some pictures maybe…magically into a modeled 3D version of whatever item is on that webpage? Or am I missing a step? Maybe I don’t understand this request yet.

SketchUp Pro can import lots of different 3D modeling file formats, but to get 3D data the object needs to have been 3D modeled by someone, somewhere, at some point, in some kind of software.

haha, yea sorry for not being clear. I have components saved. I have a database with info on those components, desc, url links to actual product. images etc. i would like to be able to send a command to import that component into sketchup. I dont have this product built yet, otherwise id provide a visual. And this may not really be a sketchup question but if I have a component, on my local hard drive. This database entry would have the filename and path to this component. could a script then run to import this into sketchup (or any other ideas on how to do so?)

What would be the next step?
Why do you need those components?

You can add a puts statement to the linked code if you want to see a list of all skp files in a directory.

After save_thumbnail, add: puts “skp: #{skp}”

after the designers put together all the pieces for the room then they let me know, i go to that page and assemble the room in sketchup.

What if it doesn’t fit or how will the designers know if it looks the way they wanted it to look?
Sounds like a lot of work and back and forthing.

After you have done their work, what is the purpose of having a SketchUp model within the organization?
To get renders?

Just curious here.

That’s just part of the process… the designers know the dimensions of the space and what needs to be accomplished. They do their best to pick the items that fulfill all of those requirements. Inevitably things will have to be replaced with something that fits better, looks better, fits the budget better. The end goal is to deliver elevations to client to approve and then technical documents to the contractors to build and execute the design plan. Currently we do everything in excel, product selection, budgeting , revisions, to setup the “design” of the rooms. Then I model everything in sketchup and deliver pdf/prints with layout. I’m creating the next version of this as a web application and one portion that i thought would be helpful of would be this catalog of items we have already used/modeled for past projects. It would assist the designers if they wanted to reuse an existing material and it would assist me by having one location for all the things I’ve already modeled and hopefully easier for me to import that item into sketchup.

Im new to the scripting side of sketchup, but my buddy said why dont you just ask chatgpt. So i did: (again this is probably old hat for most of you guys but it worked)

https://chat.openai.com/share/1dd61f47-c5a4-40a1-8370-373bf8229014

when i pasted that code into the Ruby console the component showed up at the axis origin. I think all i need to do now is create a formula to make the path dynamic and then copy and paste the code into the ruby editor. There must be a way to make this even less intrusive with an even easier way to execute scripts. but for now I have a solution:

Just a visual to show a test entry in the app:

copy the code from that cell and run in the ruby console and it shows up:

I have a working prototype now: All i have to do is provide the path to the skp file and the program will dynamically create the ruby code to import that in. very basic so far but it works. I need to learn how to attach the new component to the mouse cursor.

1 Like

Try to replace:

instance = model.entities.add_instance(component_definition, Geom::Transformation.new)

by

model.place_component component_definition, false

as @dezmo suggested in this post Insert dynamic component from the component folder by a plugin - #6 by dezmo

(edited following @dezmo post below)

1 Like

The Model #place_component method does not return an instance but the model. ( or ‘nil’ ) :innocent:

1 Like