Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Devel #273

Merged
merged 3 commits into from
May 1, 2019
Merged

Devel #273

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion InitGui.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
__title__ = 'A2plus assembly Workbench - InitGui file'
__author__ = 'kbwbe'

A2P_VERSION = 'V0.4.18'
A2P_VERSION = 'V0.4.19'



Expand Down Expand Up @@ -171,6 +171,7 @@ def Initialize(self):
'a2p_AxialConstraintCommand',
'a2p_AxisParallelConstraintCommand',
'a2p_AxisPlaneParallelCommand',
'a2p_AxisPlaneVerticalCommand',
'a2p_PlanesParallelConstraintCommand',
'a2p_PlaneCoincidentConstraintCommand',
'a2p_AngledPlanesConstraintCommand',
Expand Down
8 changes: 4 additions & 4 deletions a2p_Resources2.py

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions a2p_Resources3.py

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions a2p_constraintDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,10 +517,19 @@ def initUI(self):
QtCore.QObject.connect(self.axisPlaneParallelButton, QtCore.SIGNAL("clicked()"), self.onAxisPlaneParallelButton)
self.constraintButtons.append(self.axisPlaneParallelButton)
#-------------------------------------
self.axisPlaneVerticalButton = QtGui.QPushButton(self.panel2)
self.axisPlaneVerticalButton.setFixedSize(32,32)
self.axisPlaneVerticalButton.setIcon(QtGui.QIcon(':/icons/a2p_AxisPlaneVerticalConstraint.svg'))
self.axisPlaneVerticalButton.setToolTip(a2p_constraints.AxisPlaneVerticalConstraint.getToolTip())
self.axisPlaneVerticalButton.setText("")
QtCore.QObject.connect(self.axisPlaneVerticalButton, QtCore.SIGNAL("clicked()"), self.onAxisPlaneVerticalButton)
self.constraintButtons.append(self.axisPlaneVerticalButton)
#-------------------------------------
panel2_Layout.addWidget(self.circularEdgeButton)
panel2_Layout.addWidget(self.axialButton)
panel2_Layout.addWidget(self.axisParallelButton)
panel2_Layout.addWidget(self.axisPlaneParallelButton)
panel2_Layout.addWidget(self.axisPlaneVerticalButton)
panel2_Layout.addStretch(1)
self.panel2.setLayout(panel2_Layout)
#-------------------------------------
Expand Down Expand Up @@ -638,6 +647,8 @@ def parseSelections(self):
self.axialButton.setEnabled(True)
if a2p_constraints.AxisPlaneParallelConstraint.isValidSelection(selection):
self.axisPlaneParallelButton.setEnabled(True)
if a2p_constraints.AxisPlaneVerticalConstraint.isValidSelection(selection):
self.axisPlaneVerticalButton.setEnabled(True)
if a2p_constraints.CircularEdgeConstraint.isValidSelection(selection):
self.circularEdgeButton.setEnabled(True)
if a2p_constraints.PlanesParallelConstraint.isValidSelection(selection):
Expand Down Expand Up @@ -712,6 +723,11 @@ def onAxisPlaneParallelButton(self):
self.activeConstraint = a2p_constraints.AxisPlaneParallelConstraint(selection)
self.manageConstraint()

def onAxisPlaneVerticalButton(self):
selection = FreeCADGui.Selection.getSelectionEx()
self.activeConstraint = a2p_constraints.AxisPlaneVerticalConstraint(selection)
self.manageConstraint()

def onPlanesParallelButton(self):
selection = FreeCADGui.Selection.getSelectionEx()
self.activeConstraint = a2p_constraints.PlanesParallelConstraint(selection)
Expand Down
25 changes: 25 additions & 0 deletions a2p_constraintcommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,31 @@ def GetResources(self):

FreeCADGui.addCommand('a2p_AxisPlaneParallelCommand', a2p_AxisPlaneParallelCommand())
#==============================================================================
class a2p_AxisPlaneVerticalCommand:
def Activated(self):
selection = FreeCADGui.Selection.getSelectionEx()

c = a2p_constraints.AxisPlaneVerticalConstraint(selection)
cvp = a2p_constraintDialog.a2p_ConstraintValuePanel(
c.constraintObject,
'createConstraint'
)
FreeCADGui.Selection.clearSelection()

def IsActive(self):
return a2p_constraints.AxisPlaneVerticalConstraint.isValidSelection(
FreeCADGui.Selection.getSelectionEx()
)

def GetResources(self):
return {
'Pixmap' : ':/icons/a2p_AxisPlaneVerticalConstraint.svg',
'MenuText': 'Add axisPlaneVertical constraint',
'ToolTip': a2p_constraints.AxisPlaneVerticalConstraint.getToolTip()
}

FreeCADGui.addCommand('a2p_AxisPlaneVerticalCommand', a2p_AxisPlaneVerticalCommand())
#==============================================================================
class a2p_PlanesParallelConstraintCommand:
def Activated(self):
selection = FreeCADGui.Selection.getSelectionEx()
Expand Down
51 changes: 51 additions & 0 deletions a2p_constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,57 @@ def getToolTip():
to a selected plane. The parts are not
moved to be coincident.

