I need to know the object ID for incandescent light sources in my model, but it's not clear to me how to know what these IDs are. For other objects, when I look at the .obj file, I can search for specific text (like "Seat") and usually find object IDs that way. But it appears that my light sources are being given numeric IDs -- is there a way I can force a specific ID or know what the mapping is?
France
Joined: Nov 7, 2005
Post Count: 9426
Status:
Offline
Re: How to obtain the ID of a light source
What ID are you talking about? The ID associated to each home object and defined in HomeObject super class or the catalog ID of furniture found also in HomePieceOfFurniture instances? Both can be found in Home.xml entry found in a SH3D file (based on ZIP format). There’s no method to change the ID of an existing home object, but feel free to edit Home.xml entry to change them. Just be sure to keep they are unique.
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D creator
If I open my home.obj file, I see lines that begin with 'g' and have some unique identifier after them. i.e.:
g Seat_897 usemtl fltan
I don't know where or how "Seat_897" is created/found, and in fact my home.xml file does not contain the word "seat" in it at all.
I found my incandescent light source in the XML file you pointed me to, but nowhere do I see any ID (other than its guid).
If you're wondering why I care about this -- I have an application (Home Assistant) that imports my .obj files and allows me to couple devices in my home to objects in my scene. For instance, I can tie a smart lightbulb to a lamp in my 3D scene and whenever I turn on my light, the scene renders with the lamp on, etc.
But I need to know the ID -- or what Home Assistant is referring to as the ID, the "g" line above -- of the light source in question to create this coupling.
France
Joined: Nov 7, 2005
Post Count: 9426
Status:
Offline
Re: How to obtain the ID of a light source
As light sources are not exported in OBJ file, you won't find them without a trick. If you want them in the exported OBJ file, you'll have to change the "original ID" of light sources in the OBJ file where they were defined. If you look in your SH3D file with a ZIP tool, you'll find some numbered files and one of them is a file at OBJ format containing the text g sweethome3d_light_source (to find it more easily, move the light sources at the beginning or the end of furniture list, and study the first or last numbered files). Remove the prefix sweethome3d_ in that text, remove the entry named ContentDigests in the SH3D file and save the SH3D file (you may change temporarily the .sh3d extension to .zip if needed). Then if you open your file in Sweet Home 3D, light sources will always be displayed and exported to OBJ format (but they will also appear in renderings). The file attached to this message shows what result you'll get (the OBJ file of the light source is stored in the ZIP entry named 7).
---------------------------------------- AlwaysVisibleLightSources.sh3d
(55770 bytes)
(Download count: 27)
(Always visible light sources)
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D creator