drock019 Posted August 8 Share Posted August 8 I'm curious if there is a way in marionette that I can retrieve an external code stored on my hard drive? I use to make plugins using vectorscript and to keep my plugin snappy i would use {$INCLUDE path to file} to retrieve code only when it was necessary. Is there a similar way to accomplish this using marionette? Thanks Derek Quote Link to comment
Pat Stanford Posted August 8 Share Posted August 8 I believe you can use $INCLUDE in the Python code that defines the Marionette nodes, but I don't think that is what you are looking for. I am not certain if you can Reference in a separate VW file with Marionette nodes. If you can that might make the file slightly smaller to save disk space, but then you will need to always have access to the "library" file for the Marionette to be able to run. No other way I know of with Marionette nodes. Quote Link to comment
drock019 Posted August 8 Author Share Posted August 8 Thanks Pat, I've been trying to recreate some plugin objects that I previously made with vectorscript. Currently, my marionette objects are not nearly as complicated yet they tend to be much slower when updating. Unchecking "Update on Move" has helped significantly since they don't update every time i move the object, but they still remain slow when they do update. With the previous plugin objects I did have to reference a folder on the hard drive but, I work for a small office so it was not hard keeping them all up to date. Thanks again! Derek Quote Link to comment
Pat Stanford Posted August 8 Share Posted August 8 Marionette will always be slower. It is a hybrid language. It is objects that have functions, but that actually are a container for Python code. So there is probably 2 to 10 times more code that has to be executed in a Marionette object as in a basic script. All the code that is required to maintain the relationships between the node, the code (if you wrap or create an object is less) that shows the input and output points. The code that displays the data in the OIP. Etc. This is especially true with simpler nodes. A node to set an object class that would be a single like of code in VS/Python is 33 lines of Python (18 lines of code and 15 lines of comments) in the Marionette Object. And that does not include the overhead to actually run the marionette objects. So just like Vectorscript or Python is slower than SDK PIOs, Marionette will be slower than a scripting language. And if you were just using staight includes in your scripts, I think you are fooling yourself that they were faster. In fact there should have been marginally slower due to the time to read the file in from disk. Includes are great for sharing code or having a single place to make a change or potentially to reduce file size, but when the code is compiled or interpreted ALL of the include files have to be in memory before the compile/interpet can take place. Quote Link to comment
KingChaos Posted August 13 Share Posted August 13 is there any AI help for making those codes of all the node of f.e. a wrapper to one code without spagethicode? i think u know what i mean. i have dozents of marionettes which i have to fasten up, but i cant code by my self 🙂 Quote Link to comment
drock019 Posted August 15 Author Share Posted August 15 (edited) I've found that AI can suggest things that might steer me in the right path but doesn't offer an exact solution. If you want to cleanup your marionette object because it is overly messy try grouping chunks of your code and wrapping them. This can hide a lot of clutter. You just need to figure out what variables are going into each specific chunk and create Pass Nodes for each at the beginning of the wrapper. Then, before wrapping the chunk, just disconnect the variables, wrap the chunk, then reattach the original variables. If you want your wrapper to have a specifically named outport then just add a "Pass Node" at the very end of the chunk before you wrap it. I'm not sure how much weight is added to the code with each Pass Node but it is a way to keep things nice and tidy. It also allows you to easily copy and reuse the new wrapped node in another marionette script. Not sure if I answered your question, helped you in anyway or just if I just went off on a tangent. Or maybe you were asking if there is a way to convert a marionette script into a single python code? That would be great if it could speed things up. Derek Edited August 15 by drock019 Quote Link to comment
KingChaos Posted August 15 Share Posted August 15 now i translate it into german ^^ Quote Link to comment
DomC Posted August 15 Share Posted August 15 You can refer to a "text" resource, which is you node definition code like this at the Beginning of the node: #COMMAND;REFFILE;[UsrLib]/Defaults\Marionette\DomC\SystemWand_v13.py; @Marionette.NodeDefinition class Params(metaclass=Marionette.OrderedClass): The system detects if you edit last in Vectorworks via Node definition or via editor in the external file and will update. But it is not a direct link to an external module. But will work if it is disconnected to the external tool. The negative think about this, we (or i do not know) how to update the node without doubleclick and exit the node. So my beste Workflow to edit external code of a Marionette Node is as following: example: @Marionette.NodeDefinition class Params(metaclass=Marionette.OrderedClass): # APPEARANCE # Name this = Marionette.Node('SystemWand_v13') this.SetDescription("") # Input Ports objs = Marionette.PortIn(None) n_offset = Marionette.PortIn(0) n_height = Marionette.PortIn(3000) n_off_end = Marionette.PortIn(68) n_max_offset = Marionette.PortIn(750) profile_dim = Marionette.PortIn(30) s_group = Marionette.PortIn('') n_profile_max_horiz = Marionette.PortIn(2000) n_profile_max_vert = Marionette.PortIn(3000) n_strut_max = Marionette.PortIn(3000) b_Gehrung = Marionette.PortIn(True, 'Ecke Gehren') # 0 = Einlauf 90, 1 = Fallstrang 2x45 wire_in = Marionette.PortIn(False) # OIP Controls # Output Ports h_poly = Marionette.PortOut() p_vertices = Marionette.PortOut() # BEHAVIOR this.SetLinksObjects() # this.SetListAbsorb() def RunNode(self): import rs.systemwandv13 from imp import reload reload (rs.systemwandv13) rs.systemwandv13.run_node(self, Marionette) So i start normal and then i import my exernal code in the RunNode. Maybe it is also possible to import the complete node code but did not tried(needed) this yet. Important is to reload because of caching. This is a very good method for fast developing without refreshing nodes manually. And then the external module: def run_node(self, Marionette): # import modules from datetime import datetime import json import vs import math import copy from math import radians, sin, cos #from inspect import currentframe, getframeinfo #cf = currentframe() selection_group = [] error_log = [] # parent pio infos pio_handle = vs.Handle(Marionette.parametric_handle) pio_parent = vs.GetParent(pio_handle) pio_parent_type = vs.GetTypeN(pio_parent) #... here you can code everything you also can code inside the node. Hope that helps. Do not know what you want to do. I think the speed of Marionette not really depends of inefficient code. It is maybe the Number of nodes which makes it slower maybe by duplicate or copy/paste an Object. But maybe it is i am sure about this. Quote Link to comment
DomC Posted August 15 Share Posted August 15 If you have luck a tool like ChatGPT can simplify your code or can help optimizing it. But we can not read take the output of those AI tools directly. Still someone have to verify the output or have to know what to do if there is still "a bug" 🐞 Lets make a spontan test. Marionette is drawing a rectangle. A very easy one. I export as a script: 160 Lines (cant post the code directly here) ChatGPT. I ask for making it more compact: Quote Certainly! Here's a simplified version of your code, focusing on removing redundancies and organizing it more cleanly while preserving the original functionality. Sounds good. Result 104 lines. But i do not except this is faster. Or even the first version is really measurable slow just because of the code BTW, that faild and the "optimized" script do not run, while the original script runs: Quote Link to comment
Pat Stanford Posted August 15 Share Posted August 15 And a manually written PIO to do the same thing could have a script of 4 lines. And have the parameter show up in the OIP just like naming the Dim node. 😉 The difference in execution time on a modern computer between 4 lines and 104 is just about zero. So unless you are running thousands of iterations, it probably does not matter. As I said above, each Marionette node has a fair amount of code (10-20 lines is probably typical) for the Setup routine. If you have a networks with hundreds of nodes, all of that extra code could (will) make it slower than a script that avoids the processing of each node. It is a trade off between development time and execution time. If you can write the Marionette in 1 hour vs 10 hours to write a script/PIO, then you can still save time if the marionette is slower. But if you have 600 instances of the marionette and it takes 1 second for each to run on every update so it takes 10 minutes to redraw the drawing, it is probably not a good trade off. $0.02 2 Quote Link to comment
Pat Stanford Posted August 15 Share Posted August 15 1 hour ago, DomC said: You can refer to a "text" resource, which is you node definition code like this at the Beginning of the node: @DomC Question about this. If you use the text resource and you want to distribute the nodes, would you have to distribute the text files also and make sure the user puts them in the correct location? Or would the node cache the code if the text file is missing? Quote Link to comment
DomC Posted August 15 Share Posted August 15 3 hours ago, Pat Stanford said: Question about this. If you use the text resource and you want to distribute the nodes, would you have to distribute the text files also and make sure the user puts them in the correct location? Or would the node cache the code if the text file is missing? It is a copy of the node content in that path and the node run without it and user get not messages about that link. At the time you edit the node code also nothing happens if the resource not exists, if the resource exists it will update if the resource is newer than the code inside the node. Only if you exit the node it will report, that the resource is not existing and it tries to create the path. And from this Moment you can edit the Text resource to edit the code. I think this is done, to be able to update the nodes and keep them synced. But a note will not update automatically. Because changing a node without control could break existing scripts. So it is a good think to keep nodes synced if needed or triggered manually. But if you developing a big code content of a node and need to run tests ever 30 seconds the workflow with a direct "import module" is better till the script reached a releasable state. The Import would throw an error a machine which is not linked to that path. So this is just a developing method. Then you go to the #COMMAND;REFFILE; method. Also there is the Method #COMMAND;READONLYREFFILE; with protect nodes from editing. And just read the file.This is how the standard-nodes are created. It is thinkable to download and install the module through the modul installer of Marionette or the Marionette own installer inside the node from Vectorworks Reprository or from a python wheel url. like we import pillow, numpy etc. 1 Quote Link to comment
KingChaos Posted August 16 Share Posted August 16 to use the marionettes in XG Cabinets they have to be as slim as possible, else VWX will take minutes to run them, fe if i have 6-20 of this marionettes in one XG Cabinet Quote Link to comment
KingChaos Posted August 16 Share Posted August 16 so i am searching for a way to make the hole network wrappen "clean" of useless spagetthi lines" i have 0 capacity for learning VS or python, i stopped programming after gw basic in 1992 Quote Link to comment
DomC Posted August 16 Share Posted August 16 I analyzed that several times with many Networks from users. The more nodes the slower. Do not know, if it depends of "unpurged and many lines" or on the fact, that every node has a geometry representation, Circles and polylines for graphical representation and generating the script. My workflow for PIOs for professional usage is, to have just a few nodes. And one node contains the PIOs main-code. This can be 1000 or 3000 lines. if i export this as a python file it has 1326 lines. The PIO needs 2 seconds to execute. If i export this 500 nodes, it has 29000 lines. Those are just pass nodes. Execution Time of this PIO is 0.07 seconds. So executing 10 times (290'000 lines of code) is not even a second execution of the first example with 1300 lines, needs about 2seconds depending on the size and number of linkes objects etc. Just to show, there is not direct relation between number of lines and speed. I also think about optimizing. But if we say, one should optimize the network, so we have 10times less lines. It would be the development investment on the wrong side maybe. It would sound maybe for the world to say we reduces size of script 10 or 20 times. But is is the wrong priority to focus improvements on the number of created code-lines by marionette. It maybe could result in longer waiting time for your example, because the intelligents to create the code maybe needs then more time. Just want we think clever about where someone would invest developing time. We have maybe the same wishes and should not judge about the right solution. At the End, the wish speed by copy or import objects on the file. And we want security that a deleted node or wrecked graphical network does not change the script. I think the direction of improvement should be, to be able to dump/cache the finished script in a text-based form (one node, one resource, one stile etc.) So your 1500 nodes don't need to be part of your pio anymore. Nodes are good to easy build the script or easy edit update it. Thats why we love graphical scripting. But to use the PIOs in our models in a fast and 100% reliable way, nodes are not needed. Also i am pretty sure, those are producing your speed issue not the number of coded lines. 1 Quote Link to comment
KingChaos Posted August 19 Share Posted August 19 for non programmers like me, its the only way to get stuff what isnt there. 😞 therefor i asked for a ai based shrinker for my wrappercode. 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.