def Activated(self): newObj = App.ActiveDocument.addObject("Part::FeaturePython", "SegmentedSphere") SegmentedSphere(newObj) ViewProviderSphere(newObj.ViewObject, "SegmentedSphere") App.ActiveDocument.recompute() v = Gui.ActiveDocument.ActiveView faced.PartMover(v, newObj, deleteOnEscape=True)
def Activated(self): newObj = App.ActiveDocument.addObject("Part::FeaturePython", "Dodecahedron") Dodecahedron(newObj) ViewProviderBox(newObj.ViewObject, "Dodecahedron") App.ActiveDocument.recompute() v = Gui.ActiveDocument.ActiveView faced.PartMover(v, newObj, deleteOnEscape=True)
def Activated(self): newObj = App.ActiveDocument.addObject("Part::FeaturePython", "Capsule") Design456_CapsuleBase(newObj) ViewProviderCapsule(newObj.ViewObject, "Capsule") App.ActiveDocument.recompute() v = Gui.ActiveDocument.ActiveView faced.PartMover(v, newObj, deleteOnEscape=True)
def Activated(self): newObj = App.ActiveDocument.addObject("Part::FeaturePython", "NonuniformedBox") Design456_NonuniformedBoxBase(newObj) ViewProviderNoneUniformBox(newObj.ViewObject, "NonuniformedBox") App.ActiveDocument.recompute() v = Gui.ActiveDocument.ActiveView faced.PartMover(v, newObj, deleteOnEscape=True)
def Activated(self): try: newObj = App.ActiveDocument.addObject("Part::Box", "Box") newObj.Label = "Cube" App.ActiveDocument.recompute() v = Gui.ActiveDocument.ActiveView faced.PartMover(newObj, v, App.ActiveDocument.ActiveObject, deleteOnEscape=True) # Gui.SendMsgToActiveView("ViewFit") except Exception as err: App.Console.PrintError("'Part::Box' Failed. " "{err}\n".format(err=str(err)))
def Activated(self): try: newObj = App.ActiveDocument.addObject("Part::FeaturePython", "Octahedron") Octahedron(newObj) ViewProviderBox(newObj.ViewObject, "Octahedron") App.ActiveDocument.recompute() v = Gui.ActiveDocument.ActiveView faced.PartMover(v, newObj, deleteOnEscape=True) except Exception as err: App.Console.PrintError("'OctahedronCommand' Failed. " "{err}\n".format(err=str(err))) exc_type, exc_obj, exc_tb = sys.exc_info() fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] print(exc_type, fname, exc_tb.tb_lineno) return
def Activated(self): try: App.ActiveDocument.openTransaction( translate("Design456", "Part Box")) newObj = App.ActiveDocument.addObject("Part::Box", "Box") newObj.Label = "Cube" App.ActiveDocument.recompute() v = Gui.ActiveDocument.ActiveView faced.PartMover(v, newObj, deleteOnEscape=True) App.ActiveDocument.commitTransaction() #undo reg. except Exception as err: App.Console.PrintError("'Part::Box' Failed. " "{err}\n".format(err=str(err))) exc_type, exc_obj, exc_tb = sys.exc_info() fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] print(exc_type, fname, exc_tb.tb_lineno)
def Activated(self): try: # see https://www.freecadweb.org/wiki/Creating_a_FeaturePython_Box,_Part_II newObj = App.ActiveDocument.addObject("Part::FeaturePython", "Pyramid") Pyramid(newObj) ViewProviderBox(newObj.ViewObject, "Pyramid") App.ActiveDocument.recompute() v = Gui.ActiveDocument.ActiveView faced.PartMover(v, newObj, deleteOnEscape=True) except Exception as err: App.Console.PrintError("'PyramidCommand' Failed. " "{err}\n".format(err=str(err))) exc_type, exc_obj, exc_tb = sys.exc_info() fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] print(exc_type, fname, exc_tb.tb_lineno) return
def Activated(self): try: newObj = App.ActiveDocument.addObject("Part::Prism", "Prism") App.ActiveDocument.ActiveObject.Label = "Prism" App.ActiveDocument.recompute() v = Gui.ActiveDocument.ActiveView faced.PartMover(newObj, v, App.ActiveDocument.ActiveObject, deleteOnEscape=True) # Gui.SendMsgToActiveView("ViewFit") except Exception as err: App.Console.PrintError("'Part::Prism' Failed. " "{err}\n".format(err=str(err))) exc_type, exc_obj, exc_tb = sys.exc_info() fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] print(exc_type, fname, exc_tb.tb_lineno)
def Activated(self): try: neRaduis = QtGui.QInputDialog.getDouble(None, "Radius", "Radius:", 0, 1.0, 10000.0, 2)[0] if (neRaduis == 0): return #Nothing to do here. App.ActiveDocument.openTransaction( translate("Design456", "Part Hemisphere")) neObj = App.ActiveDocument.addObject("Part::Sphere", "tempHemisphere") neObj.Radius = neRaduis neObj.Placement = App.Placement( App.Vector(0.00, 0.00, 0.00), App.Rotation(App.Vector(1.00, 0.00, 0.00), 90.00)) neObj.Angle1 = '-90.00 deg' neObj.Angle2 = '90.00 deg' neObj.Angle3 = '180.00 deg' App.ActiveDocument.recompute() sh = neObj.Shape nsh = sh.defeaturing([ sh.Face2, ]) if not sh.isPartner(nsh): defeat = App.ActiveDocument.addObject('Part::Feature', 'Hemisphere').Shape = nsh App.ActiveDocument.removeObject(neObj.Name) else: App.Console.PrintError('Defeaturing failed\n') App.ActiveDocument.recompute() App.ActiveDocument.commitTransaction() #undo reg. newObj = App.ActiveDocument.ActiveObject v = Gui.ActiveDocument.ActiveView faced.PartMover(v, App.ActiveDocument.ActiveObject, deleteOnEscape=True) except Exception as err: App.Console.PrintError("'Part::Hemisphere' Failed. " "{err}\n".format(err=str(err))) exc_type, exc_obj, exc_tb = sys.exc_info() fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] print(exc_type, fname, exc_tb.tb_lineno)
def Activated(self): try: App.ActiveDocument.openTransaction( translate("Design456", "Part Pyramid")) obj = App.Placement() Faces = QtGui.QInputDialog.getInt(None, "Faces", "Faces:")[0] if (Faces == 0): return # Nothing to do here obj.Rotation.Q = (0.0, 0.0, 0, 1.0) obj.Base = App.Vector(0.0, 0.0, 0.0) newObj = _draft.makePolygon(Faces, radius=10, inscribed=True, placement=obj, face=True, support=None) _draft.autogroup(newObj) App.ActiveDocument.recompute() Gui.Selection.clearSelection() Gui.Selection.addSelection(App.ActiveDocument.Name, newObj.Name, 'Face1', 0, 0, 0) selectedEdge = Gui.Selection.getSelectionEx()[0].SubObjects[ 0] # select one element # loft plr = plDirection = App.Placement() yL = selectedEdge.CenterOfMass uv = selectedEdge.Surface.parameter(yL) nv = selectedEdge.normalAt(uv[0], uv[1]) direction = yL.sub(nv + yL) r = App.Rotation(App.Vector(0, 0, 1), direction) plDirection.Rotation.Q = r.Q plDirection.Base = yL plr = plDirection firstFace = newObj point = _draft.makePoint(0, 0.0, 10.0) newObj1 = App.ActiveDocument.addObject('Part::Loft', 'tempPyramid') App.ActiveDocument.ActiveObject.Sections = [ firstFace, point, ] App.ActiveDocument.ActiveObject.Solid = True newObj1 = App.ActiveDocument.ActiveObject App.ActiveDocument.recompute() # copy newOBJ = App.ActiveDocument.addObject( 'Part::Feature', 'Pyramid').Shape = _part.getShape(newObj1, '', needSubElement=False, refine=False) App.ActiveDocument.recompute() # Remove Old objects. I don't like to keep so many objects without any necessity. for obj in newObj1.Sections: App.ActiveDocument.removeObject(obj.Name) # Gui.SendMsgToActiveView("ViewFit") App.ActiveDocument.removeObject(newObj1.Name) # App.ActiveDocument.removeObject(point) App.ActiveDocument.commitTransaction() #undo reg. App.ActiveDocument.recompute() v = Gui.ActiveDocument.ActiveView faced.PartMover(v, App.ActiveDocument.ActiveObject, deleteOnEscape=True) except Exception as err: App.Console.PrintError("'Part::Pyramid' Failed. " "{err}\n".format(err=str(err))) exc_type, exc_obj, exc_tb = sys.exc_info() fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] print(exc_type, fname, exc_tb.tb_lineno)