Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implements check for unnamed sketches #6

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import FreeCAD # noqa
import Sketcher # noqa
import re # Python Regular expression operations


# From own testing:
Expand Down Expand Up @@ -220,3 +221,12 @@ def get_sketches(doc: FreeCAD.Document):
sketches.append(obj)
return sketches

def get_unnamed_sketches(doc: FreeCAD.Document):
"""Returns all sketches with default naming FreeCAD document"""
pattern = r'^Sketch\d{0,3}$'
sketches = get_sketches(doc)
unnamed_sketches = []
for sketch in sketches:
if re.match(pattern, sketch.Label):
unnamed_sketches.append(sketch)
return unnamed_sketches
4 changes: 2 additions & 2 deletions commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import FreeCAD # noqa
import FreeCADGui # noqa

from assistant import get_under_constrained_sketches, get_over_constrained_sketches, has_open_sketches, has_complex_bodies, has_old_freecad_version
from assistant import get_under_constrained_sketches, get_over_constrained_sketches, has_open_sketches, has_complex_bodies, has_old_freecad_version, get_unnamed_sketches
from config import addon_work_dir


Expand Down Expand Up @@ -50,7 +50,7 @@ def Activated(self):
FreeCAD.Console.PrintMessage("Not implemented yet" + "\n")

FreeCAD.Console.PrintMessage("You have not given your sketch a useful name: ")
FreeCAD.Console.PrintMessage("Not implemented yet" + "\n")
FreeCAD.Console.PrintMessage(str(len(get_unnamed_sketches(FreeCAD.ActiveDocument)) > 0) + "\n")

FreeCAD.Console.PrintMessage("Your file size is getting large: ")
FreeCAD.Console.PrintMessage("Not implemented yet" + "\n")
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.