@@ -280,41 +280,50 @@ def setupAdditionalProperties(self, obj):
280280 "App::PropertyLinkList" ,
281281 "BaseShapes" ,
282282 "Path" ,
283- QT_TRANSLATE_NOOP ("App::Property" , "Additional base objects to be engraved" ),
283+ QT_TRANSLATE_NOOP (
284+ "App::Property" , "Additional base objects to be engraved"
285+ ),
284286 )
285287 obj .setEditorMode ("BaseShapes" , 2 ) # hide
286288
287- obj .addProperty (
288- "App::PropertyBool" ,
289- "OptimizeMovements" ,
290- "Path" ,
291- QT_TRANSLATE_NOOP ("App::Property" , "Optimize movements" ),
292- )
289+ if not hasattr (obj , "OptimizeMovements" ):
293290
294- obj .addProperty (
295- "App::PropertyBool" ,
296- "FinishingPass" ,
297- "Path" ,
298- QT_TRANSLATE_NOOP ("App::Property" , "Add finishing pass" ),
299- )
291+ obj .addProperty (
292+ "App::PropertyBool" ,
293+ "OptimizeMovements" ,
294+ "Path" ,
295+ QT_TRANSLATE_NOOP ("App::Property" , "Optimize movements" ),
296+ )
297+ obj .OptimizeMovements = False
300298
301- obj .addProperty (
302- "App::PropertyDistance" ,
303- "FinishingPassZOffset" ,
304- "Path" ,
305- QT_TRANSLATE_NOOP ("App::Property" , "Finishing pass Z offset" ),
306- )
299+ if not hasattr (obj , "FinishingPass" ):
300+ obj .addProperty (
301+ "App::PropertyBool" ,
302+ "FinishingPass" ,
303+ "Path" ,
304+ QT_TRANSLATE_NOOP ("App::Property" , "Add finishing pass" ),
305+ )
306+ obj .FinishingPass = False
307+
308+ if not hasattr (obj , "FinishingPassZOffset" ):
309+ obj .addProperty (
310+ "App::PropertyDistance" ,
311+ "FinishingPassZOffset" ,
312+ "Path" ,
313+ QT_TRANSLATE_NOOP ("App::Property" , "Finishing pass Z offset" ),
314+ )
307315
308- obj .FinishingPass = False
309- obj .FinishingPassZOffset = "0.00"
316+ obj .FinishingPassZOffset = "0.00"
310317
311318 def initOperation (self , obj ):
312319 """initOperation(obj) ... create vcarve specific properties."""
313320 obj .addProperty (
314321 "App::PropertyFloat" ,
315322 "Discretize" ,
316323 "Path" ,
317- QT_TRANSLATE_NOOP ("App::Property" , "The deflection value for discretizing arcs" ),
324+ QT_TRANSLATE_NOOP (
325+ "App::Property" , "The deflection value for discretizing arcs"
326+ ),
318327 )
319328 obj .addProperty (
320329 "App::PropertyFloat" ,
@@ -334,7 +343,7 @@ def initOperation(self, obj):
334343 )
335344
336345 obj .Colinear = 10.0
337- obj .Discretize = 0.01
346+ obj .Discretize = 0.1
338347 obj .Tolerance = Path .Preferences .defaultGeometryTolerance ()
339348 self .setupAdditionalProperties (obj )
340349
@@ -367,7 +376,9 @@ def insert_many_wires(vd, wires):
367376 dist = ptv [- 1 ].distanceToPoint (ptv [0 ])
368377 if dist < FreeCAD .Base .Precision .confusion ():
369378 Path .Log .debug (
370- "Removing bad carve point: {} from polygon origin" .format (dist )
379+ "Removing bad carve point: {} from polygon origin" .format (
380+ dist
381+ )
371382 )
372383 del ptv [- 1 ]
373384 ptv .append (ptv [0 ])
@@ -390,13 +401,17 @@ def insert_many_wires(vd, wires):
390401 e .Color = PRIMARY
391402 else :
392403 e .Color = SECONDARY
404+
405+ vd .colorColinear (COLINEAR , obj .Colinear )
406+ vd .colorTwins (TWIN )
407+
393408 vd .colorExterior (EXTERIOR1 )
394409 vd .colorExterior (
395410 EXTERIOR2 ,
396- lambda v : not f .isInside (v .toPoint (f .BoundBox .ZMin ), obj .Tolerance , True ),
411+ lambda v : not f .isInside (
412+ v .toPoint (f .BoundBox .ZMin ), obj .Tolerance , True
413+ ),
397414 )
398- vd .colorColinear (COLINEAR , obj .Colinear )
399- vd .colorTwins (TWIN )
400415
401416 wires = _collectVoronoiWires (vd )
402417 wires = _sortVoronoiWires (wires )
@@ -462,15 +477,19 @@ def _cutWire(wire, currentPosition=None):
462477 path .append (Path .Command ("G0 Z{}" .format (obj .SafeHeight .Value )))
463478 path .append (
464479 Path .Command (
465- "G0 X{} Y{} Z{}" .format (newPosition .x , newPosition .y , obj .SafeHeight .Value )
480+ "G0 X{} Y{} Z{}" .format (
481+ newPosition .x , newPosition .y , obj .SafeHeight .Value
482+ )
466483 )
467484 )
468485
469486 hSpeed = obj .ToolController .HorizFeed .Value
470487 vSpeed = obj .ToolController .VertFeed .Value
471488 path .append (
472489 Path .Command (
473- "G1 X{} Y{} Z{} F{}" .format (newPosition .x , newPosition .y , newPosition .z , vSpeed )
490+ "G1 X{} Y{} Z{} F{}" .format (
491+ newPosition .x , newPosition .y , newPosition .z , vSpeed
492+ )
474493 )
475494 )
476495 for e in wire :
@@ -496,7 +515,9 @@ def _cutWire(wire, currentPosition=None):
496515 _maximumUsableDepth = _get_maximumUsableDepth (wires , geom )
497516 if _maximumUsableDepth is not None :
498517 maximumUsableDepth = _maximumUsableDepth
499- Path .Log .debug (f"Maximum usable depth for current face: { maximumUsableDepth } " )
518+ Path .Log .debug (
519+ f"Maximum usable depth for current face: { maximumUsableDepth } "
520+ )
500521
501522 # first pass
502523 cutWires (wires , pathlist , obj .OptimizeMovements )
@@ -534,7 +555,9 @@ def opExecute(self, obj):
534555
535556 if obj .ToolController .Tool .CuttingEdgeAngle >= 180.0 :
536557 Path .Log .info (
537- translate ("CAM_Vcarve" , "Engraver cutting edge angle must be < 180 degrees." )
558+ translate (
559+ "CAM_Vcarve" , "Engraver cutting edge angle must be < 180 degrees."
560+ )
538561 )
539562 return
540563
@@ -552,9 +575,9 @@ def opExecute(self, obj):
552575
553576 if not faces :
554577 for model in self .model :
555- if model .isDerivedFrom ("Sketcher::SketchObject" ) or model . isDerivedFrom (
556- "Part::Part2DObject "
557- ):
578+ if model .isDerivedFrom (
579+ "Sketcher::SketchObject "
580+ ) or model . isDerivedFrom ( "Part::Part2DObject" ) :
558581 faces .extend (model .Shape .Faces )
559582
560583 if faces :
@@ -602,10 +625,14 @@ def debugVoronoi(self, obj):
602625 """Debug function to display calculated voronoi edges"""
603626
604627 if not getattr (self , "voronoiDebugCache" , None ):
605- Path .Log .error ("debugVoronoi: empty debug cache. Recompute VCarve operation first" )
628+ Path .Log .error (
629+ "debugVoronoi: empty debug cache. Recompute VCarve operation first"
630+ )
606631 return
607632
608- vPart = FreeCAD .activeDocument ().addObject ("App::Part" , f"{ obj .Name } -VoronoiDebug" )
633+ vPart = FreeCAD .activeDocument ().addObject (
634+ "App::Part" , f"{ obj .Name } -VoronoiDebug"
635+ )
609636
610637 wiresToShow = []
611638
0 commit comments