Skip to content

Commit

Permalink
Merge pull request #3 from ikappaki/backport/prs-basilisp
Browse files Browse the repository at this point in the history
backported a few nREPL PRs from Basilisp
  • Loading branch information
ikappaki authored Oct 31, 2024
2 parents 3ff0e6b + 1c0615f commit 67f63d3
Show file tree
Hide file tree
Showing 7 changed files with 249 additions and 151 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@

## Unreleased

## 0.2.0

- Added async server interface support in `start-server!` with a client work abstraction.
- Implemented the async Blender nREPL server directly in Basilisp.
- Enhanced error handling to return errors at the interface layer.
- Introduced the nREPL server control panel UI component.
- Upgraded Basilisp to 0.2.4.
- Improved on the nREPL server exception messages by matching that of the REPL user friendly format, backported from [basilisp#973](https://github.com/basilisp-lang/basilisp/pull/973).
- Fix incorrect line numbers for compiler exceptions in nREPL when evaluating forms in loaded files, backported from [basilisp#1038](https://github.com/basilisp-lang/basilisp/pull/1038).
- nREPL server no longer sends ANSI color escape sequences in exception messages to clients, backported from [basilisp#1040](https://github.com/basilisp-lang/basilisp/pull/1040).
- Conform to the `cider-nrepl` `info` ops spec by ensuring result's `:file` is URI, also added missing :column number, backported from [basilisp#1068](https://github.com/basilisp-lang/basilisp/pull/1068).

## 0.1.0

Expand Down
29 changes: 15 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,37 +122,31 @@ Here is an example of Basilisp code to create a torus pattern using the bpy Blen
(:import bpy
math))

(def object (.. bpy/ops -object))
(def materials (.. bpy/data -materials))
(def mesh (.. bpy/ops -mesh))


(defn clear-mesh-objects []
(.select-all object ** :action "DESELECT")
(.select-by-type object ** :type "MESH")
(.delete object))
(.select-all bpy.ops/object ** :action "DESELECT")
(.select-by-type bpy.ops/object ** :type "MESH")
(.delete bpy.ops/object))

(clear-mesh-objects)

(defn create-random-material []
(let [mat (.new materials ** :name "RandomMaterial")
_ (set! (.-use-nodes mat) true)
(let [mat (.new bpy.data/materials ** :name "RandomMaterial")
_ (set! (.-use-nodes mat) true)
bsdf (aget (.. mat -node-tree -nodes) "Principled BSDF")]

(set! (-> bsdf .-inputs (aget "Base Color") .-default-value)
[(rand) (rand) (rand) 1])
mat))

(defn create-torus [radius tube-radius location segments]
(.primitive-torus-add mesh **
(.primitive-torus-add bpy.ops/mesh **
:major-radius radius
:minor-radius tube-radius
:location location
:major-segments segments
:minor-segments segments)
(let [obj (.. bpy/context -object)
material (create-random-material)]
(-> obj .-data .-materials (.append material))))
(let [material (create-random-material)]
(-> bpy.context/object .-data .-materials (.append material))))

#_(create-torus 5, 5, [0 0 0] 48)

Expand Down Expand Up @@ -242,3 +236,10 @@ $ poetry build # build the package
$ poetry run python scripts/bb_package_install.py # install it in Blender
```

# License

This project is licensed under the Eclipse Public License 2.0. See the [LICENSE](LICENSE) file for details.

# Acknowledgments

The nREPL server is a spin-off of [Basilisp](https://github.com/basilisp-lang/basilisp)'s `basilisp.contrib.nrepl-server` namespace.
21 changes: 8 additions & 13 deletions examples/torus_pattern.lpy
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,31 @@
(:import bpy
math))

(def object (.. bpy/ops -object))
(def materials (.. bpy/data -materials))
(def mesh (.. bpy/ops -mesh))

(defn clear-mesh-objects []
(.select-all object ** :action "DESELECT")
(.select-by-type object ** :type "MESH")
(.delete object))
(.select-all bpy.ops/object ** :action "DESELECT")
(.select-by-type bpy.ops/object ** :type "MESH")
(.delete bpy.ops/object))

(clear-mesh-objects)

(defn create-random-material []
(let [mat (.new materials ** :name "RandomMaterial")
_ (set! (.-use-nodes mat) true)
(let [mat (.new bpy.data/materials ** :name "RandomMaterial")
_ (set! (.-use-nodes mat) true)
bsdf (aget (.. mat -node-tree -nodes) "Principled BSDF")]

(set! (-> bsdf .-inputs (aget "Base Color") .-default-value)
[(rand) (rand) (rand) 1])
mat))

(defn create-torus [radius tube-radius location segments]
(.primitive-torus-add mesh **
(.primitive-torus-add bpy.ops/mesh **
:major-radius radius
:minor-radius tube-radius
:location location
:major-segments segments
:minor-segments segments)
(let [obj (.. bpy/context -object)
material (create-random-material)]
(-> obj .-data .-materials (.append material))))
(let [material (create-random-material)]
(-> bpy.context/object .-data .-materials (.append material))))

#_(create-torus 5, 5, [0 0 0] 48)

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "basilisp-blender"
version = "0.2.0b1"
version = "0.2.0"
description = ""
authors = ["ikappaki"]
readme = "README.md"
Expand Down
Loading

0 comments on commit 67f63d3

Please sign in to comment.