Support Forum

[Frage] Running a python code in visual scripting

Schlagworte:
  • Allplan
  • Python
  • Script
  • Visual
  • Scripting

Hello everyone,

I have a question:

To make a visual script even stronger I sometimes want to use a piece or small piece of python script within visual scripting. This includes IF statements, loops, etc. I want to be able to control my own input and have the script generate a certain output.

Is there a possibility to add a python script in visual scripting in a node (as can be done by dynamo)?

Anhänge (1)

Typ: image/png
232-mal heruntergeladen
Größe: 102,61 KiB

Hilfreichste Antwort anzeigen Hilfreichste Antwort verbergen

Hello,

during the development of the Python script for the ExecPythonScript node you can do the following steps to get the whole Python development functionality:

- create a separate py file with your code
- import and call the functionality from your py file in the script added to the ExecPythonScript node
- edit and debug your py file e.g. with Visual Studio Code
- add the source code from you py file to the ExecPythonScript node if your development is finished

As additional possibility you can create your own node, also with full Python development functionalitiy.

If you need more information, please let me know.

Best regards
Horst

Hello,

you can use the node ExecPythonScript.

Create the script with an editor and copy the script to the input field for the script inside the node.

You can have a look at the example AbsoluteTower, where the node is used. If you need more info, please let me know.

Best regards
Horst

Zitiert von: Horst_Hohmann
Hello,
you can use the node ExecPythonScript.
Create the script with an editor and copy the script to the input field for the script inside the node.
You can have a look at the example AbsoluteTower, where the node is used. If you need more info, please let me know.
Best regards

Horst

Thank you for your reaction!

I gave the node a try, but I still see room for improvement for this node.
You can now add multiple parameters to the node, but it is very difficult to see which parameter is picked up first by the node. Maybe it is possible to add in the node that you can click on a "+" button and then get an extra bullet for a parameter. So that it becomes clear in your script that connection 1 is, for example, a and connection 2 is b. see the picture of dynamo what I mean exactly.

Anhänge (2)

Typ: image/png
161-mal heruntergeladen
Größe: 4,36 KiB
Typ: image/png
84-mal heruntergeladen
Größe: 9,02 KiB

Thanks for the suggestion!

It is currently not possible to have dynamic number of parameter on a node in VS as you shown in the screenshot from Dynamo. We planed to implement that, but it won't happen in the near future.

Product Owner API, Allplan GmbH

Thank you for your reaction,

As you get on with improving the node, I may have a few more usability tips.
I've been discovering and using the node for a while now, but I'm still running into a few issues:

- the interface request 1: try to open it like dynamo in a separate window or if that doesn't work, try to make the color distinction like the python text is for real.

- the interface request 2: I now get a fixed box where I can type text. If I type more text than the size of the box, it disappears outside the box and I can't reach my text. I would like to scroll in the box or stretch the box to fit my text.

- the interface request 3: in various python script programs you can use the tab key to go one dimension lower in your script. For example in a for loop: if something == something, (enter and then tab) and write your for loop. now I have to use the spacebar and would like to use the tab key.

- how the node handles parameters: I've found that the python node flattens 2D lists into 1D lists. You can use the booleans to read it the input as 2D with "input list as block per row", but this can only be done for 1 input and not for multiple inputs with diverent dimensions. I would like to see that what I put in is what the node reads. For example: input 1 = 2D list and input 2 = 1D list and input 3 = 2D list.

Thanks and I hope you can do something with the input!

Hello,

during the development of the Python script for the ExecPythonScript node you can do the following steps to get the whole Python development functionality:

- create a separate py file with your code
- import and call the functionality from your py file in the script added to the ExecPythonScript node
- edit and debug your py file e.g. with Visual Studio Code
- add the source code from you py file to the ExecPythonScript node if your development is finished

As additional possibility you can create your own node, also with full Python development functionalitiy.

If you need more information, please let me know.

Best regards
Horst