Arch: Added pref option to base new walls on Draft lines

This commit is contained in:
Yorik van Havre
2018-06-06 18:34:14 -03:00
parent 05bee3aa1f
commit 08910e71e4
3 changed files with 44 additions and 7 deletions

View File

@@ -291,14 +291,17 @@ class _CommandWall:
def addDefault(self,l):
FreeCADGui.doCommand('base=FreeCAD.ActiveDocument.addObject("Sketcher::SketchObject","WallTrace")')
FreeCADGui.doCommand('base.Placement = FreeCAD.DraftWorkingPlane.getPlacement()')
FreeCADGui.doCommand('base.addGeometry(trace)')
FreeCADGui.addModule("Draft")
if FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch").GetBool("WallSketches",True):
FreeCADGui.doCommand('base=FreeCAD.ActiveDocument.addObject("Sketcher::SketchObject","WallTrace")')
FreeCADGui.doCommand('base.Placement = FreeCAD.DraftWorkingPlane.getPlacement()')
FreeCADGui.doCommand('base.addGeometry(trace)')
else:
FreeCADGui.doCommand('base=Draft.makeLine(trace)')
FreeCADGui.doCommand('wall = Arch.makeWall(base,width='+str(self.Width)+',height='+str(self.Height)+',align="'+str(self.Align)+'")')
FreeCADGui.doCommand('wall.Normal = FreeCAD.DraftWorkingPlane.axis')
if self.MultiMat:
FreeCADGui.doCommand("wall.Material = FreeCAD.ActiveDocument."+self.MultiMat.Name)
FreeCADGui.addModule("Draft")
FreeCADGui.doCommand("Draft.autogroup(wall)")
def update(self,point,info):
@@ -714,6 +717,7 @@ class _Wall(ArchComponent.Component):
v.multiply(obj.Length.Value)
p2 = e.Vertexes[0].Point.add(v)
if Draft.getType(obj.Base) == "Wire":
#print "modifying p2"
obj.Base.End = p2
elif Draft.getType(obj.Base) == "Sketch":
obj.Base.movePoint(0,2,p2,0)

View File

@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>510</width>
<width>522</width>
<height>711</height>
</rect>
</property>
@@ -97,6 +97,22 @@
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="Gui::PrefCheckBox" name="checkBox">
<property name="text">
<string>Use sketches</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>WallSketches</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Arch</cstring>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
@@ -1023,6 +1039,11 @@
<extends>Gui::ColorButton</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefCheckBox</class>
<extends>QCheckBox</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefDoubleSpinBox</class>
<extends>QDoubleSpinBox</extends>

View File

@@ -912,8 +912,20 @@ def makePolygon(nfaces,radius=1,inscribed=True,placement=None,face=None,support=
FreeCAD.ActiveDocument.recompute()
return obj
def makeLine(p1,p2):
'''makeLine(p1,p2): Creates a line between p1 and p2.'''
def makeLine(p1,p2=None):
'''makeLine(p1,p2): Creates a line between p1 and p2.
makeLine(LineSegment): Creates a line from a Part.LineSegment
makeLine(Shape): Creates a line from first vertex to last vertex of the given shape'''
if not p2:
if hasattr(p1,"StartPoint") and hasattr(p1,"EndPoint"):
p2 = p1.EndPoint
p1 = p1.StartPoint
elif hasattr(p1,"Vertexes"):
p2 = p1.Vertexes[-1].Point
p1 = p1.Vertexes[0].Point
else:
FreeCAD.Console.PrintError("Unable to create a line from the given data\n")
return
obj = makeWire([p1,p2])
return obj