Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 8 additions & 1 deletion 2gltf2.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
bpy.ops.import_mesh.ply(filepath=current_argument)

if current_extension == ".stl":
bpy.ops.import_mesh.stl(filepath=current_argument)
bpy.ops.wm.stl_import(filepath=current_argument)

if current_extension == ".usd" or current_extension == ".usda" or current_extension == ".usdc":
bpy.ops.wm.usd_import(filepath=current_argument)
Expand All @@ -91,6 +91,13 @@

#

mat = bpy.data.materials.new("Blue")
mat.use_nodes = True
mat.node_tree.nodes["Principled BSDF"].inputs["Base Color"].default_value = (0.1, 0.3, 0.8, 1.0)
mat.diffuse_color = (0.1, 0.3, 0.8, 1.0)

bpy.context.active_object.active_material = mat

export_file = current_directory + "/" + current_basename + ".gltf"
print("Writing: '" + export_file + "'")
bpy.ops.export_scene.gltf(filepath=export_file)
2 changes: 1 addition & 1 deletion 2gltf2.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
if [ "$#" = 1 ]
then
blender -b -P 2gltf2.py -- "$1"
blender -b -P $(dirname $0)/2gltf2.py -- "$1"
else
echo To glTF 2.0 converter.
echo Supported file formats: .abc .blend .dae .fbx. .obj .ply .stl .usd .wrl .x3d
Expand Down