0000866: Draft to sketch
This commit is contained in:
parent
179e89e03c
commit
e29de5dc91
|
@ -1548,12 +1548,12 @@ def makeShape2DView(baseobj,projectionVector=None,facenumbers=[]):
|
||||||
select(obj)
|
select(obj)
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
def makeSketch(objectslist,autoconstraints=False,addTo=None,name="Sketch"):
|
def makeSketch(objectslist,autoconstraints=False,addTo=None,delete=False,name="Sketch"):
|
||||||
'''makeSketch(objectslist,[autoconstraints],[addTo],[name]): makes a Sketch
|
'''makeSketch(objectslist,[autoconstraints],[addTo],[delete],[name]): makes a Sketch
|
||||||
objectslist with the given Draft objects. If autoconstraints is True,
|
objectslist with the given Draft objects. If autoconstraints is True,
|
||||||
constraints will be automatically added to wire nodes, rectangles
|
constraints will be automatically added to wire nodes, rectangles
|
||||||
and circles. If addTo is an existing sketch, geometry will be added to it instead of
|
and circles. If addTo is an existing sketch, geometry will be added to it instead of
|
||||||
creating a new one.'''
|
creating a new one. If delete is True, the original object will be deleted'''
|
||||||
import Part, DraftGeomUtils
|
import Part, DraftGeomUtils
|
||||||
from Sketcher import Constraint
|
from Sketcher import Constraint
|
||||||
|
|
||||||
|
@ -1620,6 +1620,10 @@ def makeSketch(objectslist,autoconstraints=False,addTo=None,name="Sketch"):
|
||||||
if not DraftGeomUtils.isPlanar(obj.Shape):
|
if not DraftGeomUtils.isPlanar(obj.Shape):
|
||||||
print "Error: The given object is not planar and cannot be converted into a sketch."
|
print "Error: The given object is not planar and cannot be converted into a sketch."
|
||||||
return None
|
return None
|
||||||
|
for e in obj.Shape.Edges:
|
||||||
|
if isinstance(e.Curve,Part.BSplineCurve):
|
||||||
|
print "Error: One of the selected object contains BSplines, unable to convert"
|
||||||
|
return None
|
||||||
if not addTo:
|
if not addTo:
|
||||||
nobj.Placement.Rotation = DraftGeomUtils.calculatePlacement(obj.Shape).Rotation
|
nobj.Placement.Rotation = DraftGeomUtils.calculatePlacement(obj.Shape).Rotation
|
||||||
edges = []
|
edges = []
|
||||||
|
@ -1628,7 +1632,8 @@ def makeSketch(objectslist,autoconstraints=False,addTo=None,name="Sketch"):
|
||||||
if g:
|
if g:
|
||||||
nobj.addGeometry(g)
|
nobj.addGeometry(g)
|
||||||
ok = True
|
ok = True
|
||||||
if ok:
|
formatObject(nobj,obj)
|
||||||
|
if ok and delete:
|
||||||
FreeCAD.ActiveDocument.removeObject(obj.Name)
|
FreeCAD.ActiveDocument.removeObject(obj.Name)
|
||||||
FreeCAD.ActiveDocument.recompute()
|
FreeCAD.ActiveDocument.recompute()
|
||||||
return nobj
|
return nobj
|
||||||
|
|
|
@ -381,7 +381,6 @@ def geom(edge,plac=FreeCAD.Placement()):
|
||||||
p= Part.ArcOfCircle(cu,a1,a2)
|
p= Part.ArcOfCircle(cu,a1,a2)
|
||||||
return p
|
return p
|
||||||
else:
|
else:
|
||||||
print edge.Curve
|
|
||||||
return edge.Curve
|
return edge.Curve
|
||||||
|
|
||||||
def mirror (point, edge):
|
def mirror (point, edge):
|
||||||
|
|
|
@ -370,7 +370,7 @@ class svgHandler(xml.sax.ContentHandler):
|
||||||
r = float(draftui.color.red()/255.0)
|
r = float(draftui.color.red()/255.0)
|
||||||
g = float(draftui.color.green()/255.0)
|
g = float(draftui.color.green()/255.0)
|
||||||
b = float(draftui.color.blue()/255.0)
|
b = float(draftui.color.blue()/255.0)
|
||||||
self.lw = float(draftui.widthButton.value())
|
self.lw = float(draftui.linewidth)
|
||||||
else:
|
else:
|
||||||
self.lw = float(params.GetInt("linewidth"))
|
self.lw = float(params.GetInt("linewidth"))
|
||||||
c = params.GetUnsigned("color")
|
c = params.GetUnsigned("color")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user