Thanks @Petras_Vestartas
-give Error=``Error building script: Cannot install compas-wood==2.4.0 and compas==2.4.3 because these package versions have conflicting dependencies.```
and Error building script: Cannot install compas-wood==2.4.0 and compas==2.4.3 because these package versions have conflicting dependencies.
I have corrected that kind of code
#! python3
#venv: timber_connections
#r: compas==2.8.1, compas-wood==2.4.0, wood-nano==0.2.0, wood-rui==0.2.0
import subprocess
import sys
def check_version(pkg, target_version):
try:
import importlib.metadata as metadata
version = metadata.version(pkg)
return version == target_version
except ImportError:
return False
except metadata.PackageNotFoundError:
return False
def install_package(pkg):
subprocess.check_call([sys.executable, "-m", "pip", "install", "--upgrade", pkg])
def uninstall_package(pkg):
subprocess.call([sys.executable, "-m", "pip", "uninstall", "-y", pkg])
packages = {
"compas": "2.8.1",
"compas-wood": "2.4.0",
"wood-nano": "0.2.0",
"wood-rui": "0.2.0"
}
for pkg, ver in packages.items():
if not check_version(pkg, ver):
if pkg == "compas":
uninstall_package(pkg)
install_package(f"{pkg}=={ver}")
from compas_wood.binding_rhino import mesh_skeleton
if mesh:
polylines = mesh_skeleton(mesh)
However, the results of the centerline detection are not very precise. Are there any settings in this library that can be adjusted to improve the accuracy of the output lines???
@Petras_Vestartas
I applied these settings, but they had no effect on the result:
#! python3
#venv: timber_connections
#r: compas==2.8.1, compas-wood==2.4.0, wood-nano==0.2.0, wood-rui==0.2.0
import subprocess
import sys
def check_version(pkg, target_version):
try:
import importlib.metadata as metadata
version = metadata.version(pkg)
return version == target_version
except ImportError:
return False
except metadata.PackageNotFoundError:
return False
def install_package(pkg):
subprocess.check_call([sys.executable, "-m", "pip", "install", "--upgrade", pkg])
def uninstall_package(pkg):
subprocess.call([sys.executable, "-m", "pip", "uninstall", "-y", pkg])
packages = {
"compas": "2.8.1",
"compas-wood": "2.4.0",
"wood-nano": "0.2.0",
"wood-rui": "0.2.0"
}
for pkg, ver in packages.items():
if not check_version(pkg, ver):
if pkg == "compas":
uninstall_package(pkg)
install_package(f"{pkg}=={ver}")
from compas_wood.binding_rhino import mesh_skeleton
if mesh:
try:
polylines = mesh_skeleton(
mesh,
voxel_size=0.03,
smooth_iterations=12,
tolerance=0.001,
fit_nurbs=True
)
except TypeError:
polylines = mesh_skeleton(mesh)