bonsai libs/desktop #5178

This commit is contained in:
Andrej730
2024-08-14 16:20:06 +05:00
committed by Andrej
parent f8f7884278
commit b15820dd10
8 changed files with 27 additions and 66 deletions
+10 -10
View File
@@ -310,15 +310,15 @@ class FileAssociate(bpy.types.Operator):
os.makedirs(os.path.join(destdir, rel_path), exist_ok=True) os.makedirs(os.path.join(destdir, rel_path), exist_ok=True)
shutil.copy( shutil.copy(
os.path.join(src_dir, "blenderbim.png"), os.path.join(src_dir, "bonsai.png"),
os.path.join(destdir, "share/icons/hicolor/128x128/apps"), os.path.join(destdir, "share/icons/hicolor/128x128/apps"),
) )
shutil.copy( shutil.copy(
os.path.join(src_dir, "blenderbim.desktop"), os.path.join(src_dir, "bonsai.desktop"),
os.path.join(destdir, "share/applications"), os.path.join(destdir, "share/applications"),
) )
shutil.copy( shutil.copy(
os.path.join(src_dir, "blenderbim.xml"), os.path.join(src_dir, "bonsai.xml"),
os.path.join(destdir, "share/mime/packages"), os.path.join(destdir, "share/mime/packages"),
) )
shutil.copyfile( shutil.copyfile(
@@ -327,13 +327,13 @@ class FileAssociate(bpy.types.Operator):
) )
# copy and rewrite wrapper script # copy and rewrite wrapper script
with open(os.path.join(src_dir, "blenderbim"), "r") as wrapper_template: with open(os.path.join(src_dir, "bonsai"), "r") as wrapper_template:
filedata = wrapper_template.read() filedata = wrapper_template.read()
filedata = filedata.replace("#BLENDER_EXE=/opt/blender-3.3/blender", 'BLENDER_EXE="' + binary_path + '"') filedata = filedata.replace("#BLENDER_EXE=/opt/blender-3.3/blender", 'BLENDER_EXE="' + binary_path + '"')
with open(os.path.join(destdir, "bin", "blenderbim"), "w") as wrapper: with open(os.path.join(destdir, "bin", "bonsai"), "w") as wrapper:
wrapper.write(filedata) wrapper.write(filedata)
os.chmod(os.path.join(destdir, "bin", "blenderbim"), 0o755) os.chmod(os.path.join(destdir, "bin", "bonsai"), 0o755)
self.refresh_system_linux(destdir=destdir) self.refresh_system_linux(destdir=destdir)
@@ -383,11 +383,11 @@ class FileUnassociate(bpy.types.Operator):
def uninstall_desktop_linux(self, destdir="/tmp"): def uninstall_desktop_linux(self, destdir="/tmp"):
"""Removes linux file assocations and launcher icon""" """Removes linux file assocations and launcher icon"""
for rel_path in ( for rel_path in (
"share/icons/hicolor/128x128/apps/blenderbim.png", "share/icons/hicolor/128x128/apps/bonsai.png",
"share/icons/hicolor/128x128/mimetypes/x-ifc.png", "share/icons/hicolor/128x128/mimetypes/x-ifc.png",
"share/applications/blenderbim.desktop", "share/applications/bonsai.desktop",
"share/mime/packages/blenderbim.xml", "share/mime/packages/bonsai.xml",
"bin/blenderbim", "bin/bonsai",
): ):
try: try:
os.remove(os.path.join(destdir, rel_path)) os.remove(os.path.join(destdir, rel_path))
+9 -9
View File
@@ -9,21 +9,21 @@ install :
${DESTDIR}/share/icons/hicolor/128x128/mimetypes \ ${DESTDIR}/share/icons/hicolor/128x128/mimetypes \
${DESTDIR}/share/applications \ ${DESTDIR}/share/applications \
${DESTDIR}/share/mime/packages ${DESTDIR}/share/mime/packages
cp blenderbim ${DESTDIR}/bin/ cp bonsai ${DESTDIR}/bin/
chmod +x ${DESTDIR}/bin/blenderbim chmod +x ${DESTDIR}/bin/bonsai
cp blenderbim.png ${DESTDIR}/share/icons/hicolor/128x128/apps/ cp bonsai.png ${DESTDIR}/share/icons/hicolor/128x128/apps/
cp blenderbim.desktop ${DESTDIR}/share/applications/ cp bonsai.desktop ${DESTDIR}/share/applications/
cp blenderbim.xml ${DESTDIR}/share/mime/packages/ cp bonsai.xml ${DESTDIR}/share/mime/packages/
cp x-ifc_128x128.png ${DESTDIR}/share/icons/hicolor/128x128/mimetypes/x-ifc.png cp x-ifc_128x128.png ${DESTDIR}/share/icons/hicolor/128x128/mimetypes/x-ifc.png
update-mime-database ${DESTDIR}/share/mime/ || true update-mime-database ${DESTDIR}/share/mime/ || true
update-desktop-database ${DESTDIR}/share/applications/ || true update-desktop-database ${DESTDIR}/share/applications/ || true
uninstall : uninstall :
rm -f \ rm -f \
${DESTDIR}/bin/blenderbim \ ${DESTDIR}/bin/bonsai \
${DESTDIR}/share/icons/hicolor/128x128/apps/blenderbim.png \ ${DESTDIR}/share/icons/hicolor/128x128/apps/bonsai.png \
${DESTDIR}/share/applications/blenderbim.desktop \ ${DESTDIR}/share/applications/bonsai.desktop \
${DESTDIR}/share/mime/packages/blenderbim.xml \ ${DESTDIR}/share/mime/packages/bonsai.xml \
${DESTDIR}/share/icons/hicolor/128x128/mimetypes/x-ifc.png ${DESTDIR}/share/icons/hicolor/128x128/mimetypes/x-ifc.png
update-mime-database ${DESTDIR}/share/mime/ || true update-mime-database ${DESTDIR}/share/mime/ || true
update-desktop-database ${DESTDIR}/share/applications/ || true update-desktop-database ${DESTDIR}/share/applications/ || true
+4 -4
View File
@@ -2,20 +2,20 @@ Desktop
======= =======
This folder contains everything needed to create file associations and icons to This folder contains everything needed to create file associations and icons to
present BlenderBIM as a desktop application. present Bonsai as a desktop application.
Linux Linux
----- -----
Assuming that blender and BlenderBIM are already installed on your system, Assuming that blender and Bonsai are already installed on your system,
configure associations and icons for a single user by running `make`: configure associations and icons for a single user by running `make`:
make install make install
Test by running the wrapper script directly, this should launch BlenderBIM with Test by running the wrapper script directly, this should launch Bonsai with
an empty IFC project: an empty IFC project:
blenderbim bonsai
This `Makefile` installs files to `~/.local` by default, to install to an This `Makefile` installs files to `~/.local` by default, to install to an
alternative location, set `DESTDIR`: alternative location, set `DESTDIR`:
-16
View File
@@ -1,16 +0,0 @@
#!/bin/bash
# Wrapper script to launch BlenderBIM.
# If the `blender` executable can't be found in your PATH environment, set
# BLENDER_EXE to the location of your preferred `blender` executable.
#BLENDER_EXE=/opt/blender-3.3/blender
: ${BLENDER_EXE:=blender}
if [[ $# -eq 1 && -f "$@" ]]; then
"${BLENDER_EXE}" --python-expr 'import bpy; bpy.data.batch_remove(bpy.data.objects); bpy.ops.outliner.orphans_purge(do_local_ids=True, do_linked_ids=True, do_recursive=True); bpy.ops.bim.load_project(filepath="'"$@"'")'
else
"${BLENDER_EXE}" --python-expr 'import bpy; bpy.data.batch_remove(bpy.data.objects); bpy.ops.outliner.orphans_purge(do_local_ids=True, do_linked_ids=True, do_recursive=True); bpy.ops.bim.create_project()'
fi;
@@ -1,9 +0,0 @@
[Desktop Entry]
Type=Application
Terminal=false
Exec=blenderbim %f
Name=BlenderBIM
Icon=blenderbim
X-Desktop-File-Install-Version=0.26
GenericName=Blender BIM add-on
MimeType=application/x-ifc;
Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

@@ -1,14 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
<mime-type type="application/x-ifc">
<sub-class-of type="text/plain"/>
<comment xml:lang="en">Industry Foundation Classes</comment>
<magic priority="50">
<match type="string" value="ISO-10303-21;" offset="0"/>
</magic>
<generic-icon name="x-ifc"/>
<glob pattern="*.ifc"/>
<glob pattern="*.ifczip"/>
<glob pattern="*.ifcxml"/>
</mime-type>
</mime-info>
@@ -6,11 +6,11 @@ Start-Process cmd -ArgumentList `
"/k ", ` "/k ", `
"ASSOC .IFC=", ` "ASSOC .IFC=", `
"&", ` "&", `
"FTYPE BLENDERBIM=""$BlenderPath"" --python-expr ""import bpy; bpy.ops.bim.load_project(filepath=r'%1')""", "FTYPE BONSAI=""$BlenderPath"" --python-expr ""import bpy; bpy.ops.bim.load_project(filepath=r'%1')""",
"&", ` "&", `
"echo. & echo. & echo To create an association between .IFC files and BlenderBIM", ` "echo. & echo. & echo To create an association between .IFC files and Bonsai", `
"&", ` "&", `
"echo type the command below & echo.", ` "echo type the command below & echo.", `
"&", ` "&", `
"echo ASSOC .IFC=BLENDERBIM & echo." ` "echo ASSOC .IFC=BONSAI & echo." `
-Verb RunAs -Verb RunAs