import bpy, sys, importlib.util fails=[] # ---------- ROCK ---------- spec=importlib.util.spec_from_file_location("srg", r"A:\eco\stylized_rock_generator\stylized_rock_generator.py") r=importlib.util.module_from_spec(spec); sys.modules["srg"]=r; spec.loader.exec_module(r) try: r.unregister() except Exception: pass r.register() s=bpy.context.scene.rock_gen_settings before=(s.seed, round(s.noise_scale,3), round(s.displace_strength,3), round(s.decimate_ratio_1,3)) s.random_amount=0.5 bpy.ops.rockgen.randomize() after=(s.seed, round(s.noise_scale,3), round(s.displace_strength,3), round(s.decimate_ratio_1,3)) print("ROCK vorher:", before) print("ROCK nachher:", after) if before==after: fails.append("rock_randomize_ohne_wirkung") # Grenzen eingehalten? if not (0.01<=s.noise_scale<=10 and 0<=s.displace_strength<=2 and 0.01<=s.decimate_ratio_1<=1): fails.append("rock_grenzen") # Erzeugt der Rock danach noch gueltige Geometrie? for o in list(bpy.data.objects): bpy.data.objects.remove(o,do_unlink=True) s.batch_count=1; s.use_modal=False; s.subsurf_levels=3 res=bpy.ops.object.generate_rocks_batch() meshes=[o for o in bpy.context.scene.objects if o.type=='MESH'] print("ROCK nach Randomize erzeugt:", [o.name for o in meshes], "faces=", len(meshes[0].data.polygons) if meshes else 0) if not meshes or len(meshes[0].data.polygons)==0: fails.append("rock_leer") r.unregister() # ---------- TREE ---------- for o in list(bpy.data.objects): bpy.data.objects.remove(o,do_unlink=True) spec2=importlib.util.spec_from_file_location("stg", r"A:\eco\stylized_rock_generator\stylized_tree_generator.py") t=importlib.util.module_from_spec(spec2); sys.modules["stg"]=t; spec2.loader.exec_module(t) try: t.unregister() except Exception: pass t.register() ts=bpy.context.scene.tree_gen_settings ts.preset='birke'; ts.art_name="Birke"; ts.variant=1; ts.use_growth=False ts.make_leaf=True; ts.make_frucht=True; ts.random_amount=0.5 ts.seed=0 bpy.ops.object.treegen_randomize() print("TREE Seed nach Randomize:", ts.seed) if ts.seed==0: fails.append("tree_seed") bpy.ops.object.treegen_create() names=sorted(o.name for o in bpy.context.scene.objects) print("TREE Objekte:", names) if not {"Birke_01","Birke_01_Leaf","Birke_01_Frucht"} <= set(names): fails.append("zusatz_ebenen") # Ursprung identisch? base=bpy.context.scene.objects["Birke_01"]; leaf=bpy.context.scene.objects["Birke_01_Leaf"] d=(base.location-leaf.location).length print("URSPRUNG-Abstand Stamm<->Leaf: %.6f" % d) if d>1e-6: fails.append("ursprung_leaf") # Zwei Randomize-Durchlaeufe -> unterschiedliche Geometrie? def height(): ev=bpy.context.scene.objects["Birke_01"].evaluated_get(bpy.context.evaluated_depsgraph_get()) zs=[v.co.z for v in ev.data.vertices]; return round(max(zs)-min(zs),3) h1=height() bpy.ops.object.treegen_randomize(); bpy.ops.object.treegen_create() h2=height() print("TREE Hoehe Lauf1=%.3f Lauf2=%.3f" % (h1,h2)) if abs(h1-h2)<1e-4: fails.append("tree_keine_variation") t.unregister() print("ERGEBNIS:", "ALLE CHECKS OK" if not fails else "FEHLER: "+", ".join(fails)) sys.exit(1 if fails else 0)