Jayme McColgan Posted December 6, 2022 Share Posted December 6, 2022 i was bored on a show so i decided to ask the ChatGPT from OpenAI to "build a python Vectorworks plugin that horizontally distributes all the selected items evenly" and this is what it spit out. interesting. # Import the Vectorworks Python API import Vectorworks as vw # Import the VWObjects module from Vectorworks.VWObjects import * # Define the plug-in class class CExamplePlugin: # Called when the plug-in is loaded def Load(self): # Get the selected objects selectedObjects = vw.selection.GetAllObjects() # Calculate the total width of the selected objects totalWidth = 0 for obj in selectedObjects: bounds = obj.GetBounds() totalWidth += bounds.GetRight() - bounds.GetLeft() # Calculate the space between the objects space = (totalWidth / len(selectedObjects)) - totalWidth # Distribute the objects horizontally for obj in selectedObjects: bounds = obj.GetBounds() obj.SetBounds(bounds.GetLeft() + space, bounds.GetTop(), bounds.GetRight() + space, bounds.GetBottom()) # Called when the plug-in is unloaded def Unload(self): # Clean up resources here pass # Create an instance of the plug-in class plugIn = CExamplePlugin() 4 Quote Link to comment
JBenghiat Posted December 7, 2022 Share Posted December 7, 2022 If only those calls were actually in the VW Python api… Quote Link to comment
elepp Posted December 7, 2022 Share Posted December 7, 2022 It's crazy what ChatGPT can do. I saw someone ask it to write an ifc file with a cube inside. And it worked! 😲 1 Quote Link to comment
Jayme McColgan Posted December 9, 2022 Author Share Posted December 9, 2022 yeah I'm not sure where it pulled these endpoints from. is there another "external" API for vectorworks? Quote Link to comment
JBenghiat Posted January 2, 2023 Share Posted January 2, 2023 On 12/9/2022 at 8:42 AM, Jayme McColgan said: yeah I'm not sure where it pulled these endpoints from. is there another "external" API for vectorworks? There's an SDK for c++, which the bot seems to be adapting. VWObjects is a class, but GetAllObjects() isn't in either the SDK or the Python/VS API. GetBounds() is not an actual method, though GetObjectBounds() is, which returns an object with GetLeft() etc. The logic of the AI-generated script is actually sound, but it's almost as though it wrote what *should* be the API first. 🙂 Quote Link to comment
elepp Posted January 6, 2023 Share Posted January 6, 2023 On 1/2/2023 at 4:26 AM, JBenghiat said: The logic of the AI-generated script is actually sound, but it's almost as though it wrote what *should* be the API first. Seems like it's a general thing for chatgpt. Found this on reddit about chatgpt and dynamo/revit: Quote It's a bit rubbish. Too little learning on the API for it to function well. Had a good laugh the other day when someone posted some AI python code on the Dynamo forums that was way off track from what they asked it to do, invented its own API calls that don't exist, left out necessary inputs on actual API calls. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.