Material Attributes
-
Thanks for the response.
I go to the SketchUp Material Window and use Save As, and then view the XML after loading the .SKM file with WinZip.
The .XML is not part of the process, I was just using it to see if SketchUp had saved the attributes materials properly.
Note: This is not a problem creating materials and saving them into the.SKP file. I wanted to be able to put Attributes on a material, save it in a library, use the material in a different drawing and have the attributes still be valid.
Here is the process:
- Select a SketchUp Material and place it on a face.
- Place more than 1 attribute directly on the material.
- Use the SketchUp materials window to save the material as a .SKM file.
- Start a new SketchUp session and a new drawing.
- Select the .SKM material with the SketchUp materials window
- Query the material to see if the attributes are still set.
If you can do all this, I would love to have the .SKM file for the material, and also a new model with a single face in which you have placed the material.
This would be a great help for me if we could get it to work.
Al
-
Sorry for digging up an old post, but I can't find anywhere the answer to the question posed here, the question I need answered as well.
When you apply attributes to a material, and save that material as an SKM, the attributes are saved correctly. If you rename the SKM as a zip and examine the document.xml, the attribute dictionaries are all listed, all correct.
But when you load that material into a new scene and apply it to a face, the attribute dictionaries are not restored correctly. What I've observed is that the number of dictionaries is reported correctly, but each dictionary reports it's name and keys/values as those stored only in the first dictionary. That you get multiple dictionaries with the same name seems a bug straight off the bat. Shouldn't all attributes with the same dictionary name be stored in a single dictionary? I suspect this is a Sketchup bug in loading the attributes from the SKM. Does anyone have any info about this?
-
Yes. This appears to be a SketchUp bug. Attributes and Attribute Dictionaries stored on materials are not saved properly in the SKM file and/or not reloaded properly.
-
Ok. Has this been reported to SU as an official "bug"? It would be very nice to get it fixed some day.
-
@avariant said:
Ok. Has this been reported to SU as an official "bug"? It would be very nice to get it fixed some day.
I didn't report it.
I suppose I hoped hey might read these threads.
Also, has anyone ever reported a bug and felt that the report had anything to do with the final resolution. Especially a bug like this which does not effect almost anyone? (Except we Ruby programmers who want to store attributes on materials and be able to save and reload them).
-
The problem/bug of saving multiple material attributes with a material is still there but I found a workaround. It seems that the saved .skm material file when loaded will only retain a single attribute parameter. So I packed all the material params into a single string using a single parameter and then saved the material. If I need to do anything with the material attributes, I unpack them into Sketchup attributes at run-time. Kind of a kludge, but it works.
-
That will work in some cases, and is a clever solution.
One of the things we are trying to do is save multiple images with a material - e.g. a bump map and specular map - in addition to the diffuse map. First we have to convert the binary to ASCII because SketchUp does not handle binary attributes properly, then we run into the problem that SketchUp can only handle about one megabyte (I don't remember the exact limit) per attribute, so we split large images up into several attributes.
-
@al hart said:
That will work in some cases, and is a clever solution.
One of the things we are trying to do is save multiple images with a material - e.g. a bump map and specular map - in addition to the diffuse map. First we have to convert the binary to ASCII because SketchUp does not handle binary attributes properly, then we run into the problem that SketchUp can only handle about one megabyte (I don't remember the exact limit) per attribute, so we split large images up into several attributes.
there's a attribute size limit? hm... that would have been useful info to have seen in the manual.
binary to ASCII? you mean base64?
-
@thomthom said:
there's a attribute size limit? hm... that would have been useful info to have seen in the manual.
binary to ASCII? you mean base64?
We use HEX sometimes and Base64 sometimes.
Try this little example:
def test_att(size) test_string = "A"*size printf("size; %s test_string.length; %s\n", size, test_string.length) model = Sketchup.active_model model.set_attribute("test_string","test_string", test_string) test_string2 = model.get_attribute("test_string","test_string") printf("size; %s test_string.length; %s test_string2.length; %s\n", size, test_string.length, test_string2.length) end#def
If you load it and type in:
test_att(100) - works
test_att(100000) - works
test_att(1000000) - works
test_att(2000000) - dumps core -
@al hart said:
That will work in some cases, and is a clever solution.
One of the things we are trying to do is save multiple images with a material - e.g. a bump map and specular map - in addition to the diffuse map. First we have to convert the binary to ASCII because SketchUp does not handle binary attributes properly, then we run into the problem that SketchUp can only handle about one megabyte (I don't remember the exact limit) per attribute, so we split large images up into several attributes.
Al, are you implying that you've found a way for Sketchup materials to load with multiple attributes attached? If so, can you share the magic of this invention.
-
@avariant said:
Ok. Has this been reported to SU as an official "bug"? It would be very nice to get it fixed some day.
for SketchUp 2017
@unknownuser said:
(https://help.sketchup.com/en/article/141303)":2kct16r6]
Fixes/Improvements GeneralSketchUp API Release Notes
- (Mac) Fixed issue where SKM files lost attribute dictionaries when saved from ‘In Model’ to local library.
Advertisement