[Draft] Move and Rotate documentation of recent changes
[Draft] Edit: small typo fix
This commit is contained in:
@@ -1596,11 +1596,13 @@ def move(objectslist,vector,copy=False):
|
||||
newgroups = {}
|
||||
objectslist = filterObjectsForModifiers(objectslist, copy)
|
||||
for obj in objectslist:
|
||||
vminusglobal = obj.getGlobalPlacement().inverse().Rotation.multVec(vector)
|
||||
realvector = obj.Placement.Rotation.multVec(vminusglobal)
|
||||
# real_vector have been introduced to take into account
|
||||
# the possibility that object is inside an App::Part
|
||||
v_minus_global = obj.getGlobalPlacement().inverse().Rotation.multVec(vector)
|
||||
real_vector = obj.Placement.Rotation.multVec(v_minus_global)
|
||||
if getType(obj) == "Point":
|
||||
v = Vector(obj.X,obj.Y,obj.Z)
|
||||
v = v.add(realvector)
|
||||
v = v.add(real_vector)
|
||||
if copy:
|
||||
newobj = makeCopy(obj)
|
||||
else:
|
||||
@@ -1614,7 +1616,7 @@ def move(objectslist,vector,copy=False):
|
||||
else:
|
||||
newobj = obj
|
||||
pla = newobj.Placement
|
||||
pla.move(realvector)
|
||||
pla.move(real_vector)
|
||||
elif getType(obj) == "Annotation":
|
||||
if copy:
|
||||
newobj = FreeCAD.ActiveDocument.addObject("App::Annotation",getRealName(obj.Name))
|
||||
@@ -1623,7 +1625,7 @@ def move(objectslist,vector,copy=False):
|
||||
formatObject(newobj,obj)
|
||||
else:
|
||||
newobj = obj
|
||||
newobj.Position = obj.Position.add(realvector)
|
||||
newobj.Position = obj.Position.add(real_vector)
|
||||
elif getType(obj) == "DraftText":
|
||||
if copy:
|
||||
newobj = FreeCAD.ActiveDocument.addObject("App::FeaturePython",getRealName(obj.Name))
|
||||
@@ -1637,7 +1639,7 @@ def move(objectslist,vector,copy=False):
|
||||
formatObject(newobj,obj)
|
||||
else:
|
||||
newobj = obj
|
||||
newobj.Placement.Base = obj.Placement.Base.add(realvector)
|
||||
newobj.Placement.Base = obj.Placement.Base.add(real_vector)
|
||||
elif getType(obj) == "Dimension":
|
||||
if copy:
|
||||
newobj = FreeCAD.ActiveDocument.addObject("App::FeaturePython",getRealName(obj.Name))
|
||||
@@ -1647,16 +1649,16 @@ def move(objectslist,vector,copy=False):
|
||||
formatObject(newobj,obj)
|
||||
else:
|
||||
newobj = obj
|
||||
newobj.Start = obj.Start.add(realvector)
|
||||
newobj.End = obj.End.add(realvector)
|
||||
newobj.Dimline = obj.Dimline.add(realvector)
|
||||
newobj.Start = obj.Start.add(real_vector)
|
||||
newobj.End = obj.End.add(real_vector)
|
||||
newobj.Dimline = obj.Dimline.add(real_vector)
|
||||
else:
|
||||
if copy and obj.isDerivedFrom("Mesh::Feature"):
|
||||
print("Mesh copy not supported at the moment") # TODO
|
||||
newobj = obj
|
||||
if "Placement" in obj.PropertiesList:
|
||||
pla = obj.Placement
|
||||
pla.move(realvector)
|
||||
pla.move(real_vector)
|
||||
newobjlist.append(newobj)
|
||||
if copy:
|
||||
for p in obj.InList:
|
||||
@@ -1785,15 +1787,17 @@ def rotate(objectslist,angle,center=Vector(0,0,0),axis=Vector(0,0,1),copy=False)
|
||||
newgroups = {}
|
||||
objectslist = filterObjectsForModifiers(objectslist, copy)
|
||||
for obj in objectslist:
|
||||
# real_center and real_axis are introduced to take into account
|
||||
# the possibility that object is inside an App::Part
|
||||
ci = obj.getGlobalPlacement().inverse().multVec(center)
|
||||
c = obj.Placement.multVec(ci)
|
||||
real_center = obj.Placement.multVec(ci)
|
||||
ai = obj.getGlobalPlacement().inverse().Rotation.multVec(axis)
|
||||
a = obj.Placement.Rotation.multVec(ai)
|
||||
real_axis = obj.Placement.Rotation.multVec(ai)
|
||||
if copy:
|
||||
newobj = makeCopy(obj)
|
||||
else:
|
||||
newobj = obj
|
||||
if (obj.isDerivedFrom("App::Annotation")):
|
||||
if obj.isDerivedFrom("App::Annotation"):
|
||||
if axis.normalize() == Vector(1,0,0):
|
||||
newobj.ViewObject.RotationAxis = "X"
|
||||
newobj.ViewObject.Rotation = angle
|
||||
@@ -1811,9 +1815,9 @@ def rotate(objectslist,angle,center=Vector(0,0,0),axis=Vector(0,0,1),copy=False)
|
||||
newobj.ViewObject.Rotation = -angle
|
||||
elif getType(obj) == "Point":
|
||||
v = Vector(obj.X,obj.Y,obj.Z)
|
||||
rv = v.sub(c)
|
||||
rv = DraftVecUtils.rotate(rv,math.radians(angle),a)
|
||||
v = c.add(rv)
|
||||
rv = v.sub(real_center)
|
||||
rv = DraftVecUtils.rotate(rv,math.radians(angle),real_axis)
|
||||
v = real_center.add(rv)
|
||||
newobj.X = v.x
|
||||
newobj.Y = v.y
|
||||
newobj.Z = v.z
|
||||
@@ -1821,12 +1825,12 @@ def rotate(objectslist,angle,center=Vector(0,0,0),axis=Vector(0,0,1),copy=False)
|
||||
#FreeCAD.Console.PrintMessage("placement rotation\n")
|
||||
shape = Part.Shape()
|
||||
shape.Placement = obj.Placement
|
||||
shape.rotate(DraftVecUtils.tup(c), DraftVecUtils.tup(a), angle)
|
||||
shape.rotate(DraftVecUtils.tup(real_center), DraftVecUtils.tup(real_axis), angle)
|
||||
newobj.Placement = shape.Placement
|
||||
elif hasattr(obj,'Shape') and (getType(obj) not in ["WorkingPlaneProxy","BuildingPart"]):
|
||||
#think it make more sense to try first to rotate placement and later to try with shape. no?
|
||||
shape = obj.Shape.copy()
|
||||
shape.rotate(DraftVecUtils.tup(c), DraftVecUtils.tup(a), angle)
|
||||
shape.rotate(DraftVecUtils.tup(real_center), DraftVecUtils.tup(real_axis), angle)
|
||||
newobj.Shape = shape
|
||||
if copy:
|
||||
formatObject(newobj,obj)
|
||||
@@ -1843,7 +1847,7 @@ def rotate(objectslist,angle,center=Vector(0,0,0),axis=Vector(0,0,1),copy=False)
|
||||
select(newobjlist)
|
||||
if len(newobjlist) == 1: return newobjlist[0]
|
||||
return newobjlist
|
||||
|
||||
|
||||
def scaleVectorFromCenter(vector, scale, center):
|
||||
return vector.sub(center).scale(scale.x, scale.y, scale.z).add(center)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user