Explore an alternative
Goal: try a lighter bracket without disturbing the main design, then adopt it.
You need: a project with at least one version.
Create a workspace
-
Click the workspace pill Main ▾ and choose New workspace…. To start from an earlier point instead, right-click a version or history entry and choose Branch to create workspace….
-
Give it a name, for example Lightweight, and optionally a description.
-
Click Create workspace.
You are now in Lightweight. The pill, the status bar and the history header all say so, and the graph has a new lane.
Work in the workspace
Edit and save as usual, for example make the base plate 6 mm instead of 12 mm. Create versions here too, for example LW-1 – Lightweight option for review.
Switch between workspaces
Choose another workspace from the pill’s menu, or right-click its node in the graph and choose Switch to …. Strata saves your work first if you agree, rewrites the documents that differ and reloads them in FreeCAD. Main still has the 12 mm plate; Lightweight has the 6 mm one.
| Opening an assembly can make FreeCAD mark it as modified, because it refreshes external links. Strata then asks whether to save first. After a switch, Strata clears that flag for documents you did not edit. |
Merge the alternative into Main
-
Switch to Main.
-
Open the pill’s menu and choose Merge into Main > Lightweight. Or right-click the Lightweight node and choose Merge Lightweight into Main.
-
Review the merge dialog, then click Merge.
Documents changed only in Lightweight are taken, documents changed only in Main are kept, and you choose for documents changed in both. The merge appears in history as Merged Lightweight into Main, and a banner offers Undo merge right afterwards. Merge workspaces covers merge strategies, conflicts and undo step by step.
Delete a workspace
Right-click the workspace’s node in the graph and choose Delete workspace…. Its versions are kept. Main cannot be deleted, and you cannot delete the workspace you are in.
Same thing in Python
# SPDX-License-Identifier: LGPL-2.1-or-later
"""Minimal working example: try a design alternative in a workspace, compare it, merge it.
Run with FreeCAD's console (Strata installed):
freecadcmd workspaces.py [empty-folder]
"""
import os
import sys
import tempfile
import FreeCAD as App
from strata.project import Project
folder = next((a for a in sys.argv[1:] if not a.endswith(".py")), None) or tempfile.mkdtemp()
path = os.path.join(folder, "Bracket.FCStd")
doc = App.newDocument("Bracket")
body = doc.addObject("Part::Box", "Body")
body.Length, body.Width, body.Height = 60, 40, 12
doc.recompute()
doc.saveAs(path)
App.closeDocument(doc.Name)
project = Project.create(folder, "Ada Lovelace", "ada@example.com")
v1 = project.create_version("V1", "Baseline")
# A workspace is a separate line of work. Creating one switches to it.
project.create_workspace("Lightweight", description="thinner plate")
doc = App.openDocument(path)
doc.getObject("Body").Height = 6
doc.recompute()
doc.save()
project.record()
App.closeDocument(doc.Name)
print("Workspaces:", ", ".join(w.display for w in project.workspaces()))
# Main is untouched while you work elsewhere
project.switch_workspace("main")
doc = App.openDocument(path)
print("Height in Main:", doc.getObject("Body").Height)
App.closeDocument(doc.Name)
# What would change? A semantic comparison, feature by feature
for document, diff in project.diff(v1.sha, project.repo.rev_parse("refs/heads/Lightweight")).items():
for change in diff.modified:
for p in change.props:
print("Compare %s: %s.%s %s -> %s" % (document, change.label, p.name, p.old, p.new))
# Bring the alternative into Main
plan = project.merge_plan("Lightweight")
print("Taken automatically:", plan.take_theirs, "| conflicts:", plan.conflicts)
project.merge(plan)
doc = App.openDocument(path)
print("Height in Main after merge:", doc.getObject("Body").Height)
print("Latest entry:", project.history()[0].title)
App.closeDocument(doc.Name)
project.repo.close()
freecadcmd workspaces.pyWorkspaces: Main, Lightweight
Height in Main: 12.0 mm
Compare Bracket.FCStd: Body.Height 12 mm -> 6 mm
Taken automatically: ['Bracket.FCStd'] | conflicts: []
Height in Main after merge: 6.0 mm
Latest entry: Merged Lightweight into Main