Button gets active after
correct selection.
'''

@staticmethod
def isValidSelection(selection):
validSelection = False
if len(selection) == 2:
s1, s2 = selection
if s1.ObjectName != s2.ObjectName:
if (
(LinearEdgeSelected(s1) or cylindricalFaceSelected(s1)) and
planeSelected(s2)
):
validSelection = True
return validSelection

#==============================================================================
class AxisPlaneVerticalConstraint(BasicConstraint):
def __init__(self,selection):
BasicConstraint.__init__(self, selection)
self.typeInfo = 'axisPlaneVertical'
self.constraintBaseName = 'axisPlaneVertical'
self.iconPath = ':/icons/a2p_AxisPlaneVerticalConstraint.svg'
self.create(selection)

def calcInitialValues(self):
c = self.constraintObject
axis1 = getAxis(self.ob1, c.SubElement1)
plane2 = getObjectFaceFromName(self.ob2, c.SubElement2)
axis2 = a2plib.getPlaneNormal(plane2.Surface)

angle = math.degrees(axis1.getAngle(axis2))
if angle <= 90.0:
self.direction = "aligned"
else:
self.direction = "opposed"

@staticmethod
def getToolTip():
return \
'''
Creates an axisPlaneVertical constraint.

1) select a linear edge or cylinder axis
2) select a plane face on another part

This constraint adjusts an axis vertical
to a selected plane. The parts are not
moved to be coincident.

Button gets active after
correct selection.
'''
Expand Down
37 changes: 37 additions & 0 deletions a2p_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,26 @@ def Create(doc, constraint, solver, rigid1, rigid2):
normal2 = a2plib.getPlaneNormal(plane2.Surface)
dep2.refAxisEnd = dep2.refPoint.add(normal2)

elif c.Type == "axisPlaneVertical":
dep1 = DependencyAxisPlaneVertical(c, "pointAxis")
dep2 = DependencyAxisPlaneVertical(c, "pointNormal")

ob1 = doc.getObject(c.Object1)
ob2 = doc.getObject(c.Object2)
axis1 = getAxis(ob1, c.SubElement1)
plane2 = getObjectFaceFromName(ob2, c.SubElement2)
dep1.refPoint = getPos(ob1,c.SubElement1)
dep2.refPoint = plane2.Faces[0].BoundBox.Center

axis1Normalized = Base.Vector(axis1)
axis1Normalized.normalize()
dep1.refAxisEnd = dep1.refPoint.add(axis1Normalized)

normal2 = a2plib.getPlaneNormal(plane2.Surface)
if dep2.direction == "opposed":
normal2.multiply(-1.0)
dep2.refAxisEnd = dep2.refPoint.add(normal2)

elif c.Type == "CenterOfMass":
dep1 = DependencyCenterOfMass(c, "point")
dep2 = DependencyCenterOfMass(c, "point")
Expand Down Expand Up @@ -839,6 +859,23 @@ def calcDOF(self, _dofPos, _dofRot, _pointconstraints=[]):
tmpaxis.Direction.Length = 2.0
return _dofPos, AngleAlignment(tmpaxis,_dofRot)

class DependencyAxisPlaneVertical(Dependency):
def __init__(self, constraint, refType):
Dependency.__init__(self, constraint, refType, True)
self.isPointConstraint = False
self.useRefPointSpin = False

def getMovement(self):
if not self.Enabled: return None, None
return self.refPoint, Base.Vector(0,0,0)

def calcDOF(self, _dofPos, _dofRot, _pointconstraints=[]):
#AngleBetweenPlanesConstraint
# AngleAlignment() needs to know the axis normal to plane constrained (stored in dep as refpoint and refAxisEnd) and the dofrot array
tmpaxis = cleanAxis(create_Axis2Points(self.refPoint,self.refAxisEnd))
tmpaxis.Direction.Length = 2.0
return _dofPos, AngleAlignment(tmpaxis,_dofRot)

class DependencyCenterOfMass(Dependency):
def __init__(self, constraint, refType):
Dependency.__init__(self, constraint, refType, True)
Expand Down
4 changes: 4 additions & 0 deletions a2p_rigid.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,13 @@ def applySolution(self, doc, solver):
axis2 = self.savedPlacement.Rotation.Axis
angle = math.degrees(axis2.getAngle(axis1))

'''
if absPosMove >= solver.mySOLVER_POS_ACCURACY*1e-2 or angle >= solver.mySOLVER_SPIN_ACCURACY*1e-2:
ob1 = doc.getObject(self.objectName)
ob1.Placement = self.placement
'''
ob1 = doc.getObject(self.objectName)
ob1.Placement = self.placement

def getRigidCenter(self):
_currentRigid = FreeCAD.ActiveDocument.getObject(self.objectName)
Expand Down
Loading