Me And GPT - The Flower Maker

goggle_eyes.PNG

The artificial intelligence revolution has gained momentum in the last twelve months, first with the advent of Chat GPT and Microsoft Bing's AI, Prometheus. Some people believe this is the beginning of the end, the start of the singularity, the point at which computers become smarter than us and decide to take over and run the whole show.

However I'm not so sure, my personal interactions with it have had mixed results, whilst using it for my writing, I've also been curious to try it out on other things I'm either not familiar with or have a vague understanding of, to see if GPT can fill in the blanks of my knowledge.

Here is my chat with GPT whilst trying to get it to write a Python script within the graphics program Blender. For me it was like talking to a genius with Alzheimer's disease.

GPT Chat - Design A Flower In Blender

Me - Tell me how to create a simple flower in Blender

GPT -
Sure, I'd be happy to help! Here are the steps to create a simple flower in Blender:

(Explains the 15 steps to create a flower)

Me - Is it possible to write a python script for this, in order to feed into blender?

GPT - Yes, it is possible to write a Python script in Blender to automate the creation of a flower. Here is an example script that creates a flower with three layers of petals and a yellow bulb:

(provides Python code for flower)

Me - Line 9 of the code failed (bmesh.ops.create_circle(bm, segments=32, diameter=1) any idea why?

GPT - The error you're encountering with line 9 of the code is likely because the bm object is not defined before this line is executed. The bm object is created on line 6 with bm = bmesh.new(), so make sure that line is executed before line 9.

If you're still encountering errors, it's possible that there may be other issues with the code. Double-check that you've copied the code correctly and that there are no syntax errors or typos.

If you're still having trouble, please let me know the specific error message you're seeing and any other relevant information, and I'll do my best to help you troubleshoot the issue.

At this point I realised that because GPT is only updated to September 2021, it probably needed to see the changes in Blender.

Me - The script doesn't work, could it be because you are working from an old version of Blender? Or should the script be ubiquitous through all versions?

GPT - The script I provided should be compatible with all recent versions of Blender, including Blender 2.8 and later. However, it's possible that there may be some minor differences in how certain functions or modules are used in different versions of Blender.

If the script isn't working for you, it's possible that there may be an issue with your Blender installation or configuration, or there may be some other problem that's specific to your system. I would recommend checking the console output for any error messages or warnings that might help you identify the issue.

Alternatively, if you let me know what error messages or issues you're encountering, I may be able to help you troubleshoot the problem.

Me - I've updated to the latest Blender and I'm still getting a problem with line 9, even though the bmesh is defined.

The error I get says this: (provided error)
"

And my code looks like this: (copy and pasted code from earlier GPT suggestion)

GPT - It looks like the create_circle operator no longer supports the diameter keyword argument in the latest version of Blender. Instead, you can use the radius argument to specify the radius of the circle.

Try changing line 9 to the following:

python
Copy code
bmesh.ops.create_circle(bm, segments=32, radius=0.5)
This should create a circle with a radius of 0.5 units.

Let me know if you have any other issues or questions!

Me - It neither supports 'size' or diameter

GPT - I apologize for the confusion. It seems that the create_uvsphere operator has changed again in the latest version of Blender.

Try changing line 24 to the following:

python
Copy code
bmesh.ops.create_uvsphere(bm, u_segments=32, v_segments=16, diameter=0.3)
This should create a UV sphere with a diameter of 0.3 units.

Let me know if you have any other issues or questions!

As you can see, GPT decided to use the 'diameter' argument again, so I went onto the Stack Exchange to find out what argument has replaced 'diameter'

Me - Okay, I've been onto Stack Exchange and seen a similar question to mine, the answer is below, can you make sense of it and rewrite line 24 and correct any other mistakes in the flower code?
(Stack answer provided)

GPT - Yes, the answer on Stack Exchange is correct. Here's how you can get the dimensions of a mesh in Blender using Python:

First, select the object that you want to get the dimensions of.

In the Python console, type:

python
Copy code
import bpy

Get the active object
obj = bpy.context.active_object

Get the dimensions of the object
dimensions = obj.dimensions

Print the Y dimension of the object
print(dimensions.y)
This will print the Y dimension of the selected object.

To use this in your flower script, you can replace line 24 with the following:

python
Copy code
petals_obj.scale.y = petals_obj.dimensions.y * 0.8
This will set the scale of the petals object's Y axis to 80% of its actual Y dimension. You can adjust the scaling factor as needed.

Also, in line 9, you can remove the bm variable and directly create the circle using the bmesh module like this:

python
Copy code
bmesh.ops.create_circle(
bmesh.new(),
segments=32,
radius=0.5,
fill_type='NGON'
)
This will create a circle with a radius of 0.5 units and a fill type of NGON.

Me - Thanks, can you do that for me please and rewrite the code with the changes

GPT - Certainly! Here's the modified code with the changes to line 24 and the addition of code to get the height of the petals object:
(provides adjusted code)

This is where my will to live started slipping away.

Me - You've still used the word 'diameter'!!!! Which, along with 'size' are no longer acceptable terms. Do you need me to search a solution? If so, do you know how I should phrase my search term?

GPT - I apologize for the mistake. It seems that the diameter parameter has been removed from the bmesh.ops.create_uvsphere() operator in Blender 2.80 and later versions, and size is also not a valid parameter.

To create a UV sphere with a specific radius, you can instead use bmesh.ops.create_uvsphere() with a scale parameter. Here's an updated version of the code that should work:

Me - I can already see you have reused the word diameter, it will not run. 🤦🏾‍♂️

GPT - I apologize for the mistake. Here is the corrected version of the code with the appropriate changes to the sphere creation:
(provides code)

Me - For the love of god, can you explain this line for me [bmesh.ops.create_uvsphere(bm, u_segments=32, v_segments=16, diameter=0.6)
] Why have you used u_segments and v_segments but used 'diameter=' for the last part?

GPT -
The bmesh.ops.create_uvsphere operator in Blender's Python API creates a UV sphere with the specified parameters. The u_segments and v_segments arguments determine the number of segments in the U and V directions, respectively, which affects the resolution of the sphere. The diameter argument sets the diameter of the sphere.

So in the example code, bmesh.ops.create_uvsphere(bm, u_segments=32, v_segments=16, diameter=0.6) creates a UV sphere with 32 segments in the U direction, 16 segments in the V direction, and a diameter of 0.6.

Me - Okay, but as you know, per our recent conversations in the last couple of bloody minutes. BLENDER DOES NOT USE THE DIAMETER ARGUMENT ANYMORE!!!!

GPT - I see. In that case, you can use the size argument instead of diameter. Here's the updated code:

Me - As we've also ascertained, it does not accept the 'size' argument either. Is it possible to give x,y.z coordinates instead?

GPT - Yes, you can use the bmesh.ops.create_uvsphere function with the radius argument instead of diameter. Here's an updated version of the code using x, y, and z coordinates to position the flower:
(provides code)

Me - Okay, but can you change the size of the UV sphere using xyz coordinates instead of the radius argument? Because that doesn't work either.

GPT - Yes, you can change the size of the UV sphere using the x, y, z coordinates instead of the diameter or radius. You can use the scale method of the sphere object to do this. Here's an example:

(provides code)

In this example, the scale method is used to set the x, y, and z scale values of the sphere object to (2.0, 1.5, 1.0), which will stretch the sphere along the x-axis and y-axis while leaving the z-axis at its original size. You can adjust these values to change the size and shape of the sphere as desired.

Me - The code is still not working. I think you need to see the change log. I can show it to you, what part would you need to see in order to correct the errors in your previous code attempts?

GPT - Yes, please share the change log and highlight the part where the error occurred, so I can better understand the issue and correct the code accordingly.

Me - Okay, the code you wrote for me is the following: (provides code) The error returned was this (copies error)

And this is the changelog for object operators. Please use this info to rewrite the code, if you need to see a different part of the changelog, guide me to the part you think you'll need.

GPT - Thank you for providing the error message and the changelog. Based on the changelog, it looks like the create_uvsphere operator has been updated to use the segments argument instead of u_segments and v_segments. Additionally, the radius argument is now used instead of diameter.

Here's the updated code that should work.
(provides code still containing the argument 'diameter') 🤦🏾‍♂️

Me - If I give you a web link can you read the changelog? It is too big to paste here

GPT - Sure, I can access the web link and read the changelog for you. Please provide me with the link.

Me - (provides link)

GPT - Thank you for providing the link. Based on the changelog, it appears that the create_circle() operator no longer accepts the diameter argument. Instead, you can use the radius argument to define the radius of the circle.

Here's the updated code:
I hope this works for you. Let me know if you have any other questions or concerns!

Me - There is an error returning it says this: bpy.ops.text.run_script()
Python: Traceback (most recent call last):
File "\Text", line 31,
ValueError: bpy_struct: item.attr = val: sequences of dimension 0 should contain 4 items, not 3

GPT - It seems like the error is caused by passing a vector of 3 items to a function that expects a vector of 4 items. One possible culprit could be the line mat.diffuse_color = (1, 1, 0) where you're trying to set the color to yellow.

Try changing that line to mat.diffuse_color = (1, 1, 0, 1) to include the alpha value (opacity) and see if it fixes the error.

Me - rewrite the code with this fix in it

GPT - Sure, here's the updated code with the fix: (code)
Note that I've changed the diameter of the UV sphere to 1 and then scaled it down to 0.3, to make it equivalent to a diameter of 0.6. This is because the create_uvsphere operator does not accept the diameter argument, but instead creates a sphere with a radius of 0.5 and then scales it according to the given dimensions.

Me - NO, write the code you did before this one, but this time highlight the mat.diffuse_color = for me

GPT - Sure, here is the code you previously requested with the mat.diffuse_color line highlighted:

Me - Okay, it works, however I just have a faceted sphere and the 'petals' are just a circle around the sphere, it doesn't look very flower like

GPT - If you want to give the petals a more flower-like shape, you can modify the vertices of the circle to make it more elliptical or add some variation to the petals. Here's an example of how you could modify the code to achieve that: (code with 'diameter' argument added back in! 🤦🏾‍♂️)

In this modified version of the code, I added a loop to modify the vertices of the circle to give it an elliptical shape, and also added another loop to add some random variation to the petals. This should result in a flower shape that looks more natural and less faceted.

Me - Please rewrite similar to the first iteration, whereby you did not use the 'diameter' argument. I had this error return:

Python: Traceback (most recent call last):
File "\Text", line 34,
TypeError: create_uvsphere: keyword "diameter" is invalid for this operator

GPT - Sure! Here's a modified version of the previous code without the diameter argument:

Result



This is the "flower" GPT created for me

image.png

Conclusion

As you can see from above, the object looks nothing like a flower and in fact I still had to correct the code manually as it still did not add four vector values.

The whole conversation was maddening as even though it acknowledged several times that it knew the 'diameter' argument was no longer used in Blender, it still persisted in using it.

So as far as I can see, ChatGPT is as far from science fiction AI, as a bicycle is from a Ferrari. It will not suddenly turn you into a coding genius, in fact, unless you have a wealth of knowledge yourself, you will not be able to code anything using GPT.

Find out next time if I managed to get it to code a more simple object.

HAVE YOU USED GPT? DID IT WORK FOR YOU? LET ME KNOW BELOW!

Cryptogee

H2
H3
H4
3 columns
2 columns
1 column
Join the conversation now
Logo
Center