1
$\begingroup$

Here is what I'm trying to do:

  1. Make a LODGroup Empty object ("fbx_type":"LodGroup").
  2. Import an asset
  3. Parent the asset to the lod group.
  4. Duplicate (important: original asset not decimated asset), and decimate asset. Parent it also.
  5. Repeat 4 until x many LODS.

Here is my code so far:

import bpy
import os.path
from os import path

main_dir="D:\\Documents\\Megascans Library\\Downloaded\\3d\\rock_assembly_siuw3"
model_id=main_dir.split("\\")[-1].split("_")[-1]

bpy.ops.object.empty_add(type="PLAIN_AXES", radius=1, location=(0, 0, 0))

lod_group = bpy.context.active_object
lod_group.name="LODGroup"
lod_group["fbx_type"]="LodGroup"

print(main_dir+"\\"+model_id+"_High.fbx")

if os.path.exists(main_dir+"\\"+model_id+"_High.fbx"):
    bpy.ops.import_scene.fbx(filepath=main_dir+"\\"+model_id+"_High.fbx")

My issue is that bpy.context.active_object doesn't point to the imported fbx after importing and as such I can't parent it to my LODGroup.

$\endgroup$
2
  • $\begingroup$ Suggest try: print (bpy.context.selected_objects[0]), related: blender.stackexchange.com/q/176104/31447 ... btw: How to decimate the asset? Using the decimate modifier or remesh? $\endgroup$
    – brockmann
    Aug 22, 2020 at 8:43
  • $\begingroup$ @brockmann Yes bpy.context.selected_objects[0] works! I didn't want to know the command for decimating I do know that thankfully. $\endgroup$
    – Apoqlite
    Aug 22, 2020 at 8:52

0

You must log in to answer this question.

Browse other questions tagged .