what is good practise while making script node that have lots of input variables to tidy things up for readability? now I ust inserts a blank variable _ = ""
like
but I assume there is a more accepted way of doing this well
what is good practise while making script node that have lots of input variables to tidy things up for readability? now I ust inserts a blank variable _ = ""
like
but I assume there is a more accepted way of doing this well
If you write a function you usually keep the argument count small. A component with many parameters/arguments is a indicator of violating the Single-Responsibility principle. It might be better to provide a settings or configuration object, which collects relevant information. From the image it is impossible to tell what this component is supposed to do. Also note that naming is important. Output like “script” “base_path” and “imports” are very generic names. Especially if the component is called “S”. If this component is supposed to be a code generator, you might distinguish in filling up a template and setting up an environment (defining directories etc). A single output is usually better than multiple.
thanks … still learning
I want to bring a large python file into grasshopper and divide it up in smaller code nodes. Bringing into gh gives me more flexibility, for both 3d visualisation and some mesh operations.
My reasoning was that I want to convert an external config.py into a python node, instead of opening and editing a .py file everytime i need to make a change
The imports is a txt panel with
#! python3
import os
from os.path import realpath, join
import sys
import time
from datetime import datetime, timedelta, timezone
import System
import System.Collections.Generic
# Rhino and Grasshopper Imports
import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino
from Grasshopper import DataTree
from Grasshopper.Kernel.Data import GH_Path
# Python Library Imports
import drjit as dr
import numpy as np
from matplotlib import pyplot as plt
import math
and I reference that by input ‘imports’ (str) and in that node have at the start
#! python3
import ghpythonlib.components as ghcomp
# Execute the imports string
exec(imports)
The script out is optinal “Script Output Parameter”, just so I can read the content of each node