示例#1
0
 def selectDirection(self, doc_name, obj_name, sub, selectedPoint=None):
     # This is the direction selection
     if not self.selecting_direction:
         # Shouldn't be here
         pass
     if FreeCADGui.activeDocument().Document.Name != self.obj.Document.Name:
         return
     selected_object = FreeCAD.getDocument(doc_name).getObject(obj_name)
     # On double click on a vertex of a solid sub is None and obj is the solid
     print('Selection: ' + selected_object.Shape.ShapeType + '  ' +
           selected_object.Name + GEOMETRY_REFERENCE_SEP + sub + " @ " +
           str(selectedPoint))
     if hasattr(selected_object, "Shape") and sub:
         elt = selected_object.Shape.getElement(sub)
         if self.selecting_direction:
             if elt.ShapeType == 'Face':
                 if CfdTools.isPlanar(elt):
                     selection = (selected_object.Name, sub)
                     self.form.lineDirection.setText(
                         selection[0] + GEOMETRY_REFERENCE_SEP +
                         selection[1])  # TODO: Display label, not name
                     self._directionVector = elt.normalAt(0.5, 0.5)
                 else:
                     FreeCAD.Console.PrintMessage('Face must be planar\n')
             elif elt.ShapeType == 'Edge':
                 self.form.lineDirection.setText(selected_object.Name +
                                                 GEOMETRY_REFERENCE_SEP +
                                                 sub)
                 self._directionVector = self._getEdgeDirection(elt)
             else:
                 FreeCAD.Console.PrintMessage(
                     'Only planar face and straight edge are supported as direction\n'
                 )
             self.selecting_direction = False  # completed
             self.updateUi()
示例#2
0
 def lineDirectionChanged(self, value):
     # soecify direc by directly setting QLineEdit with obj and subobj name
     selection = value.split(GEOMETRY_REFERENCE_SEP)
     # See if entered face actually exists and is planar
     try:
         selected_object = self.obj.Document.getObject(selection[0])
         if hasattr(selected_object, "Shape"):
             elt = selected_object.Shape.getElement(selection[1])
             if elt.ShapeType == 'Face':
                 if CfdTools.isPlanar(elt):
                     self._directionVector = elt.normalAt(0.5, 0.5)
                 else:
                     FreeCAD.Console.PrintMessage(
                         value + " is not a valid, planar face\n")
             elif elt.ShapeType == 'Edge':
                 self._directionVector = self._getEdgeDirection(elt)
             else:
                 return
             self.updateUi()
     except SystemError:
         pass