Extension to read & update .skp file

I want to create an extension to upload an existing .skp model file & update the model file & to save the changes to model file. I have not found any similar extension tutorial or method how to browse .skp file . Please help

Looking for tutorials and Examples:

Hi, you can start by learning how to open a .skp file with code.

Below is the API reference…


Also, if you’re interested I am starting a Blog where I post tutorials on how to code SKetchUp extensions. Below is the link to my website…

Herosu Blog

1 Like

Hi, thanks for reply. I am already done with reading .skp file from a static path. But I am creating an extension where i need to select a .skp file by browsing and to read its materials, layers data, etc.

So not getting how to upload a file

Here is an example on how to browse for a .skp file and then open it in SketchUp…

chosen_skp = UI.openpanel("Open SKP File", "c:/", "model.skp")

result = Sketchup.open_file("#{chosen_skp}")

API Reference:


Tell me if this is what you wanted and after that I can help you with reading the model’s material or layer data. Cheers! :slight_smile:

1 Like

Hi RefaelRivera,

Thanks for your reply. Yes I was looking for same and it worked perfect.

I am now trying to add new attribute/property “Price” for material of model so that i can define its value & can calculate price of all materials collectively

For now I have tried the following:

model = Sketchup.active_model
value = model.set_attribute “MaterialDictionary”, “Price”, 50
attrdicts = model.attribute_dictionaries
attrdict = attrdicts[“MaterialDictionary”]
value = attrdict[“Price”]

This is adding price attribute to whole model but i want this attribute to be added for a material

is there any way out to that?


1 Like

thanks! it worked for me

1 Like

I have never used the attribute_dictionaries on any of my extensions but it may be time for me to learn as well. Hope we can learn to solve this…I’ll keep in touch with any advances in figuring it out.

Maybe it is time to call the master… @DanRathbun


Yes. Same way. The functionality of attribute dictionaries is defined in class Sketchup::Entity so any of it’s subclasses can have them.

But in some older versions I think that attributes attached to materials did not save properly.
(Check API release notes.)

value = 50
model.materials["some_material"].set_attribute("MaterialDictionary", "Price", value)

Pls, use proper code quoting and parenthesis around argument lists.

1 Like

Thanks for reply. I will check it now

You should read the Help Center articles about Dynamic Components …

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.