Draft: Setting the WorkingPlane from a quad face now also takes its x and y directions
This commit is contained in:
parent
37d5012647
commit
8a24f0fe6f
|
@ -435,6 +435,7 @@ class _CommandStructure:
|
|||
else:
|
||||
FreeCADGui.doCommand('s = Arch.makeStructure(length='+str(self.Length)+',width='+str(self.Width)+',height='+str(self.Height)+')')
|
||||
FreeCADGui.doCommand('s.Placement.Base = '+DraftVecUtils.toString(point))
|
||||
FreeCADGui.doCommand('s.Placement.Rotation=FreeCAD.DraftWorkingPlane.getRotation().Rotation')
|
||||
FreeCAD.ActiveDocument.commitTransaction()
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
if self.continueCmd:
|
||||
|
|
|
@ -194,7 +194,8 @@ def insert(filename,docname,skip=[]):
|
|||
obj = baseobj
|
||||
if obj:
|
||||
sh = baseobj.Shape.ShapeType if hasattr(baseobj,"Shape") else "None"
|
||||
if DEBUG: print "creating object ",pid," : ",ptype, " with shape: ",sh
|
||||
sols = str(baseobj.Shape.Solids) if hasattr(baseobj,"Shape") else ""
|
||||
if DEBUG: print "creating object ",pid," : ",ptype, " with shape: ",sh," ",sols
|
||||
objects[pid] = obj
|
||||
|
||||
# subtractions
|
||||
|
|
|
@ -126,6 +126,26 @@ def isAligned(edge,axis="x"):
|
|||
if edge.StartPoint.z == edge.EndPoint.z:
|
||||
return True
|
||||
return False
|
||||
|
||||
def getQuad(face):
|
||||
"""getQuad(face): returns a list of 3 vectors (basepoint, Xdir, Ydir) if the face
|
||||
is a quad, or None if not."""
|
||||
if len(face.Edges) != 4:
|
||||
return None
|
||||
v1 = vec(face.Edges[0])
|
||||
v2 = vec(face.Edges[1])
|
||||
v3 = vec(face.Edges[2])
|
||||
v4 = vec(face.Edges[3])
|
||||
angles90 = [round(math.pi*0.5,precision()),round(math.pi*1.5,precision())]
|
||||
angles180 = [0,round(math.pi,precision()),round(math.pi*2,precision())]
|
||||
for ov in [v2,v3,v4]:
|
||||
if not (round(v1.getAngle(ov),precision()) in angles90+angles180):
|
||||
return None
|
||||
for ov in [v2,v3,v4]:
|
||||
if round(v1.getAngle(ov),precision()) in angles90:
|
||||
v1.normalize()
|
||||
ov.normalize()
|
||||
return [face.Edges[0].Vertexes[0].Point,v1,ov]
|
||||
|
||||
def areColinear(e1,e2):
|
||||
"""areColinear(e1,e2): returns True if both edges are colinear"""
|
||||
|
|
|
@ -385,7 +385,7 @@ class SelectPlane(DraftTool):
|
|||
elif arg == "currentView":
|
||||
d = self.view.getViewDirection().negative()
|
||||
FreeCADGui.doCommandGui("FreeCAD.DraftWorkingPlane.alignToPointAndAxis(FreeCAD.Vector(0,0,0), FreeCAD.Vector("+str(d.x)+","+str(d.y)+","+str(d.z)+"), "+str(self.offset)+")")
|
||||
self.display(viewDirection)
|
||||
self.display(d)
|
||||
self.finish()
|
||||
elif arg == "reset":
|
||||
FreeCADGui.doCommandGui("FreeCAD.DraftWorkingPlane.reset()")
|
||||
|
|
|
@ -224,8 +224,15 @@ class plane:
|
|||
def alignToFace(self, shape, offset=0):
|
||||
# Set face to the unique selected face, if found
|
||||
if shape.ShapeType == 'Face':
|
||||
#we should really use face.tangentAt to get u and v here, and implement alignToUVPoint
|
||||
self.alignToPointAndAxis(shape.Faces[0].CenterOfMass, shape.Faces[0].normalAt(0,0), offset)
|
||||
import DraftGeomUtils
|
||||
q = DraftGeomUtils.getQuad(shape)
|
||||
if q:
|
||||
self.u = q[1]
|
||||
self.v = q[2]
|
||||
if not DraftVecUtils.equals(self.u.cross(self.v),self.axis):
|
||||
self.u = q[2]
|
||||
self.v = q[1]
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
|
Loading…
Reference in New Issue
Block a user