kopia lustrzana https://github.com/carson-katri/geometry-script
commit
5fbc7d1ba0
|
@ -6,6 +6,8 @@ on:
|
|||
- main
|
||||
pull_request:
|
||||
|
||||
concurrency: preview-${{ github.ref }}
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-20.04
|
||||
|
@ -28,3 +30,9 @@ jobs:
|
|||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
publish_dir: ./book/book
|
||||
|
||||
- name: Deploy preview
|
||||
uses: rossjrw/pr-preview-action@v1
|
||||
if: ${{ github.ref != 'refs/heads/main' }}
|
||||
with:
|
||||
source-dir: ./book/book
|
|
@ -44,12 +44,19 @@ class Attribute:
|
|||
"""
|
||||
Creates a "Named Attribute" node with the correct arguments passed, and returns the "Attribute" socket.
|
||||
"""
|
||||
from geometry_script import named_attribute
|
||||
return named_attribute(data_type=self.data_type, name=self.name, *args, **kwargs).attribute
|
||||
from geometry_script import named_attribute, Type
|
||||
result = named_attribute(data_type=self.data_type, name=self.name, *args, **kwargs)
|
||||
# Handle Blender 3.5+, which includes an `exists` result.
|
||||
if isinstance(result, Type):
|
||||
return result
|
||||
else:
|
||||
return result.attribute
|
||||
|
||||
def exists(self, *args, **kwargs):
|
||||
"""
|
||||
Creates a "Named Attribute" node with the correct arguments passed, and returns the "Exists" socket.
|
||||
|
||||
> Only available in Blender 3.5+
|
||||
"""
|
||||
from geometry_script import named_attribute
|
||||
return named_attribute(data_type=self.data_type, name=self.name, *args, **kwargs).exists
|
||||
|
|
20
api/tree.py
20
api/tree.py
|
@ -98,12 +98,20 @@ def tree(name):
|
|||
outputs = builder(**builder_inputs)
|
||||
|
||||
# Create the output sockets
|
||||
for i, result in enumerate(_as_iterable(outputs)):
|
||||
if not issubclass(type(result), Type):
|
||||
result = Type(value=result)
|
||||
# raise Exception(f"Return value '{result}' is not a valid 'Type' subclass.")
|
||||
node_group.outputs.new(result.socket_type, 'Result')
|
||||
link = node_group.links.new(result._socket, group_output_node.inputs[i])
|
||||
if isinstance(outputs, dict):
|
||||
# Use a dict to name each return value
|
||||
for i, (k, v) in enumerate(outputs.items()):
|
||||
if not issubclass(type(v), Type):
|
||||
v = Type(value=v)
|
||||
node_group.outputs.new(v.socket_type, k)
|
||||
node_group.links.new(v._socket, group_output_node.inputs[i])
|
||||
else:
|
||||
for i, result in enumerate(_as_iterable(outputs)):
|
||||
if not issubclass(type(result), Type):
|
||||
result = Type(value=result)
|
||||
# raise Exception(f"Return value '{result}' is not a valid 'Type' subclass.")
|
||||
node_group.outputs.new(result.socket_type, 'Result')
|
||||
node_group.links.new(result._socket, group_output_node.inputs[i])
|
||||
|
||||
_arrange(node_group)
|
||||
|
||||
|
|
|
@ -175,8 +175,8 @@ class Type(metaclass=_TypeMeta):
|
|||
|
||||
def capture(self, value, **kwargs):
|
||||
data_type = socket_type_to_data_type(value._socket.type)
|
||||
geometry, attribute = self.capture_attribute(data_type=data_type, value=value, **kwargs)
|
||||
return geometry, attribute
|
||||
res = self.capture_attribute(data_type=data_type, value=value, **kwargs)
|
||||
return res.geometry, res.attribute
|
||||
def transfer(self, attribute, **kwargs):
|
||||
data_type = socket_type_to_data_type(attribute._socket.type)
|
||||
return self.transfer_attribute(data_type=data_type, attribute=attribute, **kwargs)
|
||||
|
|
Plik binarny nie jest wyświetlany.
Po Szerokość: | Wysokość: | Rozmiar: 108 KiB |
|
@ -41,6 +41,19 @@ def cube_tree():
|
|||
|
||||
![](./cube_tree_int.png)
|
||||
|
||||
By default, each output is named 'Result'. To customize the name, return a dictionary.
|
||||
|
||||
```python
|
||||
@tree("Cube Tree")
|
||||
def cube_tree():
|
||||
return {
|
||||
"My Cube": cube(),
|
||||
"Scale Constant": 5
|
||||
}
|
||||
```
|
||||
|
||||
![](./cube_tree_named_outputs.png)
|
||||
|
||||
## Group Input
|
||||
All arguments in a tree function must be annotated with a valid socket type. These types are provided by Geometry Script, and are not equivalent to Python's built-in types. Let's add a size argument to our Cube Tree.
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue