Python FreeCADGui.updateGui() Examples

The following are 17 code examples of FreeCADGui.updateGui(). 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 FreeCADGui , or try the search function .
Example #1
Source File: Animation.py    From Animation with GNU General Public License v2.0 6 votes vote down vote up
def step(self,now):
		sayd("Styler step!" + str(now))

		if now<=self.obj2.start or now>self.obj2.end:
			say("ausserhalb")
			pass
		else:
			gob=FreeCADGui.ActiveDocument.getObject(self.obj2.obj.Name)
			if not self.obj2.obj:
				errorDialog("kein Sketch zugeordnet")
				raise Exception(' self.obj2.obj nicht definiert')
			if self.obj2.transparency:

				gob.Transparency=90
				relativ=1.00/(self.obj2.end-self.obj2.start)
				gob.Transparency=  int(relativ* (self.obj2.transpaEnd -self.obj2.transpaStart)*(now-self.obj2.start)) + self.obj2.transpaStart
		if now==self.obj2.start+1 or now==self.obj2.end:
			if self.obj2.visibility:
				gob=FreeCADGui.ActiveDocument.getObject(self.obj2.obj.Name)
				gob.Visibility = not gob.Visibility
		FreeCADGui.updateGui() 
Example #2
Source File: Animation.py    From Animation with GNU General Public License v2.0 5 votes vote down vote up
def animbackward(self):
		FreeCADGui.ActiveDocument.ActiveView.setAnimationEnabled(False)
		for i in range(101):
			self.obj2.time=float(100-i)/100
			FreeCAD.ActiveDocument.recompute()
			FreeCADGui.updateGui() 
			time.sleep(0.02) 
Example #3
Source File: VertexTracker.py    From Animation with GNU General Public License v2.0 5 votes vote down vote up
def run(self,s):
		say(s.Label)
		print(s.Shape)
		say(s.Shape.Vertexes)
		i=0
		for v in s.Shape.Vertexes:
			i += 1
			if i > 5: break 
			say(["Point: ", v.Point])
			FreeCADGui.updateGui()
			self.addpoint(v.Point) 
Example #4
Source File: Animation.py    From Animation with GNU General Public License v2.0 5 votes vote down vote up
def finalize(self,wait=5):
			for obj in self.obj.targets:
				obj.toInitialPlacement()
				FreeCADGui.updateGui() 
			time.sleep(wait)
#-------------------------

# testdialig in comboview task fenster 
Example #5
Source File: Animation.py    From Animation with GNU General Public License v2.0 5 votes vote down vote up
def run(self,intervall=-1):
		sayd("run  intervall=" + str(intervall))
		FreeCADGui.ActiveDocument.ActiveView.setAnimationEnabled(False)
		
		if (intervall<0):
			intervall=self.obj2.intervall

		if hasattr(self,'obj2'):
			t=FreeCAD.ActiveDocument.getObject(self.obj2.Name)
		else:
			raise Exception("obj2 not found --> reinit the file!")

		for ob in t.OutList:
			say(ob.Label)
			ob.Proxy.initialize()
			ob.Proxy.execute(ob)

		firstRun=True
		bigloop=0

		#while firstRun or os.path.exists("/tmp/loop"):
		while firstRun or FreeCAD.ParamGet('User parameter:Plugins/animation').GetBool("loop"):
			say("manager infinite loop #################################")
			firstRun=False
			bigloop += 1 

			for nw in range(self.obj2.start):
				say("---- manager before" + str(nw))

			for nw in range(intervall+1):
				self.step(nw)
				FreeCAD.ActiveDocument.recompute()
				FreeCADGui.updateGui()
				time.sleep(self.obj2.sleeptime)

		FreeCADGui.Selection.clearSelection()
		FreeCADGui.Selection.addSelection(FreeCAD.ActiveDocument.getObject(self.obj2.Name)) 
