In [2]:
Copied!
import numpy as np
import databpy as db
vertex = np.array([[0, 0, 0]])
obj = db.create_bob(vertex, name="Mesh1")
obj.name
import numpy as np
import databpy as db
vertex = np.array([[0, 0, 0]])
obj = db.create_bob(vertex, name="Mesh1")
obj.name
Out[2]:
'Mesh1'
In [3]:
Copied!
obj.position
obj.position
Out[3]:
array([[0., 0., 0.]])
In [4]:
Copied!
import numpy as np
import databpy as db
coords = np.random.rand(20, 3)
obj = db.create_bob(coords, name="Mesh2")
obj.name
import numpy as np
import databpy as db
coords = np.random.rand(20, 3)
obj = db.create_bob(coords, name="Mesh2")
obj.name
Out[4]:
'Mesh2'
In [5]:
Copied!
obj.position[:3] # first three
obj.position[:3] # first three
Out[5]:
array([[0.1291904 , 0.00317181, 0.5135445 ], [0.94508129, 0.86277646, 0.97644675], [0.00203336, 0.87146598, 0.40898171]])
In [6]:
Copied!
%%time
import numpy as np
import databpy as db
# Generate 2 million random 3D points
coords = np.random.rand(2_000_000, 3)
# Create a mesh object using databpy
obj = db.create_bob(coords, name="Mesh2M")
print(obj.name)
%%time
import numpy as np
import databpy as db
# Generate 2 million random 3D points
coords = np.random.rand(2_000_000, 3)
# Create a mesh object using databpy
obj = db.create_bob(coords, name="Mesh2M")
print(obj.name)
Mesh2M CPU times: user 701 ms, sys: 40 ms, total: 741 ms Wall time: 736 ms
Setting Attributes¶
To run the code below, first install the Blender extension from the following link: https://extensions.blender.org/add-ons/csv-importer/
In [7]:
Copied!
import numpy as np
import polars as pl
from csv_importer.parsers import polars_df_to_bob
df = pl.DataFrame(
{
"Intensity": [10, 20],
}
)
bob = polars_df_to_bob(df, name="MeshInt")
import numpy as np
import polars as pl
from csv_importer.parsers import polars_df_to_bob
df = pl.DataFrame(
{
"Intensity": [10, 20],
}
)
bob = polars_df_to_bob(df, name="MeshInt")
In [8]:
Copied!
import numpy as np
import polars as pl
from csv_importer.parsers import polars_df_to_bob
df = pl.DataFrame(
{
"opacity": [0.34, 0.92],
}
)
bob = polars_df_to_bob(df, name="MeshFloat")
import numpy as np
import polars as pl
from csv_importer.parsers import polars_df_to_bob
df = pl.DataFrame(
{
"opacity": [0.34, 0.92],
}
)
bob = polars_df_to_bob(df, name="MeshFloat")
In [9]:
Copied!
import numpy as np
import polars as pl
from csv_importer.parsers import polars_df_to_bob
df = pl.DataFrame(
{
"Is_Visible": [True, False],
}
)
bob = polars_df_to_bob(df, name="MeshBool")
import numpy as np
import polars as pl
from csv_importer.parsers import polars_df_to_bob
df = pl.DataFrame(
{
"Is_Visible": [True, False],
}
)
bob = polars_df_to_bob(df, name="MeshBool")
In [10]:
Copied!
import numpy as np
import polars as pl
from csv_importer.parsers import polars_df_to_bob
df = pl.DataFrame({
"Star": [
[3.4, 3.5, 0.0],
[3.1, 5.6, 0.0]
]
})
obj = polars_df_to_bob(df, name="MeshVector")
import numpy as np
import polars as pl
from csv_importer.parsers import polars_df_to_bob
df = pl.DataFrame({
"Star": [
[3.4, 3.5, 0.0],
[3.1, 5.6, 0.0]
]
})
obj = polars_df_to_bob(df, name="MeshVector")
In [11]:
Copied!
import numpy as np
import polars as pl
from csv_importer.parsers import polars_df_to_bob
df = pl.DataFrame({
"String": ["Hello", "World"],
})
# Stings are not supported
obj = polars_df_to_bob(df, name="MeshVector")
import numpy as np
import polars as pl
from csv_importer.parsers import polars_df_to_bob
df = pl.DataFrame({
"String": ["Hello", "World"],
})
# Stings are not supported
obj = polars_df_to_bob(df, name="MeshVector")
In [12]:
Copied!
# all together
import numpy as np
import polars as pl
from csv_importer.parsers import polars_df_to_bob
df = pl.DataFrame({
"Intensity": [10, 20],
"opacity": [0.34, 0.92],
"Is_Visible": [True, False],
"Star": [
[3.4, 3.5, 0.0],
[3.1, 5.6, 0.0]
]
})
obj = polars_df_to_bob(df, name="MeshVector")
# all together
import numpy as np
import polars as pl
from csv_importer.parsers import polars_df_to_bob
df = pl.DataFrame({
"Intensity": [10, 20],
"opacity": [0.34, 0.92],
"Is_Visible": [True, False],
"Star": [
[3.4, 3.5, 0.0],
[3.1, 5.6, 0.0]
]
})
obj = polars_df_to_bob(df, name="MeshVector")
In [13]:
Copied!
from pathlib import Path
from csv_importer.csv import load_csv
csv_path = Path.home() / "projects" / "blender_csv_import" / "docs" / "sample_datasets" / "data_california_housing.csv"
# `load_csv` is like `like polars_df_to_bob`, but with a csv path input
obj = load_csv(csv_path)
print(obj.name)
from pathlib import Path
from csv_importer.csv import load_csv
csv_path = Path.home() / "projects" / "blender_csv_import" / "docs" / "sample_datasets" / "data_california_housing.csv"
# `load_csv` is like `like polars_df_to_bob`, but with a csv path input
obj = load_csv(csv_path)
print(obj.name)
CSV_data_california_housing
In [ ]:
Copied!