From 720d40a04e86183593862949eb655ac8b2b0fe3f Mon Sep 17 00:00:00 2001 From: paullee0 Date: Sun, 27 Oct 2019 12:05:00 +0800 Subject: [PATCH 1/5] [Arch] - To allow exportIFC.py to work properly on sketch, which use only 1st face / wire. Not fusing baseface in getExtrusionData(); fusing solids execute() Forum Discussion - Arch Wall - Based on Sketch Issues https://forum.freecadweb.org/viewtopic.php?f=39&t=31235&p=343444#p343444 --- src/Mod/Arch/ArchWall.py | 71 ++++++++++++++++++++++++++++------------ 1 file changed, 50 insertions(+), 21 deletions(-) diff --git a/src/Mod/Arch/ArchWall.py b/src/Mod/Arch/ArchWall.py index 04513aefac..1132e8458d 100644 --- a/src/Mod/Arch/ArchWall.py +++ b/src/Mod/Arch/ArchWall.py @@ -553,9 +553,13 @@ class _Wall(ArchComponent.Component): obj.addProperty("App::PropertyInteger","Face","Wall",QT_TRANSLATE_NOOP("App::Property","The face number of the base object used to build this wall")) if not "Offset" in lp: obj.addProperty("App::PropertyDistance","Offset","Wall",QT_TRANSLATE_NOOP("App::Property","The offset between this wall and its baseline (only for left and right alignments)")) - if not "Refine" in lp: - obj.addProperty("App::PropertyEnumeration","Refine","Wall",QT_TRANSLATE_NOOP("App::Property","Select whether or not and the method to remove splitter of the Wall. Currently Draft removeSplitter and Part removeSplitter available but may not work on complex sketch.")) - obj.Refine = ['No','DraftRemoveSplitter','PartRemoveSplitter'] + + # See getExtrusionData(), removeSplitters are no longer used + #if not "Refine" in lp: + # obj.addProperty("App::PropertyEnumeration","Refine","Wall",QT_TRANSLATE_NOOP("App::Property","Select whether or not and the method to remove splitter of the Wall. Currently Draft removeSplitter and Part removeSplitter available but may not work on complex sketch.")) + # obj.Refine = ['No','DraftRemoveSplitter','PartRemoveSplitter'] + # TODO - To implement in Arch Component ? + if not "MakeBlocks" in lp: obj.addProperty("App::PropertyBool","MakeBlocks","Blocks",QT_TRANSLATE_NOOP("App::Property","Enable this to make the wall generate blocks")) if not "BlockLength" in lp: @@ -600,8 +604,18 @@ class _Wall(ArchComponent.Component): for b in bplates: b.Placement = extdata[2].multiply(b.Placement) b = b.extrude(extv) - shps.append(b) - base = Part.makeCompound(shps) + + # See getExtrusionData() - not fusing baseplates there - fuse solids here + # Remarks - If solids are fused, but exportIFC.py use underlying baseplates w/o fuse, the result in ifc look slightly different from in FC. + #shps.append(b) + if shps: + shps = shps.fuse(b) #shps.fuse(b) + else: + shps=b + # TODO - To let user to select whether to fuse (slower) or to do a compound (faster) only ? + #base = Part.makeCompound(shps) + base = shps + else: bplates.Placement = extdata[2].multiply(bplates.Placement) base = bplates.extrude(extv) @@ -960,23 +974,38 @@ class _Wall(ArchComponent.Component): sh.fix(0.1,0,1) # fixes self-intersecting wires f = Part.Face(sh) if baseface: - if layers: - if layers[i] >= 0: - baseface.append(f) - else: - baseface = baseface.fuse(f) - if obj.Refine == 'DraftRemoveSplitter': - s = DraftGeomUtils.removeSplitter(baseface) - if s: - baseface = s - elif obj.Refine == 'PartRemoveSplitter': - baseface = baseface.removeSplitter() + + # To allow exportIFC.py to work properly on sketch, which use only 1st face / wire, do not fuse baseface here + # So for a sketch with multiple wires, each returns individual face (rather than fusing together) for exportIFC.py to work properly + # "ArchWall - Based on Sketch Issues" - https://forum.freecadweb.org/viewtopic.php?f=39&t=31235 + # + baseface.append(f) + # The above make Refine methods below (in else) useless, regardless removeSpitters yet to be improved for cases do not work well + + ''' Whether layers or not, all baseface.append(f) ''' + + #if layers: + # if layers[i] >= 0: + # baseface.append(f) + #else: + #baseface = baseface.fuse(f) + #if obj.Refine == 'DraftRemoveSplitter': + # s = DraftGeomUtils.removeSplitter(baseface) + # if s: + # baseface = s + #elif obj.Refine == 'PartRemoveSplitter': + # baseface = baseface.removeSplitter() else: - if layers: - if layers[i] >= 0: - baseface = [f] - else: - baseface = f + baseface = [f] + + ''' Whether layers or not, all baseface = [f] ''' + + #if layers: + # if layers[i] >= 0: + # baseface = [f] + #else: + #baseface = f + if baseface: base,placement = self.rebase(baseface) else: From 6dcf9ff8f0d356261edfc854957e1c4e773e4837 Mon Sep 17 00:00:00 2001 From: paullee0 Date: Sat, 9 Nov 2019 16:59:12 +0800 Subject: [PATCH 2/5] [Arch] Test : if Sketch, fuse solid; otherwise, do makeCompound --- src/Mod/Arch/ArchWall.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/Mod/Arch/ArchWall.py b/src/Mod/Arch/ArchWall.py index 1132e8458d..544630dc7a 100644 --- a/src/Mod/Arch/ArchWall.py +++ b/src/Mod/Arch/ArchWall.py @@ -601,21 +601,28 @@ class _Wall(ArchComponent.Component): extv = extdata[2].Rotation.multVec(extdata[1]) if isinstance(bplates,list): shps = [] + # Test : if base is Sketch, then fuse all solid; otherwise, makeCompound + sketchBaseToFuse = obj.Base.isDerivedFrom("Sketcher::SketchObject") for b in bplates: b.Placement = extdata[2].multiply(b.Placement) b = b.extrude(extv) # See getExtrusionData() - not fusing baseplates there - fuse solids here # Remarks - If solids are fused, but exportIFC.py use underlying baseplates w/o fuse, the result in ifc look slightly different from in FC. - #shps.append(b) - if shps: - shps = shps.fuse(b) #shps.fuse(b) - else: - shps=b - # TODO - To let user to select whether to fuse (slower) or to do a compound (faster) only ? - #base = Part.makeCompound(shps) - base = shps + if sketchBaseToFuse: + if shps: + shps = shps.fuse(b) #shps.fuse(b) + else: + shps=b + else: + shps.append(b) + # TODO - To let user to select whether to fuse (slower) or to do a compound (faster) only ? + + if sketchBaseToFuse: + base = shps + else: + base = Part.makeCompound(shps) else: bplates.Placement = extdata[2].multiply(bplates.Placement) base = bplates.extrude(extv) From c9522a6e63fc8c99696ddac0d70e32af3fc63de0 Mon Sep 17 00:00:00 2001 From: carlopav Date: Wed, 6 Nov 2019 21:03:38 +0100 Subject: [PATCH 3/5] [Draft] Edit: fix bug #4187 Fix bug #4187. When canceling a Dwire editing session with the Esc key or the "close" button Dwire editing breaks. --- src/Mod/Draft/DraftEdit.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Mod/Draft/DraftEdit.py b/src/Mod/Draft/DraftEdit.py index c267b11303..a5a9a1cf70 100644 --- a/src/Mod/Draft/DraftEdit.py +++ b/src/Mod/Draft/DraftEdit.py @@ -159,8 +159,9 @@ class Edit(): "terminates Edit Tool" self.unregister_selection_callback() self.unregister_editing_callbacks() - FreeCADGui.Snapper.setSelectMode(False) + self.editing = None self.finalizeGhost() + FreeCADGui.Snapper.setSelectMode(False) if self.obj and closed: if "Closed" in self.obj.PropertiesList: if not self.obj.Closed: @@ -245,11 +246,7 @@ class Edit(): key = event.getKey() #FreeCAD.Console.PrintMessage("pressed key : "+str(key)+"\n") if key == 65307: # ESC - if self.editing is None: self.finish() - else: - self.finalizeGhost() - self.setEditPoints(self.obj) - self.resetTrackers() + self.finish() if key == 97: # "a" self.finish() if key == 111: # "o" From 7adca7be3193ec8739e71e53476a83a8b8c9fd91 Mon Sep 17 00:00:00 2001 From: carlopav Date: Wed, 6 Nov 2019 21:38:55 +0100 Subject: [PATCH 4/5] [Draft] Edit: allow multiple objects editing Allow editing of multiple objects at once. --- src/Mod/Draft/DraftEdit.py | 14 +-- .../Resources/ui/preferences-draftsnap.ui | 88 +++++++++++++++---- 2 files changed, 76 insertions(+), 26 deletions(-) diff --git a/src/Mod/Draft/DraftEdit.py b/src/Mod/Draft/DraftEdit.py index a5a9a1cf70..d97a7f2111 100644 --- a/src/Mod/Draft/DraftEdit.py +++ b/src/Mod/Draft/DraftEdit.py @@ -79,8 +79,9 @@ class Edit(): self.originalNodes = None # settings - self.maxObjects = 1 - self.pick_radius = self.getPickRadius() + param = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft") + self.maxObjects = param.GetInt("DraftEditMaxObjects", 5) + self.pick_radius = param.GetInt("DraftEditPickRadius", 20) # preview self.ghost = None @@ -94,15 +95,6 @@ class Edit(): self.supportedPartObjs = ["Sketch", "Sketcher::SketchObject", \ "Part", "Part::Line", "Part::Box"] - def getPickRadius(self): - """return DraftEditPickRadius from user preferences""" - param = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft") - if param.GetInt("DraftEditPickRadius", 0) == 0: - param.SetInt("DraftEditPickRadius", 20) - return 20 - else: - return param.GetInt("DraftEditPickRadius") - def GetResources(self): return {'Pixmap' : 'Draft_Edit', 'MenuText': QtCore.QT_TRANSLATE_NOOP("Draft_Edit", "Edit"), diff --git a/src/Mod/Draft/Resources/ui/preferences-draftsnap.ui b/src/Mod/Draft/Resources/ui/preferences-draftsnap.ui index 42138a8e4f..2c8d9b56f5 100644 --- a/src/Mod/Draft/Resources/ui/preferences-draftsnap.ui +++ b/src/Mod/Draft/Resources/ui/preferences-draftsnap.ui @@ -6,8 +6,8 @@ 0 0 - 567 - 561 + 612 + 574 @@ -532,19 +532,77 @@ Edit - - - 9 - - - 9 - - - 9 - - - 9 - + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Sets the maximum number of objects Draft Edit can handle at the same time + + + Maximum number of contemporary edited objects + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + true + + + Mainlines will be drawn thicker. Specify here how many squares between mainlines. + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 1 + + + 25 + + + 5 + + + 10 + + + DraftEditMaxObjects + + + Mod/Draft + + + + + From c021ff70debb106b27d03ed1707f4b05fcf385a6 Mon Sep 17 00:00:00 2001 From: vocx-fc Date: Thu, 7 Nov 2019 20:12:48 -0600 Subject: [PATCH 5/5] Draft: rename SubelementModify to SubelementHighlight --- src/Mod/Draft/DraftTools.py | 22 ++++++++++--------- src/Mod/Draft/InitGui.py | 2 +- src/Mod/Draft/Resources/Draft.qrc | 2 +- ...dify.svg => Draft_SubelementHighlight.svg} | 2 +- 4 files changed, 15 insertions(+), 13 deletions(-) rename src/Mod/Draft/Resources/icons/{Draft_SubelementModify.svg => Draft_SubelementHighlight.svg} (99%) diff --git a/src/Mod/Draft/DraftTools.py b/src/Mod/Draft/DraftTools.py index 2eb8c61585..877addc6c8 100644 --- a/src/Mod/Draft/DraftTools.py +++ b/src/Mod/Draft/DraftTools.py @@ -2367,7 +2367,7 @@ class Move(Modifier): def Activated(self): self.name = translate("draft","Move", utf8_decode=True) Modifier.Activated(self, self.name, - is_subtool=isinstance(FreeCAD.activeDraftCommand, SubelementModify)) + is_subtool=isinstance(FreeCAD.activeDraftCommand, SubelementHighlight)) if not self.ui: return self.ghosts = [] @@ -4270,8 +4270,8 @@ class ToggleDisplayMode(): if "Flat Lines" in obj.ViewObject.listDisplayModes(): obj.ViewObject.DisplayMode = "Flat Lines" -class SubelementModify(Modifier): - """The Draft_SubelementModify FreeCAD command definition""" +class SubelementHighlight(Modifier): + """The Draft_SubelementHighlight FreeCAD command definition""" def __init__(self): self.is_running = False @@ -4279,18 +4279,20 @@ class SubelementModify(Modifier): self.original_view_settings = {} def GetResources(self): - return {'Pixmap' : 'Draft_SubelementModify', + return {'Pixmap' : 'Draft_SubelementHighlight', 'Accel' : "D, E", - 'MenuText': QtCore.QT_TRANSLATE_NOOP("Draft_SubelementModify", "Subelement modify"), - 'ToolTip': QtCore.QT_TRANSLATE_NOOP("Draft_SubelementModify", - "Allows editing the subelements " - "of the selected objects with other modification tools")} + 'MenuText': QtCore.QT_TRANSLATE_NOOP("Draft_SubelementHighlight", "Subelement highlight"), + 'ToolTip': QtCore.QT_TRANSLATE_NOOP("Draft_SubelementHighlight", + "Highlight the subelements " + "of the selected objects, " + "so that they can then be edited " + "with the move, rotate, and scale tools")} def Activated(self): if self.is_running: return self.finish() self.is_running = True - Modifier.Activated(self, "SubelementModify") + Modifier.Activated(self, "SubelementHighlight") self.get_selection() def proceed(self): @@ -5683,7 +5685,7 @@ FreeCADGui.addCommand('Draft_Downgrade',Downgrade()) FreeCADGui.addCommand('Draft_Trimex',Trimex()) FreeCADGui.addCommand('Draft_Scale',Scale()) FreeCADGui.addCommand('Draft_Drawing',Drawing()) -FreeCADGui.addCommand('Draft_SubelementModify', SubelementModify()) +FreeCADGui.addCommand('Draft_SubelementHighlight', SubelementHighlight()) FreeCADGui.addCommand('Draft_AddPoint',AddPoint()) FreeCADGui.addCommand('Draft_DelPoint',DelPoint()) FreeCADGui.addCommand('Draft_WireToBSpline',WireToBSpline()) diff --git a/src/Mod/Draft/InitGui.py b/src/Mod/Draft/InitGui.py index cd6931dc20..16cd32a230 100644 --- a/src/Mod/Draft/InitGui.py +++ b/src/Mod/Draft/InitGui.py @@ -82,7 +82,7 @@ class DraftWorkbench(Workbench): self.modList = ["Draft_Move", "Draft_Rotate", "Draft_Offset", "Draft_Trimex", "Draft_Join", "Draft_Split", "Draft_Upgrade", "Draft_Downgrade", "Draft_Scale", - "Draft_Edit", "Draft_SubelementModify", + "Draft_Edit", "Draft_SubelementHighlight", "Draft_WireToBSpline", "Draft_AddPoint", "Draft_DelPoint", "Draft_Shape2DView", "Draft_Draft2Sketch", "Draft_Array", "Draft_LinkArray", diff --git a/src/Mod/Draft/Resources/Draft.qrc b/src/Mod/Draft/Resources/Draft.qrc index a14e6b1ab8..0e9c089cb4 100644 --- a/src/Mod/Draft/Resources/Draft.qrc +++ b/src/Mod/Draft/Resources/Draft.qrc @@ -62,7 +62,7 @@ icons/Draft_Snap.svg icons/Draft_Split.svg icons/Draft_Stretch.svg - icons/Draft_SubelementModify.svg + icons/Draft_SubelementHighlight.svg icons/Draft_SwitchMode.svg icons/Draft_Text.svg icons/Draft_Trimex.svg diff --git a/src/Mod/Draft/Resources/icons/Draft_SubelementModify.svg b/src/Mod/Draft/Resources/icons/Draft_SubelementHighlight.svg similarity index 99% rename from src/Mod/Draft/Resources/icons/Draft_SubelementModify.svg rename to src/Mod/Draft/Resources/icons/Draft_SubelementHighlight.svg index edf5524e1b..047bb396e3 100644 --- a/src/Mod/Draft/Resources/icons/Draft_SubelementModify.svg +++ b/src/Mod/Draft/Resources/icons/Draft_SubelementHighlight.svg @@ -15,7 +15,7 @@ id="svg3612" version="1.1" inkscape:version="0.92.3 (2405546, 2018-03-11)" - sodipodi:docname="Draft_SubelementModify.svg"> + sodipodi:docname="Draft_SubelementHighlight.svg">