Merge branch 'master' of ssh://free-cad.git.sourceforge.net/gitroot/free-cad/free-cad
This commit is contained in:
commit
ab2d4bb2b2
|
@ -256,18 +256,11 @@ def formatObject(target,origin=None):
|
||||||
if "ShapeColor" in obrep.PropertiesList: obrep.ShapeColor = fcol
|
if "ShapeColor" in obrep.PropertiesList: obrep.ShapeColor = fcol
|
||||||
else:
|
else:
|
||||||
matchrep = origin.ViewObject
|
matchrep = origin.ViewObject
|
||||||
if ("LineWidth" in obrep.PropertiesList) and \
|
for p in matchrep.PropertiesList:
|
||||||
("LineWidth" in matchrep.PropertiesList):
|
if not p in ["DisplayMode","BoundingBox","Proxy","RootNode"]:
|
||||||
obrep.LineWidth = matchrep.LineWidth
|
if p in obrep.PropertiesList:
|
||||||
if ("PointColor" in obrep.PropertiesList) and \
|
val = getattr(matchrep,p)
|
||||||
("PointColor" in matchrep.PropertiesList):
|
setattr(obrep,p,val)
|
||||||
obrep.PointColor = matchrep.PointColor
|
|
||||||
if ("LineColor" in obrep.PropertiesList) and \
|
|
||||||
("LineColor" in matchrep.PropertiesList):
|
|
||||||
obrep.LineColor = matchrep.LineColor
|
|
||||||
if ("ShapeColor" in obrep.PropertiesList) and \
|
|
||||||
("ShapeColor" in matchrep.PropertiesList):
|
|
||||||
obrep.ShapeColor = matchrep.ShapeColor
|
|
||||||
if matchrep.DisplayMode in obrep.listDisplayModes():
|
if matchrep.DisplayMode in obrep.listDisplayModes():
|
||||||
obrep.DisplayMode = matchrep.DisplayMode
|
obrep.DisplayMode = matchrep.DisplayMode
|
||||||
|
|
||||||
|
@ -516,48 +509,52 @@ def makeText(stringslist,point=Vector(0,0,0),screen=False):
|
||||||
select(obj)
|
select(obj)
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
def makeCopy(obj):
|
def makeCopy(obj,force=None,reparent=False):
|
||||||
'''makeCopy(object): returns an exact copy of an object'''
|
'''makeCopy(object): returns an exact copy of an object'''
|
||||||
if getType(obj) == "Rectangle":
|
if (getType(obj) == "Rectangle") or (force == "Rectangle"):
|
||||||
newobj = FreeCAD.ActiveDocument.addObject(obj.Type,getRealName(obj.Name))
|
newobj = FreeCAD.ActiveDocument.addObject(obj.Type,getRealName(obj.Name))
|
||||||
_Rectangle(newobj)
|
_Rectangle(newobj)
|
||||||
_ViewProviderRectangle(newobj.ViewObject)
|
_ViewProviderRectangle(newobj.ViewObject)
|
||||||
elif getType(obj) == "Wire":
|
elif (getType(obj) == "Dimension") or (force == "Dimension"):
|
||||||
|
newobj = FreeCAD.ActiveDocument.addObject(obj.Type,getRealName(obj.Name))
|
||||||
|
_Dimension(newobj)
|
||||||
|
_ViewProviderDimension(newobj.ViewObject)
|
||||||
|
elif (getType(obj) == "Wire") or (force == "Wire"):
|
||||||
newobj = FreeCAD.ActiveDocument.addObject(obj.Type,getRealName(obj.Name))
|
newobj = FreeCAD.ActiveDocument.addObject(obj.Type,getRealName(obj.Name))
|
||||||
_Wire(newobj)
|
_Wire(newobj)
|
||||||
_ViewProviderWire(newobj.ViewObject)
|
_ViewProviderWire(newobj.ViewObject)
|
||||||
elif getType(obj) == "Circle":
|
elif (getType(obj) == "Circle") or (force == "Circle"):
|
||||||
newobj = FreeCAD.ActiveDocument.addObject(obj.Type,getRealName(obj.Name))
|
newobj = FreeCAD.ActiveDocument.addObject(obj.Type,getRealName(obj.Name))
|
||||||
_Circle(newobj)
|
_Circle(newobj)
|
||||||
_ViewProviderCircle(newobj.ViewObject)
|
_ViewProviderDraft(newobj.ViewObject)
|
||||||
elif getType(obj) == "Polygon":
|
elif (getType(obj) == "Polygon") or (force == "Polygon"):
|
||||||
newobj = FreeCAD.ActiveDocument.addObject(obj.Type,getRealName(obj.Name))
|
newobj = FreeCAD.ActiveDocument.addObject(obj.Type,getRealName(obj.Name))
|
||||||
_Polygon(newobj)
|
_Polygon(newobj)
|
||||||
_ViewProviderPolygon(newobj.ViewObject)
|
_ViewProviderPolygon(newobj.ViewObject)
|
||||||
elif getType(obj) == "BSpline":
|
elif (getType(obj) == "BSpline") or (force == "BSpline"):
|
||||||
newobj = FreeCAD.ActiveDocument.addObject(obj.Type,getRealName(obj.Name))
|
newobj = FreeCAD.ActiveDocument.addObject(obj.Type,getRealName(obj.Name))
|
||||||
_BSpline(newobj)
|
_BSpline(newobj)
|
||||||
_ViewProviderBSpline(newobj.ViewObject)
|
_ViewProviderBSpline(newobj.ViewObject)
|
||||||
elif getType(obj) == "Block":
|
elif (getType(obj) == "Block") or (force == "BSpline"):
|
||||||
newobj = FreeCAD.ActiveDocument.addObject(obj.Type,getRealName(obj.Name))
|
newobj = FreeCAD.ActiveDocument.addObject(obj.Type,getRealName(obj.Name))
|
||||||
_Block(newobj)
|
_Block(newobj)
|
||||||
_ViewProviderDraftPart(newobj.ViewObject)
|
_ViewProviderDraftPart(newobj.ViewObject)
|
||||||
elif getType(obj) == "Structure":
|
elif (getType(obj) == "Structure") or (force == "Structure"):
|
||||||
import ArchStructure
|
import ArchStructure
|
||||||
newobj = FreeCAD.ActiveDocument.addObject(obj.Type,getRealName(obj.Name))
|
newobj = FreeCAD.ActiveDocument.addObject(obj.Type,getRealName(obj.Name))
|
||||||
ArchStructure._Structure(newobj)
|
ArchStructure._Structure(newobj)
|
||||||
ArchStructure._ViewProviderStructure(newobj.ViewObject)
|
ArchStructure._ViewProviderStructure(newobj.ViewObject)
|
||||||
elif getType(obj) == "Wall":
|
elif (getType(obj) == "Wall") or (force == "Wall"):
|
||||||
import ArchWall
|
import ArchWall
|
||||||
newobj = FreeCAD.ActiveDocument.addObject(obj.Type,getRealName(obj.Name))
|
newobj = FreeCAD.ActiveDocument.addObject(obj.Type,getRealName(obj.Name))
|
||||||
ArchWall._Wall(newobj)
|
ArchWall._Wall(newobj)
|
||||||
ArchWall._ViewProviderWall(newobj.ViewObject)
|
ArchWall._ViewProviderWall(newobj.ViewObject)
|
||||||
elif getType(obj) == "Window":
|
elif (getType(obj) == "Window") or (force == "Window"):
|
||||||
import ArchWindow
|
import ArchWindow
|
||||||
newobj = FreeCAD.ActiveDocument.addObject(obj.Type,getRealName(obj.Name))
|
newobj = FreeCAD.ActiveDocument.addObject(obj.Type,getRealName(obj.Name))
|
||||||
ArchWindow._Window(newobj)
|
ArchWindow._Window(newobj)
|
||||||
Archwindow._ViewProviderWindow(newobj.ViewObject)
|
Archwindow._ViewProviderWindow(newobj.ViewObject)
|
||||||
elif getType(obj) == "Cell":
|
elif (getType(obj) == "Cell") or (force == "Cell"):
|
||||||
import ArchCell
|
import ArchCell
|
||||||
newobj = FreeCAD.ActiveDocument.addObject(obj.Type,getRealName(obj.Name))
|
newobj = FreeCAD.ActiveDocument.addObject(obj.Type,getRealName(obj.Name))
|
||||||
ArchCell._Cell(newobj)
|
ArchCell._Cell(newobj)
|
||||||
|
@ -569,8 +566,19 @@ def makeCopy(obj):
|
||||||
print "Error: Object type cannot be copied"
|
print "Error: Object type cannot be copied"
|
||||||
return None
|
return None
|
||||||
for p in obj.PropertiesList:
|
for p in obj.PropertiesList:
|
||||||
if p in newobj.PropertiesList:
|
if not p in ["Proxy"]:
|
||||||
setattr(newobj,p,obj.getPropertyByName(p))
|
if p in newobj.PropertiesList:
|
||||||
|
setattr(newobj,p,obj.getPropertyByName(p))
|
||||||
|
if reparent:
|
||||||
|
parents = obj.InList
|
||||||
|
if parents:
|
||||||
|
for par in parents:
|
||||||
|
if par.Type == "App::DocumentObjectGroup":
|
||||||
|
par.addObject(newobj)
|
||||||
|
else:
|
||||||
|
for prop in par.PropertiesList:
|
||||||
|
if getattr(par,prop) == obj:
|
||||||
|
setattr(par,prop,newobj)
|
||||||
formatObject(newobj,obj)
|
formatObject(newobj,obj)
|
||||||
return newobj
|
return newobj
|
||||||
|
|
||||||
|
@ -685,7 +693,7 @@ def move(objectslist,vector,copy=False):
|
||||||
if copy:
|
if copy:
|
||||||
newobj = FreeCAD.ActiveDocument.addObject("App::FeaturePython",getRealName(obj.Name))
|
newobj = FreeCAD.ActiveDocument.addObject("App::FeaturePython",getRealName(obj.Name))
|
||||||
_Dimension(newobj)
|
_Dimension(newobj)
|
||||||
_DimensionViewProvider(newobj.ViewObject)
|
_ViewProviderDimension(newobj.ViewObject)
|
||||||
else:
|
else:
|
||||||
newobj = obj
|
newobj = obj
|
||||||
newobj.Start = obj.Start.add(vector)
|
newobj.Start = obj.Start.add(vector)
|
||||||
|
@ -1401,6 +1409,57 @@ def clone(obj,delta=None):
|
||||||
if delta:
|
if delta:
|
||||||
cl.Placement.move(delta)
|
cl.Placement.move(delta)
|
||||||
return cl
|
return cl
|
||||||
|
|
||||||
|
def heal(objlist=None,delete=True,reparent=True):
|
||||||
|
'''heal([objlist],[delete],[reparent]) - recreates Draft objects that are damaged,
|
||||||
|
for example if created from an earlier version. If delete is True,
|
||||||
|
the damaged objects are deleted (default). If ran without arguments, all the objects
|
||||||
|
in the document will be healed if they are damaged. If reparent is True (default),
|
||||||
|
new objects go at the very same place in the tree than their original.'''
|
||||||
|
|
||||||
|
if not objlist:
|
||||||
|
objlist = FreeCAD.ActiveDocument.Objects
|
||||||
|
print "Healing whole document..."
|
||||||
|
|
||||||
|
if not isinstance(objlist,list):
|
||||||
|
objlist = [objlist]
|
||||||
|
|
||||||
|
dellist = []
|
||||||
|
got = False
|
||||||
|
|
||||||
|
for obj in objlist:
|
||||||
|
dtype = getType(obj)
|
||||||
|
ftype = obj.Type
|
||||||
|
if ftype in ["Part::FeaturePython","App::FeaturePython"]:
|
||||||
|
if obj.ViewObject.Proxy == 1 and dtype in ["Unknown","Part"]:
|
||||||
|
got = True
|
||||||
|
dellist.append(obj.Name)
|
||||||
|
props = obj.PropertiesList
|
||||||
|
if ("Dimline" in props) and ("Start" in props):
|
||||||
|
print "Healing " + obj.Name + " of type Dimension"
|
||||||
|
nobj = makeCopy(obj,force="Dimension",reparent=reparent)
|
||||||
|
elif ("Height" in props) and ("Length" in props):
|
||||||
|
print "Healing " + obj.Name + " of type Rectangle"
|
||||||
|
nobj = makeCopy(obj,force="Rectangle",reparent=reparent)
|
||||||
|
elif ("Points" in props) and ("Closed" in props):
|
||||||
|
print "Healing " + obj.Name + " of type Wire"
|
||||||
|
nobj = makeCopy(obj,force="Wire",reparent=reparent)
|
||||||
|
elif ("Radius" in props) and ("FirstAngle" in props):
|
||||||
|
print "Healing " + obj.Name + " of type Circle"
|
||||||
|
nobj = makeCopy(obj,force="Circle",reparent=reparent)
|
||||||
|
else:
|
||||||
|
dellist.pop()
|
||||||
|
print "Object " + obj.Name + " is not healable"
|
||||||
|
|
||||||
|
if not got:
|
||||||
|
print "No object seems to need healing"
|
||||||
|
else:
|
||||||
|
print "Healed ",len(dellist)," objects"
|
||||||
|
|
||||||
|
if dellist and delete:
|
||||||
|
for n in dellist:
|
||||||
|
FreeCAD.ActiveDocument.removeObject(n)
|
||||||
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
# Python Features definitions
|
# Python Features definitions
|
||||||
|
@ -1539,10 +1598,13 @@ class _ViewProviderDimension:
|
||||||
if hasattr(obj.ViewObject,"DisplayMode"):
|
if hasattr(obj.ViewObject,"DisplayMode"):
|
||||||
if obj.ViewObject.DisplayMode == "3D":
|
if obj.ViewObject.DisplayMode == "3D":
|
||||||
offset = fcvec.neg(offset)
|
offset = fcvec.neg(offset)
|
||||||
if obj.ViewObject.TextPosition == Vector(0,0,0):
|
if hasattr(obj.ViewObject,"TextPosition"):
|
||||||
tbase = midpoint.add(offset)
|
if obj.ViewObject.TextPosition == Vector(0,0,0):
|
||||||
|
tbase = midpoint.add(offset)
|
||||||
|
else:
|
||||||
|
tbase = obj.ViewObject.TextPosition
|
||||||
else:
|
else:
|
||||||
tbase = obj.ViewObject.TextPosition
|
tbase = midpoint.add(offset)
|
||||||
rot = FreeCAD.Placement(fcvec.getPlaneRotation(u,v,norm)).Rotation.Q
|
rot = FreeCAD.Placement(fcvec.getPlaneRotation(u,v,norm)).Rotation.Q
|
||||||
return p1,p2,p3,p4,tbase,norm,rot
|
return p1,p2,p3,p4,tbase,norm,rot
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user