0

Im ultra new to blender and am using v2.81 to create some poses for a game mod.

Can someone please correct this script below so that it will compile in v2.81 as it wont compile based on the format..and i have no clue after reading up for hours about the known script error in v2.8 i just cant get my head around the issue. i do not understand scripting or coding very well despite trying to fix this all night. Also i cannot understand the blender versions below 2.8 for creating poses seem so clunky compared to the newer version,no camera navigation without pain!!!no easy way of moving bones without a nightmare .. otherwise my script would compile in earlier versions but i just cant create the poses anywhere near as accurately or as fast as in v2.81

This is where the compile error is in the log:

SelectedObject = bpy.context.scene.objects.active
Armatura = SelectedObject.data

Appreciate any help Thanks

batFINGER
  • 84,216
  • 10
  • 108
  • 233
ZMD
  • 1
  • 1
  • Why are you coding if you're not good at it? And add the whole script. – Lukasz-40sth Dec 04 '19 at 09:31
  • 1
  • 3
    @Lukasz-40sth Perhaps to learn? Please be nice to other users. – Robert Gützkow Dec 04 '19 at 12:09
  • 1
    @ZMD, a few things that improve one's experience on this site: The titles should be descriptive. No point mentioning you are a begginer, or that you need help - that's obvious. You should state your question in the title. Try not to use incorrect terminology. No 'format error', 'compile error', or a 'log' , no compiling here. You should get AttributeError: 'bpy_prop_collection' object has no attribute 'active' in the System or Python Console running that code, you should post the error message if you ask about it and other details. People will be nicer to you if you form questions well. – Martynas Žiemys Dec 04 '19 at 12:57
  • @ Lukasz-40sth : Becuase im fairly good at game modding and require a slight adjustment to a template pre made script for my pose script to compile;) I would like to learn sure..but for now I am focused on the mod side and require a quick fix for my issue. Thank you for your reply – ZMD Dec 04 '19 at 14:03
  • Possbly not a duplicate in that it is not setting the active object but getting it ... however replacing scene.objects.active with view_layer.objects.active will solve the issue in 2.8x. Or use context.object as answered below. – batFINGER Dec 04 '19 at 14:25

1 Answers1

0

Use bpy.context.object instead of bpy.context.scene.objects.active that does not work in 2.8x.

Works fine in 2.81:

enter image description here

Martynas Žiemys
  • 24,274
  • 2
  • 34
  • 77
  • @ Martynas Žiemys Thankyou however that throws up the same compile error .I am using v2.81 not 2.8 – ZMD Dec 04 '19 at 14:04
  • here is the script error:AttributeError: bpy_prop_collection object has no attribute active – ZMD Dec 04 '19 at 14:09
  • @ZMD using ob = context.object and armature = ob.data as suggested above, will not throw that error. There is no collection (like scene.objects and no property "acitve" like in scene.objects.active. – batFINGER Dec 04 '19 at 14:20
  • @ Martynas Žiemys Ok thanks so this would be the correct formatting : SelectedObject = bpy.context.object Armatura = Object.data – ZMD Dec 04 '19 at 14:58
  • error: object is not defined .. – ZMD Dec 04 '19 at 15:02
  • Works fine as you can see in the gif. That's 2.81 official release. – Martynas Žiemys Dec 04 '19 at 16:43
  • Fair enough but not working for me..thanks anyway – ZMD Dec 04 '19 at 18:43