¢hris £und Posted May 10 Share Posted May 10 (edited) Ok. Just started playing with chatGPT. I asked it to generate a python script for formZ. It was able to create something after I directed it to the python documentation page. Note, it really didn't work. But, I am pretty sure that this is because the documentation is not remotely complete at this time. So, chatGPT made some reasonable assumptions. Such as there being a function or method "modeler.document()" There is none. Regardless, This is looks like a way to rough out ideas to clean up on. chatGPT prompt: please provide me with a python script for formZ that generates 10 cubes each increasing in size by 10 percent starting with a volume of 1 cubic foot. Here is the formZ/python API documentation. import math from formZ import modeler # Create a new document doc = modeler.Document() # Set the units to feet doc.units = modeler.Document.UNITS_FEET # Create a group for the cubes group = modeler.Group("Cubes") # Define the starting cube size and volume cube_size = 1.0 cube_vol = cube_size ** 3 # Create 10 cubes for i in range(10): # Create a new cube cube = modeler.Cube(modeler.Vector3(0, 0, 0), cube_size) # Add the cube to the group group.add_object(cube) # Increase the size of the next cube by 10 percent cube_size *= 1.1 # Calculate the volume of the cube cube_vol = cube_size ** 3 # Add the group to the document doc.add_object(group) # Save the document doc.save("cubes.fmz") chatGPT description of its generated code: This script uses the formZ Python API to create a new document, set the units to feet, create a group for the cubes, and then create 10 cubes, each increasing in size by 10 percent and starting with a volume of 1 cubic foot. The script then adds the group to the document and saves it as "cubes.fmz". Again, this code will NOT work. But Later this week I am going to mess with it to see what it will take to make it work. I am going try to find out what will be the minimal changes. Some things I see right now are: Input statement is not correct (or I don't think this is an option right now.) as mentioned above "doc = modeler.Document()" isn't a call or at least not currently implemented in the API. I think chatGPT is making an assumption based on how other APIs for python work. Though, it may see something in the documentation that I have not. as part of issue #2 "document()" call, there are no further methods such as doc.save("xxx") If you look at my prompt, I did not ask it to save the document. I just want fZ to create the 10 cubes. Any way... going to play with it. Will give updates. Looks interesting. Might even be a worse coder than I am. Ha! ¢£ P.S. chatGPT did not write any of the above text except for the code to build the 10 cubes. All that crappy writing was mine and mine alone. Edited May 10 by ¢hris £und Had an error in my description of the code. I referred to an earlier generation of the script rather than the one I included in the post here. ZTEK, Justin Montoya, Des and 2 others 5 Quote Link to comment Share on other sites More sharing options...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.