Merge pull request #7526 from paullee0/ArchWall_15_UseAndCreate-ArchSketch-If-Present

[ArchWall]  Use and Create ArchSketch if add-on is present
This commit is contained in:
Yorik van Havre
2022-11-16 11:08:11 +01:00
committed by GitHub
2 changed files with 53 additions and 4 deletions

View File

@@ -0,0 +1,32 @@
#***************************************************************************
#* *
#* Copyright (c) 2022 *
#* Paul Lee <paullee0@gmail.com> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) *
#* as published by the Free Software Foundation; either version 2 of *
#* the License, or (at your option) any later version. *
#* for detail see the LICENCE text file. *
#* *
#* This program is distributed in the hope that it will be useful, *
#* but WITHOUT ANY WARRANTY; without even the implied warranty of *
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
#* GNU Library General Public License for more details. *
#* *
#* You should have received a copy of the GNU Library General Public *
#* License along with this program; if not, write to the Free Software *
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
#* USA *
#* *
#***************************************************************************
class ArchSketchObject:
def __init__(self, obj):
pass
class ArchSketch(ArchSketchObject):
def __init__(self, obj):
pass
#from ArchSketchObjectExt import ArchSketch # Not works

View File

@@ -171,12 +171,23 @@ def joinWalls(walls,delete=False):
if base.Base:
if base.Base.Shape.Faces:
return None
if Draft.getType(base.Base) == "Sketcher::SketchObject":
# Use ArchSketch if SketchArch add-on is present
if Draft.getType(base.Base) == "ArchSketch":
sk = base.Base
else:
sk = Draft.makeSketch(base.Base,autoconstraints=True)
if sk:
try:
import ArchSketchObject
newSk=ArchSketchObject.makeArchSketch()
except:
if Draft.getType(base.Base) != "Sketcher::SketchObject":
newSk=FreeCAD.ActiveDocument.addObject("Sketcher::SketchObject","WallTrace")
else:
newSk=None
if newSk:
sk = Draft.makeSketch(base.Base,autoconstraints=True, addTo=newSk)
base.Base = sk
else:
sk = base.Base
for w in walls:
if w.Base:
if not w.Base.Shape.Faces:
@@ -421,7 +432,13 @@ class _CommandWall:
FreeCADGui.addModule("Draft")
if FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch").GetBool("WallSketches",True):
FreeCADGui.doCommand('base=FreeCAD.ActiveDocument.addObject("Sketcher::SketchObject","WallTrace")')
# Use ArchSketch if SketchArch add-on is present
try:
import ArchSketchObject
FreeCADGui.doCommand('import ArchSketchObject')
FreeCADGui.doCommand('base=ArchSketchObject.makeArchSketch()')
except:
FreeCADGui.doCommand('base=FreeCAD.ActiveDocument.addObject("Sketcher::SketchObject","WallTrace")')
FreeCADGui.doCommand('base.Placement = FreeCAD.DraftWorkingPlane.getPlacement()')
FreeCADGui.doCommand('base.addGeometry(trace)')
else: