Skip to content

Commit

Permalink
Merge pull request #17 from kolibril13/changelog
Browse files Browse the repository at this point in the history
Changelog 0.1.6
  • Loading branch information
kolibril13 authored Jan 13, 2025
2 parents 68b5ce3 + 328ed9f commit 59e59ae
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 25 deletions.
114 changes: 91 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,32 @@ Download here: https://extensions.blender.org/add-ons/csv-importer/

Walkthrough video:



https://github.com/user-attachments/assets/1b8a26d7-ce35-4717-bf73-bc05dbf3912a





## How to Use

Option 1: Drag and drop your CSV file directly into Blender’s viewport.

Option 2: Use the menu:
File → Import → CSV

### **Using the Data**
- The imported data will appear in Blender’s **Spreadsheet Editor**.
- Use the **Named Attribute** in **Geometry Nodes** to access the imported data.
### **Using the Data**

- The imported data will appear in Blender’s **Spreadsheet Editor**.
- Use the **Named Attribute** in **Geometry Nodes** to access the imported data.

And the data will show up in the speadsheet:

<img width="900" alt="image" src="https://github.com/user-attachments/assets/36f7e277-ab73-4335-936c-9ca25a32683b" />



you can reproduce the above example with this geometry nodes setup.
The corresponding Blender file can be downloaded [here](https://github.com/kolibril13/blender_csv_import/blob/main/generate_data/example_file_california_bounding_box.blend)

<img width="1471" alt="image" src="https://github.com/user-attachments/assets/515e7727-e995-4672-918a-1234c9fd0ad7" />

## Support this project



## Support this project
[![Buy Me a Coffee](https://img.shields.io/static/v1?label=&message=Buy%20Me%20a%20Coffee&color=FFDD00&logo=buy-me-a-coffee&logoColor=black)](https://buymeacoffee.com/jan_hendrik)
[![Buy Me a Coffee](https://img.shields.io/static/v1?label=&message=Buy%20Me%20a%20Coffee&color=FFDD00&logo=buy-me-a-coffee&logoColor=black)](https://buymeacoffee.com/jan_hendrik)

## Development instructions

Expand All @@ -52,11 +42,14 @@ The corresponding Blender file can be downloaded [here](https://github.com/kolib

### Build the extension:

For downloading the wheels files, run:
For downloading the wheels files, run:

```
/Applications/Blender.app/Contents/MacOS/Blender -b -P build.py
```

For building the app for all platforms, run

```
/Applications/Blender.app/Contents/MacOS/Blender --command extension build --split-platforms
```
Expand All @@ -70,9 +63,82 @@ uv run -m pytest

# Changelog

## Version 0.1.6

- Add Reload and Hot Reload operators https://github.com/kolibril13/blender_csv_import/pull/16#issue-2782446043

![shape_q8JB38xjnwPqY-cLurMz- at 25-01-13 12 40 57](https://github.com/user-attachments/assets/7e14ac30-a0af-45ab-aa06-61ef8f7e0bda)

- Support for 3D vectors (with potential JSON support in the future: https://github.com/BradyAJohnston/databpy/issues/3#issuecomment-2571415664). Here's a dataframe example

```py
import polars as pl
import numpy as np
from csv_importer.parsers import polars_df_to_bob

df = pl.DataFrame({
"Star": [
[58.2, 91.8, 0.0],
[58.1, 92.2, 0.0]
],
"Is_Visible": [True, False],
"Intensity": [10, 20],
})

bob = polars_df_to_bob(df, name="Test")
```

- new functions`update_obj_from_csv` and `update_bob_from_polars_df`

```py
from csv_importer.csv import load_csv
from csv_importer.parsers import update_obj_from_csv
from pathlib import Path

csv_path1 = Path("/Users/jan-hendrik/projects/blender_csv_import/docs/sample_datasets/data_california_housing.csv")
csv_path2 = Path("/Users/jan-hendrik/projects/blender_csv_import/docs/sample_datasets/data_gemeran_cities.csv")


bob = load_csv(csv_path1)
print(bob.name)
# out: CSV_data_california_housing

# Make changes to the CSV file using a text editor.
# Important note: The name of the Blender object won't change, only the underlying data.
update_obj_from_csv(bob, csv_path2)
```

```py
import polars as pl
from csv_importer.parsers import polars_df_to_bob, update_bob_from_polars_df

# Create initial DataFrame with star coordinates
df1 = pl.DataFrame({
"Star": [
[58.2, 91.8, 0.0],
[58.1, 92.2, 0.0]
]
})

# Convert DataFrame to 'bob' object
bob = polars_df_to_bob(df1, name="Test")

# Create a second DataFrame with new star coordinates
df2 = pl.DataFrame({
"Star": [
[1.2, 1.8, 0.0],
[1.1, 1.2, 0.0]
]
})

# Update 'bob' object with new data from df2
update_bob_from_polars_df(bob, df2)
```

## Version 0.1.5

### New Features

- **Drag-and-Drop:** Added support for drag-and-drop functionality into windows other than the viewport.
- **API Import Call:** Introduced an API for importing CSV data (note: this feature is not yet stable and may change in the future). Usage examples:

Expand All @@ -84,6 +150,7 @@ from csv_importer.parsers import polars_df_to_bob
### Usage Examples

1. **Loading CSV File:**

```python
>>> from csv_importer.csv import load_csv
>>> bob = load_csv("/Users/jan-hendrik/Desktop/data_california_housing.csv")
Expand All @@ -92,6 +159,7 @@ from csv_importer.parsers import polars_df_to_bob
```

2. **Converting Polars DataFrame:**

```python
from io import StringIO
import polars as pl
Expand All @@ -109,6 +177,7 @@ from csv_importer.parsers import polars_df_to_bob
---

### Blender Version Support

- **Supported Versions:**
- Blender 4.3.1 and later.
- Blender 4.2.5 (requires testing, I did not try this yet).
Expand All @@ -118,30 +187,29 @@ from csv_importer.parsers import polars_df_to_bob
---

### Improvements

- Properly skip string data when processing CSVs.
- Added test coverage for the CSV importer.
- Refactored the project structure for better organization.

---

### Additional Updates

- Use a new data wrapper using [databpy](https://github.com/BradyAJohnston/databpy) by @BradyAJohnston.
- Update to latest Polars library version: [1.19.0](https://pypi.org/project/polars/1.19.0/).

## 0.1.4

* Rename the imported mesh from "ImportedMesh" to "CSV_filename"


## 0.1.4

- Rename the imported mesh from "ImportedMesh" to "CSV_filename"

<!-- # might be a useful import snippet
import polars as pl
import bpy
from bl_ext.blender_org.csv_importer import PolarsMesh -->

<!--
<!--
and here another one
```
Expand All @@ -160,4 +228,4 @@ blender_mesh = PolarsMesh(dataframe=df, object_name=f"JSON OBJ")
# Link the new mesh to the Blender scene
bpy.context.collection.objects.link(blender_mesh.point_obj)
``` -->
``` -->
4 changes: 2 additions & 2 deletions csv_importer/blender_manifest.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
schema_version = "1.0.0"

id = "csv_importer"
version = "0.1.5"
version = "0.1.6"
name = "CSV Importer"
tagline = "import csv data to meshes in Blender"
maintainer = "Jan-Hendrik Müller<[email protected]>"
Expand All @@ -25,7 +25,7 @@ copyright =[
"2024 Jan-Hendrik Müller",
]
wheels = [
"./wheels/databpy-0.0.6-py3-none-any.whl",
"./wheels/databpy-0.0.8-py3-none-any.whl",
"./wheels/polars-1.19.0-cp39-abi3-macosx_10_12_x86_64.whl",
"./wheels/polars-1.19.0-cp39-abi3-macosx_11_0_arm64.whl",
"./wheels/polars-1.19.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
Expand Down

0 comments on commit 59e59ae

Please sign in to comment.