Jump to content

Having fun with ChatGPT


Recommended Posts

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()

 

  • Like 4
Link to comment
  • 4 weeks later...
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. 🙂

Link to comment
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.

 

Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...