![]() |
Warning: Long read! (15 min) |
Preparation
Before prompting the LLM, I first identified the lines that needed upgrading
myself. 2.78 already uses Bmesh, so the list is fairly short:
- minimal version number in bl_info
- property definitions
properties defined in an operator used to be assigned to class variables. we
still have class variables but now these property types are added as
annotations, i.e. we need to change the equal character to a colon.
- the menu where we add the operator changed
from the info area to the view3d area
- the way we create uv and vertex color layers
attribute access has changed quite a bit, so this needs a careful check
- vertex colors now have alpha,
so contain 4 components, not 3.
Prompting
With this in mind I provided it with the following prompt:
Suggest all steps needed to port this add-on to Blender 4.4
this got me a long list of very generic bits of advice, even though it had
drystone.py in its context. Pretty useless, but maybe I should have made it
more specific I wanted concrete suggestions for code changes. It did make the
following suggestion though:
Would you like a review of the drystone.py code for common compatibility issues?
to which I replied yes and got again a large amount of verbal diarrhea and
another question:
Would you like a code review of drystone.py to identify specific lines that may need updating?
my 'yes' finally got me this list (originally in markdown, edited to fit the
HTML of this blog):
Suggested changes
Here are the main Blender 4.4 compatibility issues found in drystone.py, with
specific lines and update suggestions:
1. bl_info Version
Line: "blender": (2, 78, 0),
Update: Change to
"blender": (4, 4, 0),
2. Property Definitions (Deprecated)
Lines: Inside `class DryStone`, e.g.
xsub = IntProperty(...)
ysub = IntProperty(...)
...
randomuv = BoolProperty(...)
Update: Define properties as class annotations using
`bpy.props`:
xsub: bpy.props.IntProperty(...)
ysub: bpy.props.IntProperty(...)
...
randomuv: bpy.props.BoolProperty(...)
3. Menu Registration
Lines:
bpy.types.INFO_MT_mesh_add.append(menu_func)
bpy.types.INFO_MT_mesh_add.remove(menu_func)
Update:
Blender 2.80+ uses
bpy.types.VIEW3D_MT_mesh_add.
Update both lines:
bpy.types.VIEW3D_MT_mesh_add.append(menu_func)
bpy.types.VIEW3D_MT_mesh_add.remove(menu_func)
4. UV and Vertex Color Layer Creation
Lines:
me.uv_textures.new()
uv_layer = me.uv_layers.active.data
vertex_colors = me.vertex_colors.new().data
Update: For Blender 2.80+ and 4.x, use:
if not me.uv_layers: me.uv_layers.new()
uv_layer = me.uv_layers.active.data
if not me.vertex_colors: me.vertex_colors.new()
vertex_colors = me.vertex_colors.active.data
5. Operator Registration
Lines:
bpy.utils.register_class(DryStone)
bpy.utils.unregister_class(DryStone)
Note: This is correct, but ensure all operator and menu functions are
registered/unregistered.
6. Other Minor Adjustments
- Confirm all `bpy.context` and `bpy.ops` usage is compatible with Blender 4.4’s context requirements.
- Check for any new warnings/errors after updating.
Summary Table:
Issue | Old Code Example | Update To |
---|---|---|
bl_info version | (2, 78, 0) | (4, 4, 0) |
Property definition | xsub = IntProperty(...) | xsub: bpy.props.IntProperty(...) |
Menu type | INFO_MT_mesh_add | VIEW3D_MT_mesh_add |
UV/vertex color layers | me.uv_textures.new(), me.vertex_colors.new() | me.uv_layers.new(), me.vertex_colors.new() |
Next Steps:
- Apply above changes.
- Test the add-on in Blender 4.4 and check the console for new warnings or errors.
- Fix any additional API changes found in testing. Let me know if you want line-by-line code examples for any of these changes!
Observations
The first four are spot on, and the table is a nice touch, but it missed the
fact that vertex colors now have alpha. And why it produces the useless* extra
points and next steps is a mystery to me. Even though GitHub Copilot is free.
you would think it is paid by the token.
Oh, and answering 'yes' to its last question simply repeats everything in
slightly different wording but still misses the vertex color issue.
*) useless, because if something is correct already there is no need for
the advice in point 5, and those minor adjustments are not adjustments but
bits of common sense, so suggesting them is a waste of time.
Conclusion
Is it useful? for a beginner maybe, but if you know what changed over time
doing it yourself is just as fast and even better, and you don't have to read
an avalanche of extraneous drivel.
No comments:
Post a Comment