Compare commits

...

8 Commits

Author SHA1 Message Date
izzy lyseggen 03f94d6371 fix(convert): breps and dates (#87) 2022-03-28 15:03:27 +01:00
izzy lyseggen c220337aec chore: upgrade specklepy and add Blender v3.1 to ci (#86)
* chore(specklepy): upgrade to 2.6.3

* ci: add py 3.10 for blender 3.1
2022-03-28 11:47:56 +01:00
izzy lyseggen 1b67304cfc fix(converter): skip if not Pincipled BSDF (#85) 2022-03-09 11:07:35 +00:00
izzy lyseggen 25a1ec1cd1 ci: fix py 3.9 package install (#83)
* ci: test upgrade py

* ci: how about now?

* ci: we did it! 💃
2022-02-23 16:42:01 +00:00
izzy lyseggen 8296e48c28 Merge pull request #81 from specklesystems/izzy/displayvals
fix(convert): new `displayValue` to native & specklepy update
2022-02-23 11:56:15 +00:00
izzy lyseggen ca81ac6fd6 feat(convert): list displayvals to native 2022-02-23 11:50:33 +00:00
izzy lyseggen 88212b94b6 fix(users): none commit bug 2022-02-23 11:50:21 +00:00
izzy lyseggen 3375a04007 chore: update specklepy 2022-02-23 11:06:56 +00:00
8 changed files with 523 additions and 364 deletions
+20 -8
View File
@@ -20,8 +20,8 @@ jobs:
- checkout
- attach_workspace:
at: ./
- run:
name: Install specklepy with python 3.7
- run:
name: Install specklepy with python 3.7 for Blender v2.93
shell: powershell.exe
command: |
$pyarr=(python --version).split(' ')[1].split('.')
@@ -29,16 +29,28 @@ jobs:
echo "using python version:" $pyver
$specklepy=(python patch_version.py)
python -m pip install --target=./modules-$pyver specklepy==$specklepy
- run:
name: Install python 3.9 and specklepy
- run:
name: Install python 3.9 and specklepy for Blender v3.0
shell: powershell.exe
command: |
choco install python --version=3.9.2
$pyarr=(C:\Python39\python.exe --version).split(' ')[1].split('.')
choco upgrade python --version=3.9.7
refreshenv
$pyarr=(py --version).split(' ')[1].split('.')
$pyver=($pyarr[0..1] -join '.')
echo "using python version:" $pyver
$specklepy=(python patch_version.py)
C:\Python39\python.exe -m pip install --target=./modules-$pyver specklepy==$specklepy
py -m pip install --target=./modules-$pyver specklepy==$specklepy
- run:
name: Install python 3.10 and specklepy for Blender v3.1
shell: powershell.exe
command: |
choco upgrade python --version=3.10.2
refreshenv
$pyarr=(py --version).split(' ')[1].split('.')
$pyver=($pyarr[0..1] -join '.')
echo "using python version:" $pyver
$specklepy=(python patch_version.py)
py -m pip install --target=./modules-$pyver specklepy==$specklepy
- run:
name: Patch
shell: powershell.exe
@@ -79,7 +91,7 @@ jobs:
root: ./
paths:
- modules-*
get-ci-tools: # Clones our ci tools and persists them to the workspace
docker:
- image: cimg/base:2021.01
+7 -15
View File
@@ -17,7 +17,6 @@ SUPPORTED_CURVES = (Line, Polyline, Curve, Arc, Polycurve)
CAN_CONVERT_TO_NATIVE = (
Mesh,
Brep,
*SUPPORTED_CURVES,
Transform,
BlockDefinition,
@@ -28,10 +27,9 @@ CAN_CONVERT_TO_NATIVE = (
def can_convert_to_native(speckle_object):
if type(speckle_object) in CAN_CONVERT_TO_NATIVE:
return True
display = getattr(
if getattr(
speckle_object, "displayMesh", getattr(speckle_object, "displayValue", None)
)
if display:
):
return True
_report(f"Could not convert unsupported Speckle object: {speckle_object}")
@@ -43,8 +41,9 @@ def convert_to_native(speckle_object, name=None):
speckle_name = (
name
or getattr(speckle_object, "name", None)
or speckle_object.speckle_type + f" -- {speckle_object.id}"
or f"{speckle_object.speckle_type} -- {speckle_object.id}"
)
if speckle_type not in CAN_CONVERT_TO_NATIVE:
display = getattr(
speckle_object, "displayMesh", getattr(speckle_object, "displayValue", None)
@@ -55,9 +54,11 @@ def convert_to_native(speckle_object, name=None):
# add parent type here so we can use it as a blender custom prop
# not making it hidden, so it will get added on send as i think it might be helpful? can reconsider
if isinstance(display, list):
converted = []
for item in display:
item.parent_speckle_type = speckle_object.speckle_type
convert_to_native(item)
converted.append(convert_to_native(item))
return converted
else:
display.parent_speckle_type = speckle_object.speckle_type
return convert_to_native(display, speckle_name)
@@ -69,8 +70,6 @@ def convert_to_native(speckle_object, name=None):
try:
if speckle_type is Mesh:
obj_data = mesh_to_native(speckle_object, name=speckle_name, scale=scale)
elif speckle_type is Brep:
obj_data = brep_to_native(speckle_object, name=speckle_name, scale=scale)
elif speckle_type in SUPPORTED_CURVES:
obj_data = icurve_to_native(speckle_object, name=speckle_name, scale=scale)
elif speckle_type is Transform:
@@ -113,13 +112,6 @@ def convert_to_native(speckle_object, name=None):
return blender_object
def brep_to_native(speckle_brep, name, scale=1.0):
display = getattr(
speckle_brep, "displayMesh", getattr(speckle_brep, "displayValue", None)
)
return mesh_to_native(display, name, scale) if display else None
def mesh_to_native(speckle_mesh, name, scale=1.0):
if name in bpy.data.meshes.keys():
+6 -1
View File
@@ -245,10 +245,15 @@ def material_to_speckle(blender_object) -> RenderMaterial:
return
blender_mat = blender_object.data.materials[0]
if not blender_mat:
return
speckle_mat = RenderMaterial()
speckle_mat.name = blender_mat.name
if blender_mat.use_nodes is True:
if blender_mat.use_nodes is True and blender_mat.node_tree.nodes.get(
"Principled BSDF"
):
inputs = blender_mat.node_tree.nodes["Principled BSDF"].inputs
speckle_mat.diffuse = to_argb_int(inputs["Base Color"].default_value)
speckle_mat.emissive = to_argb_int(inputs["Emission"].default_value)
+4 -2
View File
@@ -25,7 +25,7 @@ from bpy_speckle.clients import speckle_clients
from bpy_speckle.operators.users import add_user_stream
from specklepy.api import operations
from specklepy.api.credentials import StreamWrapper
from specklepy.api.wrapper import StreamWrapper
from specklepy.api.resources.stream import Stream
from specklepy.transports.server import ServerTransport
from specklepy.objects.geometry import *
@@ -127,7 +127,9 @@ def bases_to_native(context, collections, scale, stream_id, func=None):
def base_to_native(context, base, scale, stream_id, col, existing, func=None):
new_objects = [convert_to_native(base)]
new_objects = convert_to_native(base)
if not isinstance(new_objects, list):
new_objects = [new_objects]
if hasattr(base, "properties") and base.properties is not None:
new_objects.extend(get_speckle_subobjects(base.properties, scale, base.id))
+3 -2
View File
@@ -6,6 +6,7 @@ from bpy_speckle.functions import _report
from bpy_speckle.clients import speckle_clients
from specklepy.api.client import SpeckleClient
from specklepy.api.credentials import get_local_accounts
from datetime import datetime
class LoadUsers(bpy.types.Operator):
@@ -78,10 +79,10 @@ def add_user_stream(user, stream):
for c in b.commits.items:
commit = branch.commits.add()
commit.id = commit.name = c.id
commit.message = c.message
commit.message = c.message or ""
commit.author_name = c.authorName
commit.author_id = c.authorId
commit.created_at = c.createdAt
commit.created_at = datetime.strftime(c.createdAt, "%Y-%m-%d %H:%M:%S.%f%Z")
commit.source_application = str(c.sourceApplication)
if hasattr(s, "baseProperties"):
+6 -8
View File
@@ -12,7 +12,7 @@ from bpy.props import (
EnumProperty,
)
import datetime
from datetime import datetime
"""
Compatibility
@@ -177,7 +177,7 @@ class VIEW3D_PT_SpeckleActiveStream(bpy.types.Panel):
stream = user.streams[user.active_stream]
# user.active_stream = min(user.active_stream, len(user.streams) - 1)
row = col.row()
row.label(text="{} ({})".format(stream.name, stream.id))
row.label(text=f"{stream.name} ({stream.id})")
row.operator("speckle.stream_copy_id", text="", icon="COPY_ID")
col.separator()
@@ -205,13 +205,11 @@ class VIEW3D_PT_SpeckleActiveStream(bpy.types.Panel):
row.label(text=line)
area.separator()
dt = datetime.datetime.strptime(
commit.created_at, "%Y-%m-%dT%H:%M:%S.%fZ"
)
col.label(text="{}".format(dt.ctime()))
col.label(
text="{} ({})".format(commit.author_name, commit.author_id)
dt = datetime.strptime(
commit.created_at, "%Y-%m-%d %H:%M:%S.%f%Z"
)
col.label(text=f"{dt.ctime()}")
col.label(text=f"{commit.author_name} ({commit.author_id})")
col.label(text=commit.source_application)
else:
col.label(text="No branches found!")
Generated
+475 -326
View File
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -6,8 +6,8 @@ authors = ["izzy lyseggen <izzy.lyseggen@gmail.com>"]
license = "Apache-2.0"
[tool.poetry.dependencies]
python = ">=3.7,<3.8"
specklepy = "^2.5.1"
python = ">=3.7,<3.10"
specklepy = "^2.6.3"
[tool.poetry.dev-dependencies]
devtools = "^0.6.1"