Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Materialx: 1st merge (experimental) #371

Merged
merged 134 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
134 commits
Select commit Hold shift + click to select a range
d8b7056
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 18, 2023
de3fa3d
[pre-commit.ci] pre-commit autoupdate
pre-commit-ci[bot] Dec 25, 2023
6fddcd4
Texture: fix add_texture (property naming)
howetuft Jan 15, 2024
275a178
MaterialX: first commit
howetuft Jan 17, 2024
b12158c
Cycles: record coordinate system (as a comment)
howetuft Jan 24, 2024
c521391
Rendermesh: add tangent computation and enhance Cycles export
howetuft Jan 26, 2024
89ca674
Cycles: apply normalmap in tangent space
howetuft Jan 26, 2024
bab7742
Luxcore: normal map - assume DirectX
howetuft Jan 26, 2024
d611c27
Luxcore: textures - set gamma to 1 for normal maps
howetuft Jan 26, 2024
cf4e116
MaterialX: various improvements
howetuft Jan 26, 2024
8d0aaee
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 18, 2023
f65ad64
[pre-commit.ci] pre-commit autoupdate
pre-commit-ci[bot] Dec 25, 2023
9870aab
MaterialX: adaptations for materials without nodegraph
howetuft Feb 4, 2024
c78258f
MaterialX: enhance debug function
howetuft Feb 6, 2024
62f6e06
Cycles: update normals & tangents attributes on meshes
howetuft Feb 10, 2024
2da2faa
Mesher: use fullname when skipping meshing
howetuft Feb 11, 2024
1d6ca4f
Renderables: App::Part - do not filter on countpoints (issue with ski…
howetuft Feb 11, 2024
474edda
Skip meshing: handle missing previous meshing
howetuft Feb 11, 2024
9b500ba
Multithreaded rendering: submit chunks rather than individual objects
howetuft Feb 7, 2024
f8af552
Release GIL while meshing (version >= 0.22)
howetuft Feb 7, 2024
85b2ae6
Remove debug message
howetuft Feb 8, 2024
58e1628
Rendermesh: Rename private method
howetuft Feb 8, 2024
fe0762f
Revert "Release GIL while meshing (version >= 0.22)"
howetuft Feb 13, 2024
bae453a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 18, 2023
a47847f
[pre-commit.ci] pre-commit autoupdate
pre-commit-ci[bot] Dec 25, 2023
1bc3fcb
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 18, 2023
66bd472
[pre-commit.ci] pre-commit autoupdate
pre-commit-ci[bot] Dec 25, 2023
884bdac
MaterialX: add displacement shader
howetuft Feb 10, 2024
1b205ff
MaterialX: reimplement TextureBaker
howetuft Feb 17, 2024
29a1517
MaterialX: set license to (original) Apache 2.0
howetuft Feb 18, 2024
132b1a1
MaterialX: add setters/getters to RenderTextureBaker
howetuft Feb 18, 2024
8f0fdcd
MaterialX: vim sections in RenderTextureBaker
howetuft Feb 18, 2024
c558ece
MaterialX: optimize loop in _optimize_baked_textures
howetuft Feb 18, 2024
247eaab
MaterialX: support multi-shader materials
howetuft Feb 18, 2024
0aec2e0
MaterialX: tweak copyright commentw
howetuft Feb 19, 2024
a348fa3
MaterialX: update file comment
howetuft Feb 19, 2024
f3f3da3
Merge branch 'FreeCAD:master' into materialx
howetuft Feb 24, 2024
a45e99a
MaterialX: refactor _generate_new_document_from_shaders main loop
howetuft Feb 19, 2024
6dedd5a
materialx: split _generate_new_document_from_shaders (refactor)
howetuft Feb 23, 2024
6cc86d8
materialx: annotations
howetuft Feb 23, 2024
de3b814
MaterialX: small adjustments to materialx.py
howetuft Feb 24, 2024
f374223
Materialx: pythonicize
howetuft Feb 24, 2024
c12db3f
Materialx: pythonicize
howetuft Feb 24, 2024
e236426
Materialx: pythonicize
howetuft Feb 24, 2024
803994e
Materialx: add missing docstring
howetuft Feb 24, 2024
8d5e38c
Materialx: split _generate_new_document_from_shaders (2)
howetuft Feb 24, 2024
5514f10
MaterialX: update package.xml (python version & optional dep)
howetuft Feb 24, 2024
3c327f1
MaterialX: remove duplicate attribute definitions in baker
howetuft Feb 24, 2024
c0f6a0a
MaterialX: pythonicize dictionary
howetuft Feb 24, 2024
0b3830b
MaterialX: isolate _print method
howetuft Feb 24, 2024
78155a9
MaterialX: refactor setup_unit_system
howetuft Feb 24, 2024
fd28662
MaterialX: fix setup_unit_system
howetuft Feb 24, 2024
dbbd9c3
MaterialX: refactor/split import_materialx
howetuft Feb 25, 2024
83dde58
MaterialX: add GUI
howetuft Feb 25, 2024
6fa621c
MaterialX: add support for plain mtlx files (not zipped)
howetuft Feb 25, 2024
2894cc7
MaterialX: add (optional) destination document to import_materialx
howetuft Feb 26, 2024
9b00b0f
MaterialX: access to library (operational, but to be enhanced)
howetuft Feb 28, 2024
3429519
MaterialX: transform import_materialx into object
howetuft Feb 28, 2024
c6696d6
MaterialX: report progress and make code interruptible
howetuft Feb 29, 2024
62a9971
MaterialX: check whether MaterialX library is installed
howetuft Feb 29, 2024
b70dd20
MaterialX: add one more 'check halt requested'
howetuft Feb 29, 2024
4e8ed5e
Merge branch 'FreeCAD:master' into materialx
howetuft Feb 29, 2024
132e3fe
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 18, 2023
5c19747
[pre-commit.ci] pre-commit autoupdate
pre-commit-ci[bot] Dec 25, 2023
5d7947e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 18, 2023
d9ca5ee
[pre-commit.ci] pre-commit autoupdate
pre-commit-ci[bot] Dec 25, 2023
8dd75ea
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 18, 2023
f643842
[pre-commit.ci] pre-commit autoupdate
pre-commit-ci[bot] Dec 25, 2023
ddb37bc
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 18, 2023
34841e5
[pre-commit.ci] pre-commit autoupdate
pre-commit-ci[bot] Dec 25, 2023
d0b5ba7
MaterialX: add icons
howetuft Feb 29, 2024
a33f437
Merge branch 'FreeCAD:master' into materialx
howetuft Feb 29, 2024
ad0b4cd
Merge branch 'FreeCAD:master' into materialx
howetuft Feb 29, 2024
1c72c4c
MaterialX: set menu item for GPUOpen library
howetuft Mar 1, 2024
7873d03
MaterialX: bake images in SRGB
howetuft Mar 1, 2024
2524a22
Merge branch 'FreeCAD:master' into materialx
howetuft Mar 5, 2024
f088904
Merge branch 'FreeCAD:master' into materialx
howetuft Mar 6, 2024
d7cb6e3
MaterialX: refine test for SRGB texture
howetuft Mar 2, 2024
26b163e
Rendermesh: convert distances rather than use scale
howetuft Mar 3, 2024
51c4294
MaterialX: update todo
howetuft Mar 4, 2024
833c2ef
MaterialX: check whether MaterialX is installed
howetuft Mar 6, 2024
8d2868d
MaterialX: check whether MaterialX is installed
howetuft Mar 6, 2024
0168ac3
MaterialX: check whether MaterialX is installed
howetuft Mar 6, 2024
e01db3a
MaterialX: check whether MaterialX is installed
howetuft Mar 6, 2024
114c3d8
MaterialX: check whether MaterialX is installed
howetuft Mar 6, 2024
d3475d7
MaterialX: check whether MaterialX is installed
howetuft Mar 6, 2024
bcfa5d2
MaterialX: check whether MaterialX is installed
howetuft Mar 6, 2024
5effdb9
MaterialX: check whether MaterialX is installed
howetuft Mar 6, 2024
8f998bb
MaterialX: check whether MaterialX is installed
howetuft Mar 6, 2024
1fc90b4
MaterialX: make it as a module
howetuft Mar 6, 2024
a6307ad
MaterialX: specify target doc where to import
howetuft Mar 6, 2024
03757dd
MaterialX: enhance texture file finding
howetuft Mar 7, 2024
71daf16
MaterialX: cleaning
howetuft Mar 7, 2024
c77c0c6
Luxcore: add 1.5 factor to clearcoatgloss
howetuft Mar 7, 2024
6698341
MaterialX: add AmbientCG library
howetuft Mar 9, 2024
87f3287
MaterialX: remove downloaded file
howetuft Mar 9, 2024
dde8dda
Luxcore: reorder textures and material
howetuft Mar 9, 2024
8d5eefa
MaterialX: displacement / bump swapping
howetuft Mar 9, 2024
79decb1
MaterialX: icon for AmbientCG
howetuft Mar 10, 2024
38f7b15
Cycles: tweak bump factor
howetuft Mar 10, 2024
36d21e2
MaterialX: create dedicated menu for libraries
howetuft Mar 10, 2024
4a60d7f
MaterialX: handle 'unrecognized format'
howetuft Mar 10, 2024
471d6e3
MaterialX: enhance comments
howetuft Mar 11, 2024
5072406
MaterialX: get actual size from polyhaven.com if applicable
howetuft Mar 16, 2024
6da14d6
Merge branch 'FreeCAD:master' into materialx
howetuft Mar 17, 2024
5f4d49e
MaterialX: isolate web profile from reloading
howetuft Mar 17, 2024
3703753
MaterialX: convert actual size to meters
howetuft Mar 17, 2024
f38dc78
MaterialX: use polyhaven size when applicable
howetuft Mar 17, 2024
24fa0da
MaterialX: do not crash Render.materialx import when materialx is not…
howetuft Mar 18, 2024
0cb76ef
MaterialX: polyhaven - move message to import
howetuft Mar 18, 2024
5f866ae
MaterialX: provide installer
howetuft Mar 18, 2024
4858cf1
MaterialX: switch to PySide (instead of PySide2)
howetuft Mar 18, 2024
f66a83a
Replace PySide2 with PySide
howetuft Mar 18, 2024
8787f1b
MaterialX: propose install
howetuft Mar 19, 2024
d5c8f75
MaterialX: fix installer/uninstaller
howetuft Mar 19, 2024
9d2d26e
MaterialX: close temp file between using filename
howetuft Mar 20, 2024
b025ed5
MaterialX: check page when downloading
howetuft Mar 20, 2024
952592f
Merge branch 'FreeCAD:master' into materialx
howetuft Mar 20, 2024
542cf9e
Move PySide.QtWidgets to PySide.QtGui (https://wiki.freecad.org/PySide)
howetuft Mar 20, 2024
49aafa0
MaterialX: hide console messages
howetuft Mar 20, 2024
25cff13
MaterialX: add documentation
howetuft Mar 23, 2024
7f755ef
Linting
howetuft Mar 23, 2024
afc58a7
MaterialX: encapsulate importer in subprocess (to be completed)
howetuft Mar 26, 2024
11822c5
MaterialX: resetting progress feature
howetuft Mar 26, 2024
12818ff
MaterialX: no progress hook cornercase
howetuft Mar 26, 2024
bab5d0f
MaterialX: fix import_material target document
howetuft Mar 26, 2024
3fb0b11
MaterialX: reset disp2bump
howetuft Mar 26, 2024
7df75be
Linting
howetuft Mar 26, 2024
7f2cdcb
MaterialX: isolate converter
howetuft Mar 26, 2024
381c943
MaterialX: reset error handling
howetuft Mar 26, 2024
bf8fbbf
MaterialX: linting
howetuft Mar 26, 2024
4465cc5
MaterialX: adapt behavior to virtual environment
howetuft Apr 7, 2024
03c0945
MaterialX: install in virtual environment - 1st attempt
howetuft Apr 7, 2024
dd4738e
MaterialX: control MaterialX feature with parameters
howetuft Apr 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ init-hook='import sys; sys.path.append("/usr/lib/freecad/lib"); sys.path.append(
ignore=CVS

# Python version
# 2022-04-30: we target 3.6, same as FreeCAD 0.20
py-version=3.6
# 2024-02-15: we target 3.8, same as FreeCAD 0.21
py-version=3.8

# Pickle collected data for later comparisons.
persistent=yes
Expand All @@ -24,7 +24,9 @@ persistent=yes
# usually to register additional checkers.
load-plugins=
pylint.extensions.check_elif,
pylint.extensions.no_self_use
pylint.extensions.no_self_use,
pylint.extensions.typing,
pylint.extensions.code_style

# Use multiple processes to speed up Pylint.
jobs=2
Expand All @@ -36,15 +38,21 @@ unsafe-load-any-extension=no
# A comma-separated list of package or module names from where C extensions may
# be loaded. Extensions are loading into the active Python interpreter and may
# run arbitrary code
extension-pkg-whitelist=PySide2,
PySide,
FreeCAD,
FreeCADGui,
Part,
Draft,
ImageGui,
MeshPart,
Mesh
extension-pkg-allow-list=PySide2,
PySide,
FreeCAD,
FreeCADGui,
Part,
Draft,
ImageGui,
MeshPart,
Mesh,
MaterialX.PyMaterialXCore,
MaterialX.PyMaterialXGenShader,
MaterialX.PyMaterialXGenGlsl,
MaterialX.PyMaterialXFormat,
MaterialX.PyMaterialXRender,
MaterialX.PyMaterialXRenderGlsl


[MESSAGES CONTROL]
Expand Down
1 change: 1 addition & 0 deletions Render/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,4 @@
)
from Render.commands import RENDER_COMMANDS # noqa: F401
from Render.prefpage import PreferencesPage # noqa: F401
from Render.materialx import import_materialx # noqa: F401
183 changes: 162 additions & 21 deletions Render/commands.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ***************************************************************************
# * *
# * Copyright (c) 2017 Yorik van Havre <[email protected]> *
# * Copyright (c) 2021 Howetuft <[email protected]> *
# * Copyright (c) 2024 Howetuft <[email protected]> *
# * *
# * This program is free software; you can redistribute it and/or modify *
# * it under the terms of the GNU Lesser General Public License (LGPL) *
Expand All @@ -27,14 +27,20 @@
import os
import itertools as it

from PySide.QtCore import QT_TRANSLATE_NOOP, Qt
from PySide.QtGui import QMessageBox, QInputDialog, QApplication, QCursor
from PySide.QtCore import QT_TRANSLATE_NOOP, Qt, QUrl
from PySide.QtGui import (
QMessageBox,
QInputDialog,
QApplication,
QCursor,
QFileDialog,
)

import FreeCAD as App
import FreeCADGui as Gui
from ArchMaterial import _CommandArchMaterial

from Render.constants import ICONDIR, VALID_RENDERERS
from Render.constants import ICONDIR, VALID_RENDERERS, PARAMS
from Render.utils import translate
from Render.rdrhandler import RendererHandler
from Render.taskpanels import MaterialSettingsTaskPanel
Expand All @@ -49,6 +55,10 @@
)
from Render.rendermaterial import is_multimat
from Render.help import open_help
from Render.materialx import (
import_materialx,
open_mxdownloader,
)