Example #6
Source File: Animation.py    From Animation with GNU General Public License v2.0 5 votes vote down vote up
def step(self,nw):

		if self.obj2.start<=nw and   nw<=self.obj2.start + self.obj2.intervall:
			say("step  " + self.obj2.Label + "  " + str(nw))
			t=FreeCAD.ActiveDocument.getObject(self.obj2.Name)
			intervall=self.obj2.intervall
			if self.obj2.Label == self.obj2.Name:
				s= s=self.obj2.Label
			else:
				s=self.obj2.Label + ' ('+ self.obj2.Name +")"
			say(s +" !************************* manager run loop:" + str(nw-self.obj2.start) + "/" + str(intervall))
			
			self.obj2.step=nw
			#if os.path.exists("/tmp/stop"):
			if FreeCAD.ParamGet('User parameter:Plugins/animation').GetBool("stop"):
					say("notbremse gezogen")
					raise Exception("Notbremse Manager main loop")
			for ob in t.OutList:
				if 1: # fehler analysieren
					sayd("step fuer ")
					sayd(ob.Label)
					if ob.ViewObject.Visibility:
							ob.Proxy.step(nw)
				else:
					try:
						sayd(ob.Proxy)
						if ob.ViewObject.Visibility:
							ob.Proxy.step(nw)
					except:
						say("fehler step 2")
						raise Exception("step nicht ausfuerbar")
			FreeCAD.ActiveDocument.recompute()
			print("deaktivate updateGui()--------------------------------------------------!")
			#FreeCADGui.updateGui()
			time.sleep(self.obj2.sleeptime) 
Example #7
Source File: Animation.py    From Animation with GNU General Public License v2.0 5 votes vote down vote up
def step(self,now):
		App=FreeCAD
		say("step " +str(now))
		s=self.obj2.ext.Spine
		ss=s[0]
		kk=s[1]
		if now==self.obj2.start:
			kk=[]
			steps=20
			steps=self.obj2.duration
			l=ss.Shape.copy().discretize(steps)
			f=Part.makePolygon(l)
			f1=Part.show(f)
			ss=FreeCAD.ActiveDocument.Objects[-1]
		kk.append("Edge"+str(now+1-self.obj2.start))
		if now<self.obj2.start:
			kk=["Edge1"]
			self.obj2.ext.ViewObject.Visibility=False
		else: 
			self.obj2.ext.ViewObject.Visibility=True
		self.obj2.ext.Spine=(ss,kk)
		FreeCAD.ActiveDocument.recompute()
		FreeCADGui.updateGui() 

#----------------------------------------------------------------------------------------------------------
#  Movie Screen
#---------------------------------------------------------------------------------------------------------- 
Example #8
Source File: Animation.py    From Animation with GNU General Public License v2.0 5 votes vote down vote up
def step(self,now):
		say("Bounder step!" + str(now))
		if now<=self.obj2.start or now>self.obj2.end:
			pass
		else:
			gob=FreeCAD.ActiveDocument.getObject(self.obj2.obj.Name)
			pm=gob.Placement.Base
			x, y, z = pm.x, pm.y, pm.z

			if self.obj2.x:
				if self.obj2.xmin>x:
					x=self.obj2.xmin
					say("xmin")
				if self.obj2.xmax<x:
					x=self.obj2.xmax
					say("xmax")

			if self.obj2.y:
				if self.obj2.ymin>y:
					y=self.obj2.ymin
				if self.obj2.ymax<y:
					y=self.obj2.ymax

			if self.obj2.z:
				if self.obj2.zmin>z:
					z=self.obj2.zmin
				if self.obj2.zmax<z:
					z=self.obj2.zmax

			gob.Placement.Base=FreeCAD.Vector(x,y,z)
			pm=gob.Placement.Base
			FreeCADGui.updateGui() 
Example #9
Source File: kicad.py    From fcad_pcb with MIT License 5 votes vote down vote up
def updateGui():
    try:
        FreeCADGui.updateGui()
    except Exception:
        pass 
Example #10
Source File: Animation.py    From Animation with GNU General Public License v2.0 5 votes vote down vote up
def animforward(self):
		FreeCADGui.ActiveDocument.ActiveView.setAnimationEnabled(False)
		for i in range(101):
			self.obj2.time=float(i)/100
			FreeCAD.ActiveDocument.recompute()
			FreeCADGui.updateGui() 
			time.sleep(0.02) 
