### Develop a project Source: https://solid-node.readthedocs.io/en/latest/_sources/cli.rst.txt Starts the development environment with filesystem monitoring and a viewer. ```bash solid develop [reference] [--set NAME=VALUE ...] [--web] [--web-dev] [--no-web] [--openscad] [--debug-builder] [--debug-web] [--callback URL] ``` -------------------------------- ### Start solid develop with web viewer Source: https://solid-node.readthedocs.io/en/latest/quickstart.html Starts the solid process using the default web viewer. Operates on the project's model declared in pyproject.toml. ```bash $ solid develop ``` -------------------------------- ### Start development with OpenSCAD Source: https://solid-node.readthedocs.io/en/latest/_sources/quickstart.rst.txt Launch the solid development process using OpenSCAD as the viewer. ```bash $ solid develop --openscad ``` -------------------------------- ### Start development server Source: https://solid-node.readthedocs.io/en/latest/_sources/quickstart.rst.txt Launch the solid development process using the default web viewer. ```bash $ solid develop ``` -------------------------------- ### Install solid-node Source: https://solid-node.readthedocs.io/en/latest/_sources/quickstart.rst.txt Install the solid-node package within the active virtual environment. ```bash $ pip install solid-node ``` -------------------------------- ### Build a project Source: https://solid-node.readthedocs.io/en/latest/_sources/cli.rst.txt Builds the node once and publishes the model without starting a viewer or watcher. ```bash solid build [reference] [--set NAME=VALUE ...] ``` -------------------------------- ### Create a new solid-node project Source: https://solid-node.readthedocs.io/en/latest/quickstart.html Creates a new project with a starting structure and changes into its directory. ```bash $ solid new myproject $ cd myproject ``` -------------------------------- ### solid snapshot command usage and examples Source: https://solid-node.readthedocs.io/en/latest/cli.html Renders the node to a PNG image without opening a viewer. The default renderer is openscad; the web renderer preserves an alpha channel. The examples show various options: output file, time, image size, projection, and renderer. ```bash solid snapshot [reference] [options] ``` ```bash $ solid snapshot -o front.png --viewall --autocenter $ solid snapshot windmill.windmill:Sail --time 0.25 --imgsize 800x600 --projection ortho $ solid snapshot --renderer web -o transparent.png ``` -------------------------------- ### Install OpenSCAD on Debian Source: https://solid-node.readthedocs.io/en/latest/_sources/quickstart.rst.txt Install the OpenSCAD dependency required for the default project template on Debian-based systems. ```bash $ sudo apt-get install openscad ``` -------------------------------- ### Create and activate virtual environment Source: https://solid-node.readthedocs.io/en/latest/quickstart.html Creates a Python virtual environment and activates it. Required before installing solid-node. ```bash $ virtualenv --python=python3 myproject-env $ source myproject-env/bin/activate ``` -------------------------------- ### Generate model snapshots Source: https://solid-node.readthedocs.io/en/latest/_sources/cli.rst.txt Examples of using the solid snapshot command with various flags for output, view settings, and rendering engines. ```bash $ solid snapshot -o front.png --viewall --autocenter $ solid snapshot windmill.windmill:Sail --time 0.25 --imgsize 800x600 --projection ortho $ solid snapshot --renderer web -o transparent.png ``` -------------------------------- ### AssemblyNode with render and simulate methods Source: https://solid-node.readthedocs.io/en/latest/_sources/declaring.rst.txt Example of a Block assembly where render() handles static placement and simulate() handles rotation via a driver. ```python class Block(AssemblyNode): clearance = Length(0.3, min=0) frame = BlockFrame(clearance=clearance) caps = MainBearingCap(clearance=clearance).repeat(5) crank = Crankshaft() angle = Driver(default=0.0, range=(0.0, 720.0), unit='deg') def render(self): for cap, x in zip(self.caps, BEARING_CENTERS): cap.translate([x, 0, 0]) self.crank.translate([0, 0, CRANK_HEIGHT]) def simulate(self): self.crank.rotate(self.angle, [1, 0, 0]) ``` -------------------------------- ### Setting design parameters via command line Source: https://solid-node.readthedocs.io/en/latest/_sources/declaring.rst.txt Examples of using the solid CLI to override declared parameters when building or developing a node. ```shell solid build engine.py --set bore=32.0 --set count=6 solid develop windmill.py --set guard_installed=false solid develop tower.py --set height=300 ``` -------------------------------- ### Create a new project Source: https://solid-node.readthedocs.io/en/latest/_sources/cli.rst.txt Initializes a new project directory with the specified name. ```bash solid new ``` -------------------------------- ### Create new project Source: https://solid-node.readthedocs.io/en/latest/_sources/quickstart.rst.txt Generate a new project structure and navigate into the directory. ```bash $ solid new myproject $ cd myproject ``` -------------------------------- ### Create virtual environment Source: https://solid-node.readthedocs.io/en/latest/_sources/quickstart.rst.txt Initialize a Python virtual environment for your project. ```bash $ virtualenv --python=python3 myproject-env $ source myproject-env/bin/activate ``` -------------------------------- ### solid develop command options Source: https://solid-node.readthedocs.io/en/latest/cli.html Runs everything needed to develop a project: monitors the filesystem, rebuilds the parts that changed, and serves a viewer that reloads automatically. Options include `--web`, `--openscad`, `--web-dev`, `--no-web`, `--debug-builder`, `--debug-web`, `--callback`, and `--set`. ```text solid develop [reference] [--set NAME=VALUE ...] [--web] [--web-dev] [--no-web] [--openscad] [--debug-builder] [--debug-web] [--callback URL] ``` -------------------------------- ### Assert a crash in a simulation Source: https://solid-node.readthedocs.io/en/latest/scenarios.html Example of asserting that a simulation crash is caught at the expected tick. ```python def test_a_crash_is_caught_at_the_tick_it_appears(self): sim = self.simulation() sim.at(0.0).trigger('Crash') sim.every(0.1, self.assertNoSolidInterference, self.node) with self.assertRaises(AssertionError): sim.run(3.0) self.assertEqual(sim.tick, 75) ``` -------------------------------- ### FutureWarning for improper render() usage Source: https://solid-node.readthedocs.io/en/latest/_sources/declaring.rst.txt Example of the warning issued when render() attempts to read drivers, time, or ports. ```text FutureWarning: SimpleClock.render() read time 'time'. Reading drivers, time or ports in render(), or binding a port there, is deprecated: render() builds the machine at rest and the framework runs it once per instance. Move the read or binding and the operations it feeds into simulate(), which runs on every instant. Until then SimpleClock re-renders per binding as before. ``` -------------------------------- ### solid new command Source: https://solid-node.readthedocs.io/en/latest/cli.html Creates a new project directory `` with a package, model module, `pyproject.toml` manifest, and `.gitignore`. Fails if `` exists. ```text solid new ``` -------------------------------- ### Define KnobShaft node in knob_shaft.py Source: https://solid-node.readthedocs.io/en/latest/_sources/fusion.rst.txt Creates a simple cylinder shaft as a Solid2Node. Used as a child in the fusion example. ```python from solid_node.node import Solid2Node from solid2 import cylinder class KnobShaft(Solid2Node): fn = 64 def render(self): return cylinder(r=4, h=30) ``` -------------------------------- ### Indexed names for list children Source: https://solid-node.readthedocs.io/en/latest/node-tree.html Shows that children held in a list get indexed names like planets-0, planets-1, planets-2. ```python self.planets = [Planet(i) for i in range(3)] # named planets-0, planets-1, planets-2 ``` -------------------------------- ### Test a project Source: https://solid-node.readthedocs.io/en/latest/_sources/cli.rst.txt Builds the node and executes its test methods. ```bash solid test [reference] [--set NAME=VALUE ...] [--failfast] ``` -------------------------------- ### SolidNodeWidget.mount(target, manifestUrl, options) Source: https://solid-node.readthedocs.io/en/latest/embedding.html Mounts the Solid Node viewer into a target element, loading a manifest and applying camera and driver control options. Returns a promise that resolves to a mount handle. ```APIDOC ## SolidNodeWidget.mount(target, manifestUrl, options) ### Description Mounts the Solid Node viewer into a target element, loading a manifest and applying camera and driver control options. Returns a promise that resolves to a mount handle. ### Method JavaScript function call ### Endpoint SolidNodeWidget.mount ### Parameters #### Parameters - **target** (string or Element) - Required - CSS selector or DOM element where the viewer will be mounted. - **manifestUrl** (string) - Required - URL to the manifest JSON file. - **options** (object) - Optional - Configuration options. - **view** (object) - Optional - Camera and target. Each vector may be a three-number tuple. - **camera** (array) - Optional - Camera position as [x, y, z]. - **target** (array) - Optional - Look-at target as [x, y, z]. - **up** (array) - Optional - Up vector as [x, y, z]. - **fov** (number) - Optional - Field of view in degrees. - **driverControls** (string) - Optional - Set to 'none' to suppress built-in controls. ### Request Example ```javascript const viewer = await SolidNodeWidget.mount('#model', 'manifest.json', { view: { camera: [80, -60, 40], target: [0, 0, 0] }, up: [0, 0, 1], fov: 22.5, driverControls: 'none', }); ``` ### Response #### Success Response Returns a promise that resolves to a mount handle object. #### Response Example ```javascript { drivers: function() {}, driver: function(id) {}, setDriver: function(id, value) {}, onDriverChange: function(fn) {}, instructions: function() {}, trigger: function(name) {} } ``` ``` -------------------------------- ### solid_node.test.testing_steps(steps, start=0, end=1) Source: https://solid-node.readthedocs.io/en/latest/api-reference.html Decorator to run the test in several steps of the animation. Use start and end to define the range that will be divided into those steps. ```APIDOC ## solid_node.test.testing_steps(steps, start=0, end=1) ### Description Use this decorator to run the test in several steps of the animation. Use start and end to define the range that will be divided into those steps. ### Parameters - **steps** - The number of steps to divide the animation range into. - **start** (float, default 0) - The start of the animation range. - **end** (float, default 1) - The end of the animation range. ``` -------------------------------- ### Defining a declarative assembly node with render() Source: https://solid-node.readthedocs.io/en/latest/_sources/declaring.rst.txt An example of a Windmill assembly node that uses render() to conditionally omit the guard part based on a flag parameter. ```python class Windmill(AssemblyNode): overall_height = Length(400.0, min=0) rotor_fraction = Ratio(0.36, min=0, max=1) guard_installed = Flag(True) rotor_radius = overall_height * rotor_fraction tower = TowerBody(height=overall_height) rotor = Rotor(radius=rotor_radius) guard = Guard() def render(self): if not self.guard_installed: self.guard.omit() ``` -------------------------------- ### Export model for web Source: https://solid-node.readthedocs.io/en/latest/_sources/cli.rst.txt Export a model to a directory and serve it using a local Python server. ```bash $ solid export -o export $ python -m http.server -d export # view at http://localhost:8000 ``` -------------------------------- ### Test at a single instant with @testing_instant Source: https://solid-node.readthedocs.io/en/latest/_sources/testing.rst.txt Runs a test at one specific instant of the animation using the @testing_instant decorator. The example checks that the pointer and pin do not intersect at time 0.5. ```python from solid_node.test import TestCaseMixin, testing_instant class SimpleClock(AssemblyNode, TestCaseMixin): ... @testing_instant(0.5) def test_pointer_at_half_turn(self): self.assertNotIntersecting(self.pointer, self.pin) ``` -------------------------------- ### OpenScadNode.__init__(*args, name=None, **kwargs) Source: https://solid-node.readthedocs.io/en/latest/api-reference.html Initializes an OpenScadNode, passing arguments and keyword arguments to the OpenSCAD module. The optional name keyword sets the node's name, defaulting to the class name. ```APIDOC ## OpenScadNode.__init__(*args, name=None, **kwargs) ### Description Initializes an OpenScadNode, passing arguments and keyword arguments to the OpenSCAD module. The optional name keyword sets the node's name, defaulting to the class name. ### Parameters - **args** (*args) - Required - Will be passed as arguments to the OpenSCAD module. - **name** (keyword) - Optional - The name of this node, defaults to the name of the class. - **kwargs** (**kwargs) - Required - Will be passed as keyword arguments to the OpenSCAD module. ``` -------------------------------- ### Define a scenario test class Source: https://solid-node.readthedocs.io/en/latest/_sources/scenarios.rst.txt Declares a `ScenarioTest` subclass with the node, step, and whether geometry is needed. Each test gets a fresh simulation and can schedule actions to assert on state. ```python from solid_node.simulation import ScenarioTest from .axis import Axis class AxisScenarioTest(ScenarioTest): node = Axis dt = 0.02 meshes = True # this scenario asserts on geometry def test_homing_stays_clear_of_the_stop(self): sim = self.simulation() arrived = [] sim.at(0.0).trigger('Home') sim.every(0.1, self.assertNoSolidInterference, self.node) sim.at(2.5).run(lambda s: arrived.append(s.state['x'])) sim.run(3.0) self.assertEqual(arrived, [0]) self.assertEqual(sim.assertion_stats[0], 30) ``` -------------------------------- ### Configure solid_node.sphinx in conf.py Source: https://solid-node.readthedocs.io/en/latest/_sources/embedding.rst.txt Add the extension to the extensions list in your Sphinx configuration file. ```python extensions = [ # ... 'solid_node.sphinx', ] ``` -------------------------------- ### trigger(_name_) Source: https://solid-node.readthedocs.io/en/latest/api-reference.html Starts the named instruction's ramps at the current tick. The name is qualified the same way a driver id is, and its targets are class-local, resolving against the declaring node's own path. ```APIDOC ## trigger(_name_) ### Description Start the named instruction's ramps at the current tick. name is qualified the same way a driver id is: an instruction declared on a child is x_axis.Home, one declared on the root keeps its bare name. Its targets are class-local, so they resolve against the declaring node's own path. ### Parameters - **name** - The qualified name of the instruction to trigger. ```