Hello uss, I do agree about setting goals.
Here what we are trying to achieve is the following:
Preserve the name of the objects across multiple export of the same models;
Still be able to bind objects to entities to visualize state or trigger actions
It will be impossible to achieve both without touching the OBJWriter class you pointed me to.
Sweethome3D is not natively exporting O tags and the G tags are built diregarding the pesistency of the names. As far as I could test, the O tag are not searchable by name in the Three.js library.
The light is not a problem, I create it by setting a point light at the center of the box containing the object. That is working in all contexts. Actions on objects can be achieved easily (I can do it by clicking on the object representing the light or by creating a new switch object that can be positioned somewhere else). What I propose is to redesign the OBJWriter (unfortunately we will loose forward compatibility): thanks to your help I’m getting some knowledge on the Plugin development. Not yet there but I’m definetly progressing
I also have a car object that is far more complex and it would balloon my card code. Is there a way to select a single object id and it hide any object nested in it / associated to it?
Unfortunately the Export to OBJ function in Sweethome3D does not group together the elements of an object. I’m checking how we can improve the export by building a specific Export to HASS plugin. See above discussion with uss. Not an easy one. You can always edit the obj file but it is a tedious activity…
I can suggest you a dirty workaround, waiting for a better solution.
In Sweethome3D put your car in a new model (only the car), click on Export to OBJ format.
Retrieve the file.obj. Open it in an advanced editor such as Visual Studio Code.
Then follow these steps:
In place of the first "g " tag put something like “g_your_car_name”
Cmd-F to open find.
Paste the string "g "
Alt-Enter to select all of the instances of the string on the page.
Cmd-L to broaden the selection to the entire line of each instance on the page.
Delete/Backspace to remove those lines.
change the first g line to “g your_car_name”
Save your file as car.obj and reimport it as furniture (from the menu, Furniture, Import Furniture) give it a new name and insert it into your catalog of objects.
Satrting from your car will be made of only one object when adding it to your home model.
Hmmm. I must have messed it up somehow because after having followed the instructions and importing back into SH3D the id’s have just been swapped by my new one followed by some numbers
It also changed some of the models colours. Going to have to revisit this one. Thanks though!
That is normal after the export of the full home containing your new car, the car gets renamed to something like your_car_name_1_1, but you now have only one object representing your car.
You just have to change your hide element to the object_id your_car_name_1_1…
If you have already done a lot of binding based on a model you exported, any change to the model (especially removing objects) generates new objects_id that have to be bound back inside the card configuration (I know this is an annoying limit, but I am trying to overcome it based on our disucssion thread with uss above).
I gave you a dirty (yet working) way to overcome the other problem you raised. Complex objects are not grouped together with one object_id. This means that to make a complex object disappear you need to create as many hide bindings as the number of composing objects. If you follow my procedure you should change the obj file from:
g winshield
v …x…
v …y…
g trunk
v …w…
v…z…
g …
v …
to:
g car
v …x…
v …y…
v …w…
v…z…
v …
of course by removing your old car object and put your new car ojbect, you get into the first problem, objects_id get re-organized.
So my suggestion is: for all the objects that needs to be grouped, do my “export change import” trick. Only after, build the final version of the plan putting all your new objects and do the card binding inside Home Assistant. In other words stabilize your plan before binding 100s of objects…
you need to put an object_id in the entity configuration but you can now reference and object_group by enclosing the object_group name into <>. It is not very intuitive but I’ve tried a solution to have object groups without impacting those who are not using them.