Example #11
Source File: AnimationLib.py    From FreeCAD_Assembly4 with GNU Lesser General Public License v2.1 5 votes vote down vote up
def sliderMoved(self):
        self.Run = False
        varName = self.varList.currentText()
        varValue = self.slider.value()
        setattr( self.Variables, varName, varValue )
        App.ActiveDocument.Model.recompute('True')
        Gui.updateGui()
        return 
Example #12
Source File: AnimationLib.py    From FreeCAD_Assembly4 with GNU Lesser General Public License v2.1 5 votes vote down vote up
def onRun(self):
        self.Run = True
        # the selected variable
        varName = self.varList.currentText()
        begin   = self.minValue.value()
        end     = self.maxValue.value()
        step    = self.stepValue.value()
        sleep   = self.sleepValue.value()
        # basic checks
        if varName:
            varValue = begin
            # if we go forwards ...
            if end>begin and step>0:
                while varValue <= end and self.Run:
                    setattr( self.Variables, varName, varValue )
                    self.slider.setValue(varValue)
                    App.ActiveDocument.Model.recompute('True')
                    Gui.updateGui()
                    varValue += step
                    time.sleep(sleep)
            # ... or backwards
            elif end<begin and step<0:
                while varValue >= end and self.Run:
                    setattr( self.Variables, varName, varValue )
                    self.slider.setValue(varValue)
                    App.ActiveDocument.Model.recompute('True')
                    Gui.updateGui()
                    varValue += step
                    time.sleep(sleep)
        return 
Example #13
Source File: kicad.py    From fcad_pcb with MIT License 5 votes vote down vote up
def warning(self,msg):
        if self._isEnabledFor(1):
            FreeCAD.Console.PrintWarning(msg+'\n')
            updateGui() 
Example #14
Source File: kicad.py    From fcad_pcb with MIT License 5 votes vote down vote up
def info(self,msg):
        if self._isEnabledFor(2):
            FreeCAD.Console.PrintMessage(msg+'\n')
            updateGui() 
Example #15
Source File: kicad.py    From fcad_pcb with MIT License 5 votes vote down vote up
def log(self,msg):
        if self._isEnabledFor(3):
            FreeCAD.Console.PrintLog(msg+'\n')
            updateGui() 
Example #16
Source File: kicad.py    From fcad_pcb with MIT License 5 votes vote down vote up
def trace(self,msg):
        if self._isEnabledFor(4):
            FreeCAD.Console.PrintLog(msg+'\n')
            updateGui() 
Example #17
Source File: Animation.py    From Animation with GNU General Public License v2.0 4 votes vote down vote up
def step(self,now):
		from pivy import coin
		camera = FreeCADGui.ActiveDocument.ActiveView.getCameraNode()
		if self.obj2.typeCamera=="Orthographic":
			FreeCADGui.activeDocument().activeView().setCameraType("Orthographic")
		else:
			FreeCADGui.activeDocument().activeView().setCameraType("Perspective")

		campos=Base.Vector( 100, 50, 30)
		campos=self.obj2.posCamera

		if self.obj2.modeCamera == 'Path' :
			pos=-self.obj2.indexCamera
			t=FreeCAD.animCamera[pos]
			campos=t.pop()

		say("camera pos" + str(campos))
		camera.position.setValue( campos) 

		if now==self.obj2.start:
			pass

		if self.obj2.zoom !=1:
			if self.obj2.zoom <=0:
				sayErr("Zoom darf nicht <= NULL seinn")
				errorDialog("Zoom darf nicht <= NULL seinn")
			SS=1/(self.obj2.zoom)-1
			start=float(self.obj2.start)
			end=float(self.obj2.start + self.obj2.duration)
			if now>start and now<=end:
				s1=0.00+(1+(now-start)/(end-start)*SS)
				s2=0.00+(1+(now-1-start)/(end-start)*SS)
				s=s1/s2
				camera.scaleHeight(s)
		
		if self.obj2.dirMode=='Object':
			target=self.obj2.dirTarget
			say(target.Placement.Base)
			pos3=target.Placement.Base
			pos3.sub(campos)
			camera.pointAt(coin.SbVec3f(pos3),coin.SbVec3f(0,0,1))

		FreeCAD.ActiveDocument.recompute()
		FreeCADGui.updateGui()