class RenderProjectCommand:
Expand Down Expand Up @@ -336,15 +346,23 @@ class MaterialCreatorCommand(_CommandArchMaterial):
This class is partially based on Arch 'ArchMaterial' command.
"""

def __init__(self, newname=False):
"""Init command."""
self._newname = bool(newname)

def GetResources(self):
"""Get command's resources (callback)."""
res = super().GetResources()
res["MenuText"] = QT_TRANSLATE_NOOP(
"MaterialCreatorCommand", "Create Material"
res["MenuText"] = (
QT_TRANSLATE_NOOP(
"MaterialCreatorCommand", "Internal Material Library"
)
if self._newname
else QT_TRANSLATE_NOOP("MaterialCreatorCommand", "Create Material")
)
res["ToolTip"] = QT_TRANSLATE_NOOP(
"MaterialCreatorCommand",
"Create a new Material in current document",
"Create a new Material in current document from internal library",
)
return res

Expand All @@ -365,6 +383,101 @@ def Activated(self):
App.ActiveDocument.commitTransaction()


class MaterialMaterialXImportCommand:
"""GUI command to import a MaterialX material."""

def GetResources(self): # pylint: disable=no-self-use
"""Get command's resources (callback)."""
return {
"Pixmap": os.path.join(ICONDIR, "materialx-stacked-black.svg"),
"MenuText": QT_TRANSLATE_NOOP(
"MaterialMaterialXImportCommand",
"Import MaterialX file",
),
"ToolTip": QT_TRANSLATE_NOOP(
"MaterialMaterialXImportCommand",
"Import a material from MaterialX file",
),
}

def Activated(self): # pylint: disable=no-self-use
"""Respond to Activated event (callback).

This code is executed when the command is run in FreeCAD.
It opens a dialog to set the rendering parameters of the selected
material.
"""
filefilter = "MaterialX (*.mtlx *.zip);;All files (*.*)"
caption = translate("Render", "Select MaterialX")
openfilename = QFileDialog.getOpenFileName(
Gui.getMainWindow(), caption, "", filefilter
)
materialx_file = openfilename[0]
if not materialx_file:
return
App.ActiveDocument.openTransaction("MaterialXImport")
import_materialx(materialx_file, Gui.ActiveDocument.Document)
App.ActiveDocument.commitTransaction()


class MaterialMaterialXLibrary:
"""GUI command to open MaterialX online library."""

def GetResources(self): # pylint: disable=no-self-use
"""Get command's resources (callback)."""
return {
"Pixmap": os.path.join(ICONDIR, "amdgpuopen.png"),
"MenuText": QT_TRANSLATE_NOOP(
"MaterialMaterialXImportCommand",
"GPUOpen Material Library",
),
"ToolTip": QT_TRANSLATE_NOOP(
"MaterialMaterialXImportCommand",
"Open AMD GPUOpen Material Library",
),
}

def Activated(self): # pylint: disable=no-self-use
"""Respond to Activated event (callback).

This code is executed when the command is run in FreeCAD.
It opens a dialog to set the rendering parameters of the selected
material.
"""
doc = App.ActiveDocument
url = QUrl("https://matlib.gpuopen.com/")
open_mxdownloader(url, doc)


class MaterialAmbientCGLibrary:
"""GUI command to open AmbientCG online library."""

def GetResources(self): # pylint: disable=no-self-use
"""Get command's resources (callback)."""
return {
"Pixmap": os.path.join(ICONDIR, "ambientcg.png"),
"MenuText": QT_TRANSLATE_NOOP(
"MaterialMaterialXImportCommand",
"AmbientCG Material Library",
),
"ToolTip": QT_TRANSLATE_NOOP(
"MaterialMaterialXImportCommand",
"Open AmbientCG Material Library",
),
}

def Activated(self): # pylint: disable=no-self-use
"""Respond to Activated event (callback).

This code is executed when the command is run in FreeCAD.
It opens a dialog to set the rendering parameters of the selected
material.
"""
doc = App.ActiveDocument
url = QUrl("https://ambientcg.com/")
open_mxdownloader(url, doc, disp2bump=True)


class MaterialRenderSettingsCommand:
"""GUI command to set render settings of a material object."""

Expand Down Expand Up @@ -613,25 +726,53 @@ def add_command(name, action):
lights_group = CommandGroup(lights_cmd, "Lights", "Create a Light")

mats_cmd = [
("MaterialCreator", MaterialCreatorCommand()),
("MaterialRenderSettings", MaterialRenderSettingsCommand()),
("MaterialApplier", MaterialApplierCommand()),
("MaterialRenderSettings", MaterialRenderSettingsCommand()),
]
materials_group = CommandGroup(mats_cmd, "Materials", "Manage Materials")

render_commands = [
("Projects", projects_group),
separator,
("Camera", CameraCommand()),
("Lights", lights_group),
("View", RenderViewCommand()),
("Materials", materials_group),
separator,
("Render", RenderCommand()),
separator,
("Settings", SettingsCommand()),
("Help", HelpCommand()),
libs_cmd = [
("MaterialMaterialXLibrary", MaterialMaterialXLibrary()),
("MaterialAmbientCGLibrary", MaterialAmbientCGLibrary()),
("MaterialCreator", MaterialCreatorCommand()),
("MaterialMaterialXImporter", MaterialMaterialXImportCommand()),
]
libraries_group = CommandGroup(
libs_cmd, "Libraries", "Download from material libraries"
)

if PARAMS.GetBool("MaterialX"):
render_commands = [
("Projects", projects_group),
separator,
("Camera", CameraCommand()),
("Lights", lights_group),
("View", RenderViewCommand()),
separator,
("Libraries", libraries_group),
("Materials", materials_group),
separator,
("Render", RenderCommand()),
separator,
("Settings", SettingsCommand()),
("Help", HelpCommand()),
]
else:
mats_cmd.insert(0, ("MaterialCreator", MaterialCreatorCommand()))
render_commands = [
("Projects", projects_group),
separator,
("Camera", CameraCommand()),
("Lights", lights_group),
("View", RenderViewCommand()),
separator,
("Materials", materials_group),
separator,
("Render", RenderCommand()),
separator,
("Settings", SettingsCommand()),
("Help", HelpCommand()),
]

result = []

Expand Down
2 changes: 2 additions & 0 deletions Render/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
# Paths
PKGDIR = os.path.dirname(__file__) # Package directory (=this file directory)
WBDIR = os.path.dirname(PKGDIR) # Workbench root directory
USERAPPDIR = App.getUserAppDataDir()
RDRDIR = os.path.join(PKGDIR, "renderers")
ICONDIR = os.path.join(PKGDIR, "resources", "icons")
TEMPLATEDIR = os.path.join(WBDIR, "templates")
Expand All @@ -41,6 +42,7 @@
TRANSDIR = os.path.join(PKGDIR, "resources", "translations")
PREFPAGE = os.path.join(PKGDIR, "resources", "ui", "RenderSettings.ui")
TASKPAGE = os.path.join(PKGDIR, "resources", "ui", "RenderMaterial.ui")
VENVDIR = os.path.join(USERAPPDIR, ".render_venv") # Virtual environment

# Renderers lists
RENDERERS = {
Expand Down
6 changes: 3 additions & 3 deletions Render/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@

import os.path

from PySide2.QtWebEngineWidgets import (
from PySide.QtWebEngineWidgets import (
QWebEngineView,
QWebEngineScript,
QWebEnginePage,
)
from PySide2.QtCore import QUrl
from PySide2.QtWidgets import QWidget, QToolBar, QVBoxLayout
from PySide.QtCore import QUrl
from PySide.QtGui import QWidget, QToolBar, QVBoxLayout

import FreeCADGui as Gui
import FreeCAD as App
Expand Down
7 changes: 4 additions & 3 deletions Render/material.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,13 @@
from Render.utils import translate, warn


def make_material(name="Material", color=None, transparency=None):
def make_material(name="Material", color=None, transparency=None, doc=None):
"""Make an Material object."""
if not App.ActiveDocument:
doc = doc or App.ActiveDocument
if not doc and not App.ActiveDocument:
App.Console.PrintError("No active document. Aborting\n")
return None
obj = App.ActiveDocument.addObject("App::MaterialObjectPython", "Material")
obj = doc.addObject("App::MaterialObjectPython", "Material")
obj.Label = name
Material(obj)
if App.GuiUp:
Expand Down
27 changes: 27 additions & 0 deletions Render/materialx/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# ***************************************************************************
# * *
# * Copyright (c) 2024 Howetuft <[email protected]> *
# * *
# * This program is free software; you can redistribute it and/or modify *
# * it under the terms of the GNU Lesser General Public License (LGPL) *
# * as published by the Free Software Foundation; either version 2 of *
# * the License, or (at your option) any later version. *
# * for detail see the LICENCE text file. *
# * *
# * This program is distributed in the hope that it will be useful, *
# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
# * GNU Library General Public License for more details. *
# * *
# * You should have received a copy of the GNU Library General Public *
# * License along with this program; if not, write to the Free Software *
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
# * USA *
# * *
# ***************************************************************************

"""This module gathers public MaterialX handling features."""

from .materialx_importer import MaterialXImporter, import_materialx
from .materialx_downloader import MaterialXDownloader, open_mxdownloader
from .materialx_installer import RENDERVENV
Loading
Loading