Jump to content
Developer Wiki and Function Reference Links ×

Using ChatGPT to understand Marionette under the hood coding


Recommended Posts

Not until now 🤣..

This is a direct copy and paste of my prompt and the result, however, I'm pretty sure its a simpe scenario, and there will be hallucinations for more advanced requests. But certainly there are tools out there that will make all these possible some day..

With your knowledge of Marionette coding and Vectorworks python api functions, build another Marionette node code that creates a rectangle.
The two input nodes are just the width and height, and the output node is the resulting rectangle created



Certainly, here's a Marionette node code that takes width and height as input and creates a rectangle with those dimensions:

#Modified by [Your Name] [Current Date]
class Params(metaclass = Marionette.OrderedClass):
    this = Marionette.Node('Rectangle')
    this.SetDescription('Creates a rectangle with the specified dimensions.')

    # INPUTS
    width = Marionette.PortIn(0, 'Width')
    width.SetDescription('The width of the rectangle.')
    height = Marionette.PortIn(0, 'Height')
    height.SetDescription('The height of the rectangle.')

    rect = Marionette.PortOut('h', 'Rectangle')
    rect.SetDescription('The resulting rectangle.')

def RunNode():
    # Inputs
    w = Params.width.value
    h = Params.height.value

    # Script
    rect = vs.CreateRectangle(vs.Vector(0, 0), w, h)

    # Outputs
    Params.rect.value = rect

This code defines a Marionette node that takes two inputs, width and height, and outputs a rectangle object with those dimensions. The script creates a rectangle using the vs.CreateRectangle function from the Vectorworks Python API, which takes a position vector and the width and height of the rectangle. The rect object is then outputted as the result of the node.


As you can see it came up with the first two lines just because of the context of the chat session I'm sure. This is still crazy though.


Edited by twk
  • Like 1
Link to comment



i just tried it myself and i am amazed, this seems like a good tool to learn from existing code.

I wrote a little nonsensical script to test Chat.



Can you explain this Python script for Vectorworks line by line, considering the information you can find in the documentation (https://developer.vectorworks.net/index.php/VS:Function_Reference): 

def run():
	vs.AlertInform("Error", "Chat", False)

vs.CallTool(-201, run)



Sure! Here's a line-by-line explanation of the script:

def run():
    vs.AlertInform("Error", "Chat", False)

This defines a function called `run` that takes no arguments. Inside the function, it calls the `vs.AlertInform` function from the Vectorworks scripting module `vs`. This function displays an alert dialog which provides the user with information about the result of a command. It offers no user choices¹. The first argument `"Error"` is the text to be displayed in the alert dialog. The second argument `"Chat"` is additional text to be displayed in a smaller font under the main information message. The third argument `False` specifies that this is a major alert (as opposed to a minor alert)¹.

vs.CallTool(-201, run)

This line calls the `vs.CallTool` function from the Vectorworks scripting module `vs`. This function activates the specified VectorWorks tool for a single use. After the tool has been used, VectorWorks will revert back to the previously active tool⁵. The first argument `-201` specifies the tool ID of the tool to be activated. The second argument `run` is a callback function that will be executed when the tool finishes⁵.

I hope this helps! Is there anything else you would like to know?


Quelle: Unterhaltung mit Bing, 27.4.2023
(1) VS:AlertInform - Vectorworks Developer. https://developer.vectorworks.net/index.php/VS:AlertInform.
(2) VS:CallTool - Vectorworks Developer. https://developer.vectorworks.net/index.php/VS:CallTool.
(3) VCOM:VectorWorks:ISDK::AlertInform - Vectorworks Developer. https://developer.vectorworks.net/index.php/VCOM:VectorWorks:ISDK::AlertInform.
(4) VS:AlertInformHLinkN - Vectorworks Developer. https://developer.vectorworks.net/index.php/VS:AlertInformHLinkN.
(5) VS:AlertInformHLink - Vectorworks Developer. https://developer.vectorworks.net/index.php/VS:AlertInformHLink.
(6) vs.CallTool SP3 - Python Scripting - Vectorworks Community Board. https://forum.vectorworks.net/index.php?/topic/95084-vscalltool-sp3/.
(7) VS:CallToolByName - Vectorworks Developer. https://developer.vectorworks.net/index.php/VS:CallToolByName.
(8) VS:CallToolByIndex - Vectorworks Developer. https://developer.vectorworks.net/index.php/VS:CallToolByIndex.



As expected it could not find the information about the argument "-201" even when i pointed it into the right direction. Obviously it "only" provided me with the information it found in the documentation, but that leaves me wondering what it could do if the documentation would be a little more Chat friendly and a bit more complete.





Edited by Letti R
  • Like 3
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.

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...