Python FreeCAD.ActiveDocument() Examples
The following are 30
code examples of FreeCAD.ActiveDocument().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
FreeCAD
, or try the search function
.
Example #1
Source File: HelicalSweepFP.py From CurvesWB with GNU Lesser General Public License v2.1 | 7 votes |
def make_profile_sketch(self): import Sketcher sk = FreeCAD.ActiveDocument.addObject('Sketcher::SketchObject','Profile') sk.Placement = FreeCAD.Placement(FreeCAD.Vector(0,0,0),FreeCAD.Rotation(0,0,0,1)) sk.MapMode = "Deactivated" sk.addGeometry(Part.LineSegment(FreeCAD.Vector(100.0,0.0,0),FreeCAD.Vector(127.0,12.0,0)),False) sk.addConstraint(Sketcher.Constraint('PointOnObject',0,1,-1)) sk.addGeometry(Part.ArcOfCircle(Part.Circle(FreeCAD.Vector(125.0,17.0,0),FreeCAD.Vector(0,0,1),5.8),-1.156090,1.050925),False) sk.addConstraint(Sketcher.Constraint('Tangent',0,2,1,1)) sk.addGeometry(Part.LineSegment(FreeCAD.Vector(128.0,22.0,0),FreeCAD.Vector(100.0,37.0,0)),False) sk.addConstraint(Sketcher.Constraint('Tangent',1,2,2,1)) sk.addConstraint(Sketcher.Constraint('Vertical',0,1,2,2)) sk.addConstraint(Sketcher.Constraint('DistanceY',0,1,2,2,37.5)) sk.setDatum(4,FreeCAD.Units.Quantity('35.000000 mm')) sk.renameConstraint(4, u'Lead') sk.setDriving(4,False) sk.addConstraint(Sketcher.Constraint('Equal',2,0)) FreeCAD.ActiveDocument.recompute() return sk
Example #2
Source File: IsoCurve2.py From CurvesWB with GNU Lesser General Public License v2.1 | 6 votes |
def run(): sel = Gui.Selection.getSelectionEx() try: if len(sel) != 1: raise Exception("Select one face only.") try: App.ActiveDocument.openTransaction("Macro IsoCurve") selfobj = makeIsoCurveFeature() so = sel[0].SubObjects[0] p = sel[0].PickedPoints[0] poe = so.distToShape(Part.Vertex(p)) par = poe[2][0][2] selfobj.Face = [sel[0].Object,sel[0].SubElementNames] selfobj.Parameter = par[0] selfobj.Proxy.execute(selfobj) finally: App.ActiveDocument.commitTransaction() except Exception as err: from PySide import QtGui mb = QtGui.QMessageBox() mb.setIcon(mb.Icon.Warning) mb.setText("{0}".format(err)) mb.setWindowTitle("Macro IsoCurve") mb.exec_()
Example #3
Source File: FC_interaction_example.py From CurvesWB with GNU Lesser General Public License v2.1 | 6 votes |
def __init__(self, points=[], fp = None): self.points = points self.curve = Part.BSplineCurve() self.fp = fp self.root_inserted = False #self.support = None # Not yet implemented if len(points) > 0: if isinstance(points[0],FreeCAD.Vector): self.points = [ConnectionMarker([p]) for p in points] elif isinstance(points[0],(tuple,list)): self.points = [MarkerOnEdge([p]) for p in points] else: FreeCAD.Console.PrintError("InterpolationPolygon : bad input") # Setup coin objects if not FreeCAD.ActiveDocument: appdoc = FreeCAD.newDocument("New") self.guidoc = FreeCADGui.ActiveDocument self.view = self.guidoc.ActiveView self.rm = self.view.getViewer().getSoRenderManager() self.sg = self.view.getSceneGraph() self.setup_InteractionSeparator() self.update_curve()
Example #4
Source File: pasteSVG.py From CurvesWB with GNU Lesser General Public License v2.1 | 6 votes |
def Activated(self): cb = QtGui.QApplication.clipboard() t=cb.text() if t[0:5] == '<?xml': h = importSVG.svgHandler() doc = FreeCAD.ActiveDocument if not doc: doc = FreeCAD.newDocument("SvgImport") h.doc = doc xml.sax.parseString(t,h) doc.recompute() FreeCADGui.SendMsgToActiveView("ViewFit") else: FreeCAD.Console.PrintError('Invalid clipboard content.\n') #def IsActive(self): #return(True)
Example #5
Source File: sublink_edit.py From CurvesWB with GNU Lesser General Public License v2.1 | 6 votes |
def set_link(self): #debug("%s.%s -> Set button pressed"%(self.obj.Label, self.link)) subs = list() sel = FreeCADGui.Selection.getSelectionEx() if sel == []: FreeCAD.Console.PrintError("Nothing selected !\n") for selobj in sel: if selobj.HasSubObjects: subs.append(("(FreeCAD.ActiveDocument.getObject('%s'),%s)"%(selobj.Object.Name, selobj.SubElementNames))) if self.obj.getTypeIdOfProperty(self.link) == 'App::PropertyLinkSub': if not len(subs) == 1: FreeCAD.Console.PrintError("This property accept only 1 subobject !\n") else: #FreeCADGui.doCommand("subobj = FreeCAD.ActiveDocument.getObject('%s')"%(subs[0][0].Name)) FreeCADGui.doCommand("FreeCAD.ActiveDocument.getObject('%s').%s = %s"%(self.obj.Name, self.link, subs[0])) elif self.obj.getTypeIdOfProperty(self.link) == 'App::PropertyLinkSubList': FreeCADGui.doCommand("FreeCAD.ActiveDocument.getObject('%s').%s = %s"%(self.obj.Name, self.link, self.concat(subs))) self.view_link()
Example #6
Source File: OrientedSketchFP.py From CurvesWB with GNU Lesser General Public License v2.1 | 5 votes |
def __setstate__(self, state): self.Object = FreeCAD.ActiveDocument.getObject(state["name"]) return None
Example #7
Source File: splitCurves.py From CurvesWB with GNU Lesser General Public License v2.1 | 5 votes |
def IsActive(self): if FreeCAD.ActiveDocument: f = FreeCADGui.Selection.Filter("SELECT Part::Feature SUBELEMENT Edge COUNT 1..1000") return f.match() else: return(False)
Example #8
Source File: CurveEdit.py From CurvesWB with GNU Lesser General Public License v2.1 | 5 votes |
def main(): doc = FreeCAD.ActiveDocument bs = Part.BSplineCurve() edge = Part.Edge(bs) curveEdit(edge)
Example #9
Source File: pipeshellFP.py From CurvesWB with GNU Lesser General Public License v2.1 | 5 votes |
def makePipeShellFeature(self,path,profs): if path and profs: psfp = FreeCAD.ActiveDocument.addObject("Part::FeaturePython","PipeShell") pipeShell(psfp) psfp.Spine = path psfp.Profiles = profs pipeShellVP(psfp.ViewObject) #psfp.ViewObject.LineWidth = 2.0 #psfp.ViewObject.LineColor = (0.5,0.8,0.3) psfp.Mode = "DiscreteTrihedron" FreeCAD.ActiveDocument.recompute()
Example #10
Source File: multiLoftFP.py From CurvesWB with GNU Lesser General Public License v2.1 | 5 votes |
def makeFeature(self, sel): fp = FreeCAD.ActiveDocument.addObject("Part::FeaturePython","MultiLoft") MultiLoftFP(fp) MultiLoftVP(fp.ViewObject) fp.Sources = sel for c in sel: if hasattr(c,"ViewObject"): c.ViewObject.Visibility = False FreeCAD.ActiveDocument.recompute()
Example #11
Source File: IsoCurve.py From CurvesWB with GNU Lesser General Public License v2.1 | 5 votes |
def run(): f = Gui.Selection.Filter("SELECT Part::Feature SUBELEMENT Face COUNT 1..1000") try: if not f.match(): raise Exception("Select at least one face.") try: App.ActiveDocument.openTransaction("Macro IsoCurve") r = f.result() for e in r: for s in e: for f in s.SubElementNames: #App.ActiveDocument.openTransaction("Macro IsoCurve") selfobj = makeIsoCurveFeature() #so = sel[0].SubObjects[0] #p = sel[0].PickedPoints[0] #poe = so.distToShape(Part.Vertex(p)) #par = poe[2][0][2] #selfobj.Face = [sel[0].Object,sel[0].SubElementNames] selfobj.Face = [s.Object,f] #selfobj.Parameter = par[0] selfobj.Proxy.execute(selfobj) finally: App.ActiveDocument.commitTransaction() except Exception as err: from PySide import QtGui mb = QtGui.QMessageBox() mb.setIcon(mb.Icon.Warning) mb.setText("{0}".format(err)) mb.setWindowTitle("Macro IsoCurve") mb.exec_()
Example #12
Source File: Outline_FP.py From CurvesWB with GNU Lesser General Public License v2.1 | 5 votes |
def makeFeature(self,sel): fp = FreeCAD.ActiveDocument.addObject("Part::FeaturePython","Outline Curve") OutlineFP(fp, sel) approximate_extension.ApproximateExtension(fp) fp.Active = False OutlineVP(fp.ViewObject) FreeCAD.ActiveDocument.recompute()
Example #13
Source File: OrientedSketchFP.py From CurvesWB with GNU Lesser General Public License v2.1 | 5 votes |
def IsActive(self): if FreeCAD.ActiveDocument: return True else: return False
Example #14
Source File: multiLoftFP.py From CurvesWB with GNU Lesser General Public License v2.1 | 5 votes |
def __setstate__(self,state): self.Object = FreeCAD.ActiveDocument.getObject(state["name"]) return None
Example #15
Source File: segmentSurfaceFP.py From CurvesWB with GNU Lesser General Public License v2.1 | 5 votes |
def __setstate__(self,state): self.Object = FreeCAD.ActiveDocument.getObject(state["name"]) return(None)
Example #16
Source File: segmentSurfaceFP.py From CurvesWB with GNU Lesser General Public License v2.1 | 5 votes |
def IsActive(self): if FreeCAD.ActiveDocument: return(True) else: return(False)
Example #17
Source File: segmentSurfaceFP.py From CurvesWB with GNU Lesser General Public License v2.1 | 5 votes |
def makeFeature(self, s): fp = FreeCAD.ActiveDocument.addObject("Part::FeaturePython","Segment_Surface") SegmentSurface(fp, (s.Object,s.SubElementNames[0])) SegmentSurfaceVP(fp.ViewObject) FreeCAD.ActiveDocument.recompute()
Example #18
Source File: splitCurves.py From CurvesWB with GNU Lesser General Public License v2.1 | 5 votes |
def __setstate__(self,state): self.Object = FreeCAD.ActiveDocument.getObject(state["name"]) return(None)
Example #19
Source File: Outline_FP.py From CurvesWB with GNU Lesser General Public License v2.1 | 5 votes |
def IsActive(self): if FreeCAD.ActiveDocument: return(True) else: return(False)
Example #20
Source File: comp_spring.py From CurvesWB with GNU Lesser General Public License v2.1 | 5 votes |
def __setstate__(self,state): self.Object = FreeCAD.ActiveDocument.getObject(state["name"]) return None
Example #21
Source File: Outline_FP.py From CurvesWB with GNU Lesser General Public License v2.1 | 5 votes |
def __setstate__(self,state): self.Object = FreeCAD.ActiveDocument.getObject(state["name"]) return(None)
Example #22
Source File: sublink_edit.py From CurvesWB with GNU Lesser General Public License v2.1 | 5 votes |
def IsActive(self): if FreeCAD.ActiveDocument: selection = FreeCADGui.Selection.getSelection() if len(selection) == 1: return True return False
Example #23
Source File: sublink_edit.py From CurvesWB with GNU Lesser General Public License v2.1 | 5 votes |
def view_link(self): debug("%s.%s = %s"%(self.obj.Label, self.link, self.obj.getPropertyByName(self.link))) #FreeCADGui.doCommand("print(FreeCAD.ActiveDocument.getObject('%s').%s)"%(self.obj.Name, self.link))
Example #24
Source File: sublink_edit.py From CurvesWB with GNU Lesser General Public License v2.1 | 5 votes |
def reject(self): print('reject and resetEdit') FreeCADGui.ActiveDocument.resetEdit() FreeCADGui.Control.closeDialog() return(True)
Example #25
Source File: sublink_edit.py From CurvesWB with GNU Lesser General Public License v2.1 | 5 votes |
def accept(self): print('accept and resetEdit') FreeCADGui.ActiveDocument.resetEdit() self.widget.close() self.obj.ViewObject.Visibility = self.initial_visibility FreeCAD.ActiveDocument.recompute() return(True)
Example #26
Source File: curveExtendFP.py From CurvesWB with GNU Lesser General Public License v2.1 | 5 votes |
def makeExtendFeature(self,source): if source is not []: for o in source: extCurve = FreeCAD.ActiveDocument.addObject("Part::FeaturePython","ExtendedCurve") extend(extCurve) extCurve.Edge = o extendVP(extCurve.ViewObject) extCurve.ViewObject.LineWidth = 2.0 extCurve.ViewObject.LineColor = (0.5,0.0,0.3) FreeCAD.ActiveDocument.recompute()
Example #27
Source File: curveExtendFP.py From CurvesWB with GNU Lesser General Public License v2.1 | 5 votes |
def __setstate__(self,state): self.Object = FreeCAD.ActiveDocument.getObject(state["name"]) return(None)
Example #28
Source File: mixed_curve.py From CurvesWB with GNU Lesser General Public License v2.1 | 5 votes |
def IsActive(self): if FreeCAD.ActiveDocument: sel = FreeCADGui.Selection.getSelection() if len(sel) == 2: return True return False
Example #29
Source File: mixed_curve.py From CurvesWB with GNU Lesser General Public License v2.1 | 5 votes |
def makeCPCFeature(self,o1,o2,d1,d2): cc = FreeCAD.ActiveDocument.addObject("Part::FeaturePython","Mixed curve") MixedCurveFP(cc, o1,o2,d1,d2) approximate_extension.ApproximateExtension(cc) cc.Active = False MixedCurveVP(cc.ViewObject) FreeCAD.ActiveDocument.recompute()
Example #30
Source File: mixed_curve.py From CurvesWB with GNU Lesser General Public License v2.1 | 5 votes |
def __setstate__(self,state): self.Object = FreeCAD.ActiveDocument.getObject(state["name"]) return None