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:
32
src/Mod/Arch/ArchSketchObject.py
Normal file
32
src/Mod/Arch/ArchSketchObject.py
Normal 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
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user