CAM: No need to copy defaultl shapes anymore, because the asset manager now dynamically fetches built-in shapes as a fallback
This commit is contained in:
@@ -30,7 +30,7 @@ import unittest
|
||||
from Path.Tool.assets import AssetManager, MemoryStore, DummyAssetSerializer
|
||||
from Path.Tool.library.serializers import FCTLSerializer
|
||||
from Path.Tool.toolbit.serializers import FCTBSerializer
|
||||
from Path.Tool.camassets import ensure_assets_initialized
|
||||
from Path.Tool.camassets import ensure_assets_initialized, ensure_toolbitshape_assets_present
|
||||
from Path.Tool.library import Library
|
||||
from Path.Tool.toolbit import ToolBit
|
||||
from Path.Tool.shape import ToolBitShape
|
||||
@@ -235,6 +235,7 @@ class PathTestWithAssets(PathTestBase):
|
||||
# Include the built-in assets from src/Mod/CAM/Tools.
|
||||
# These functions only copy if there are no assets, so this
|
||||
# must be done BEFORE adding the additional test assets below.
|
||||
ensure_toolbitshape_assets_present(self.assets, self.asset_store.name)
|
||||
ensure_assets_initialized(self.assets, self.asset_store.name)
|
||||
|
||||
# Additional test assets.
|
||||
|
||||
@@ -85,10 +85,17 @@ def ensure_toolbit_assets_initialized(asset_manager: AssetManager, store_name: s
|
||||
ensure_toolbits_have_shape_type(asset_manager, store_name)
|
||||
|
||||
|
||||
def ensure_toolbitshape_assets_initialized(asset_manager: AssetManager, store_name: str = "local"):
|
||||
def ensure_toolbitshape_assets_present(asset_manager: AssetManager, store_name: str = "local"):
|
||||
"""
|
||||
Ensures the given store is initialized with built-in shapes
|
||||
if it is currently empty.
|
||||
if it is currently empty. This copies all built-in shapes,
|
||||
which is generally not recommended, but is useful for
|
||||
testing.
|
||||
|
||||
In practice, the built-in tools don't need to be copied,
|
||||
because the CamAssetManager will automatically fall back to
|
||||
fetching them from the builtin store if they are not
|
||||
present in the local store (=the user's Shape directory).
|
||||
"""
|
||||
builtin_shape_path = Preferences.getBuiltinShapePath()
|
||||
|
||||
@@ -118,6 +125,17 @@ def ensure_toolbitshape_assets_initialized(asset_manager: AssetManager, store_na
|
||||
asset_manager.add_file("toolbitshapepng", path, asset_id=path.stem + ".png")
|
||||
|
||||
|
||||
def ensure_toolbitshape_assets_initialized(asset_manager: AssetManager, store_name: str = "local"):
|
||||
"""
|
||||
Copies an example shape to the given store if it is currently empty.
|
||||
"""
|
||||
builtin_shape_path = Preferences.getBuiltinShapePath()
|
||||
|
||||
if asset_manager.is_empty("toolbitshape", store=store_name):
|
||||
path = builtin_shape_path / "endmill.fcstd"
|
||||
asset_manager.add_file("toolbitshape", path, store=store_name, asset_id="example")
|
||||
|
||||
|
||||
def ensure_assets_initialized(asset_manager: AssetManager, store="local"):
|
||||
"""
|
||||
Ensures the given store is initialized with built-in assets.
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"version": 2,
|
||||
"name": "30 Deg. V-Bit",
|
||||
"shape": "v-bit.fcstd",
|
||||
"shape-type": "VBit",
|
||||
"parameter": {
|
||||
"CuttingEdgeAngle": "30.0000 \u00b0",
|
||||
"Diameter": "10.0000 mm",
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"version": 2,
|
||||
"name": "375-16_Tap",
|
||||
"shape": "tap.fcstd",
|
||||
"shape-type": "tap",
|
||||
"parameter": {
|
||||
"Coating": "None",
|
||||
"CuttingEdgeLength": "1.063 \"",
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"version": 2,
|
||||
"name": "45 Deg. V-Bit",
|
||||
"shape": "v-bit.fcstd",
|
||||
"shape-type": "VBit",
|
||||
"parameter": {
|
||||
"CuttingEdgeAngle": "45.0000 \u00b0",
|
||||
"Diameter": "10.0000 mm",
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"version": 2,
|
||||
"name": "45 Deg. Chamfer",
|
||||
"shape": "chamfer.fcstd",
|
||||
"shape-type": "Chamfer",
|
||||
"parameter": {
|
||||
"CuttingEdgeAngle": "45.0000 \u00b0",
|
||||
"CuttingEdgeHeight": "6.3500 mm",
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"version": 2,
|
||||
"name": "5mm-thread-cutter",
|
||||
"shape": "thread-mill.fcstd",
|
||||
"shape-type": "ThreadMill",
|
||||
"parameter": {
|
||||
"Crest": "0.10 mm",
|
||||
"Diameter": "5.00 mm",
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"version": 2,
|
||||
"name": "5mm Drill",
|
||||
"shape": "drill.fcstd",
|
||||
"shape-type": "Drill",
|
||||
"parameter": {
|
||||
"Diameter": "5.0000 mm",
|
||||
"Length": "50.0000 mm",
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"version": 2,
|
||||
"name": "5mm Endmill",
|
||||
"shape": "endmill.fcstd",
|
||||
"shape-type": "Endmill",
|
||||
"parameter": {
|
||||
"CuttingEdgeHeight": "30.0000 mm",
|
||||
"Diameter": "5.0000 mm",
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"version": 2,
|
||||
"name": "60 Deg. V-Bit",
|
||||
"shape": "v-bit.fcstd",
|
||||
"shape-type": "VBit",
|
||||
"parameter": {
|
||||
"CuttingEdgeAngle": "60.0000 \u00b0",
|
||||
"Diameter": "10.0000 mm",
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"version": 2,
|
||||
"name": "6mm Ball End",
|
||||
"shape": "ballend.fcstd",
|
||||
"shape-type": "Ballend",
|
||||
"parameter": {
|
||||
"CuttingEdgeHeight": "40.0000 mm",
|
||||
"Diameter": "6.0000 mm",
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"version": 2,
|
||||
"name": "6 mm Bull Nose",
|
||||
"shape": "bullnose.fcstd",
|
||||
"shape-type": "Bullnose",
|
||||
"parameter": {
|
||||
"CuttingEdgeHeight": "40.0000 mm",
|
||||
"Diameter": "6.0000 mm",
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"version": 2,
|
||||
"name": "90 Deg. V-Bit",
|
||||
"shape": "v-bit.fcstd",
|
||||
"shape-type": "VBit",
|
||||
"parameter": {
|
||||
"CuttingEdgeAngle": "90.0000 \u00b0",
|
||||
"Diameter": "10.0000 mm",
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"version": 2,
|
||||
"name": "Probe",
|
||||
"shape": "probe.fcstd",
|
||||
"shape-type": "Probe",
|
||||
"parameter": {
|
||||
"Diameter": "6.0000 mm",
|
||||
"Length": "50.0000 mm",
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"version": 2,
|
||||
"name": "Slitting Saw",
|
||||
"shape": "slittingsaw.fcstd",
|
||||
"shape-type": "SlittingSaw",
|
||||
"parameter": {
|
||||
"BladeThickness": "3.0000 mm",
|
||||
"CapHeight": "3.0000 mm",
|
||||
|
||||
Reference in New Issue
Block a user