0
$\begingroup$

I am creating a lattice through the Blender API and I want to change the resolution when I create it:

collection = bpy.context.collection

lattice = bpy.data.lattices.new("Lattice")
lattice_ob = bpy.data.objects.new("Lattice", lattice)
lattice_ob.scale = (224, 352, 224)
lattice_ob.location = (112,176,112)

I am trying to change the resolution of my lattice by using:

lattice_ob.points_u = 10
lattice_ob.points_v = 10
lattice_ob.points_w = 10

I get the error

AttributeError: 'Object' object has no attribute 'points_u'
$\endgroup$

1 Answer 1

2
$\begingroup$

It's the data part of the lattice.

Just like vertices belong to a mesh, the resolution belongs to a lattice ID object, bpy.data.lattices which is the data part of the lattice object.

lattice_ob.data.points_u = 10

or as defined in question code

lattice.points_u = 10

Any property seen in the DATA part of the properties panel belongs to the data part of the object of its given type. In this case bpy.types.Lattice object being the data of bpy.types.Object.type == 'LATTICE'. `

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.