Ejemplo n.º 1
0
    def start(self):
        say("start sensor")
        mw = QtGui.qApp

        ef = EventFilter(self.obj2)
        FreeCAD.keyfilter = ef
        mw.installEventFilter(ef)
Ejemplo n.º 2
0
	def start(self):
		say("start sensor")
		mw=QtGui.qApp
		
		ef=EventFilter(self.obj2)
		FreeCAD.keyfilter=ef
		mw.installEventFilter(ef)
Ejemplo n.º 3
0
    def stop(self):
        say("stop sensor")

        mw = QtGui.qApp
        ef = FreeCAD.keyfilter
        mw.removeEventFilter(ef)
        say("stopped")
Ejemplo n.º 4
0
	def stop(self):
		say("stop sensor")
		
		mw=QtGui.qApp
		ef=FreeCAD.keyfilter
		mw.removeEventFilter(ef)
		say("stopped")
Ejemplo n.º 5
0
	def main(self):

		anz=self.obj2.countSlices

		pb=createProgressBar("calculate Points")

		xc=self.obj2.dimU
		yc=self.obj2.dimV
		zc=anz

		# point index
		self.ptsl=np.arange(xc*yc*zc).reshape(zc,xc,yc)

		# anfangsgeschwindigkeiten der Teilchen
		self.pvs=np.zeros(xc*yc*3)
	#	self.pvs += 1
		self.pvs=self.pvs.reshape(xc,yc,3)
	# 	self.pvs[:,:] += [0,0,10]

		self.ptslix=np.zeros(xc*yc*zc*3).reshape(xc*yc*zc,3)


		bb=self.obj2.boundBox.Shape.BoundBox
		print "bounds ",bb
		self.xmax=bb.XMax
		self.ymax=bb.YMax
		self.zmax=bb.ZMax
		self.xmin=bb.XMin
		self.ymin=bb.YMin
		self.zmin=bb.ZMin

		createStartPtsV2(self)


#		self.obj2.forceMethod="myforce"
		reload(flowlib)
		force=eval("flowlib."+self.obj2.methodForce)
		self.force=force
		
		damper=eval("flowlib."+self.obj2.methodDamper)
		self.damper=damper

		ts=time.time()

		for i in range(anz-1): 
			createStepPtsV2(self,i)
			pb.pb.setValue(i*100/(anz-2))

		te=time.time()



		createFCOs(self,anz,1)
		say(("create points all ",i,"timee",round(te-ts,3)))
		showAll()
		Gui.SendMsgToActiveView("ViewFit")
		hideAll()

		pb.hide()
Ejemplo n.º 6
0
	def update(self):
		say("update ")
		import math
		time=self.obj2.time
		say(str(time))
		pl=self.path[time]
		self.obj2.target.Placement=pl
		self.obj2.Placement=pl
Ejemplo n.º 7
0
 def update(self):
     say("update ")
     import math
     time = self.obj2.time
     say(str(time))
     pl = self.path[time]
     self.obj2.target.Placement = pl
     self.obj2.Placement = pl
Ejemplo n.º 8
0
	def main(self):

		anz=self.obj2.countSlices

		pb=createProgressBar("calculate Points")

		xc=self.obj2.dimU
		yc=self.obj2.dimV
		zc=anz

		# point index
		self.ptsl=np.arange(xc*yc*zc).reshape(zc,xc,yc)

		# anfangsgeschwindigkeiten der Teilchen
		self.pvs=np.zeros(xc*yc*3)
	#	self.pvs += 1
		self.pvs=self.pvs.reshape(xc,yc,3)
	# 	self.pvs[:,:] += [0,0,10]

		self.ptslix=np.zeros(xc*yc*zc*3).reshape(xc*yc*zc,3)


		bb=self.obj2.boundBox.Shape.BoundBox
		self.xmax=bb.XMax
		self.ymax=bb.YMax
		self.zmax=bb.ZMax
		self.xmin=bb.XMin
		self.ymin=bb.YMin
		self.zmin=bb.ZMin

		createStartPtsV2(self)


#		self.obj2.forceMethod="myforce"
		reload(flowlib)
		force=eval("flowlib."+self.obj2.methodForce)
		self.force=force
		
		damper=eval("flowlib."+self.obj2.methodDamper)
		self.damper=damper

		ts=time.time()

		for i in range(anz-1): 
			createStepPtsV2(self,i)
			pb.pb.setValue(i*100/(anz-2))

		te=time.time()



		createFCOs(self,anz,1)
		say(("create points all ",i,"timee",round(te-ts,3)))
		showAll()
		Gui.SendMsgToActiveView("ViewFit")
		hideAll()

		pb.hide()
Ejemplo n.º 9
0
	def attach(self,vobj):
		self.emenu=[["start",self.start],["stop",self.stop]]
		self.cmenu=self.emenu
		say("attach " + str(vobj.Object.Label))
		self.Object = vobj.Object
		self.obj2=self.Object
		self.Object.Proxy.Lock=False
		self.Object.Proxy.Changed=False
		return
Ejemplo n.º 10
0
	def onBeforeChange(self,obj,prop):
		say("** on Before Changed " )
		FreeCAD.animationLock=False
#		say(obj)
		say(prop)
		FreeCAD.animation={}
		oldval=obj.getPropertyByName(prop)
		FreeCAD.animation['changed'] =[obj,prop,oldval]
		pass
Ejemplo n.º 11
0
 def attach(self, vobj):
     self.emenu = [["start", self.start], ["stop", self.stop]]
     self.cmenu = self.emenu
     say("attach " + str(vobj.Object.Label))
     self.Object = vobj.Object
     self.obj2 = self.Object
     self.Object.Proxy.Lock = False
     self.Object.Proxy.Changed = False
     return
Ejemplo n.º 12
0
 def onBeforeChange(self, obj, prop):
     say("** on Before Changed ")
     FreeCAD.animationLock = False
     #		say(obj)
     say(prop)
     FreeCAD.animation = {}
     oldval = obj.getPropertyByName(prop)
     FreeCAD.animation['changed'] = [obj, prop, oldval]
     pass
Ejemplo n.º 13
0
	def attach(self,vobj):
		self.emenu=[["Show Path",self.showpath]]
		self.cmenu=[]
		say("attach " + str(vobj.Object.Label))
		self.Object = vobj.Object
		self.obj2=self.Object
		self.Object.Proxy.Lock=False
		self.Object.Proxy.Changed=False
		return
Ejemplo n.º 14
0
	def attach(self,vobj):
		say("attach " + str(vobj.Object.Label))
		self.emenu=[["Reload Track",self.loadtrack],["Show Track",self.showtrack]]
		self.cmenu=[]
		self.Object = vobj.Object
		self.obj2=self.Object
		self.Object.Proxy.Lock=False
		self.Object.Proxy.Changed=False
		return
Ejemplo n.º 15
0
	def attach(self,vobj):
		self.emenu=[["Show Path Data",self.Object.Proxy.show],["Generate Path",self.Object.Proxy.gen]]
		self.cmenu=self.emenu
		say("attach " + str(vobj.Object.Label))
		self.Object = vobj.Object
		self.obj2=self.Object
		self.Object.Proxy.Lock=False
		self.Object.Proxy.Changed=False
		return
Ejemplo n.º 16
0
    def step(self, now):
        say("Kardan step!" + str(now))
        FreeCAD.R = self

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

            # alpha=60
            alpha = self.obj2.angleZenit
            phi = 1

            # testfall
            phi = 10

            # achse 1
            fa1 = self.obj2.objAxis1
            p0 = fa1.Placement
            phi0 = p0.Rotation.Angle / pi * 180
            # say("phi0 Basis " + str(phi0))
            p1 = FreeCAD.Placement(App.Vector(0, 0, 0),
                                   App.Rotation(App.Vector(0, 0, 1), phi))
            r1 = p1.multiply(p0)
            fa1.Placement = r1

            phi20 = arctan(
                tan(phi0 * pi / 180) * cos(alpha * pi / 180)) * 180 / pi
            phi21 = arctan(
                tan((phi0 + phi) * pi / 180) *
                cos(alpha * pi / 180)) * 180 / pi
            say("phi20 " + str(phi20))
            say("phi21 " + str(phi21))

            # achse 2
            timepos = now - self.obj2.start
            if 90 / phi - 1 <= timepos and timepos < 270 / phi - 1:
                phi21 = 180 + phi21
                say("*************** ! phi21 =" + str(phi21) + " now:" +
                    str(now))

            fa2 = self.obj2.objAxis2
            p1 = FreeCAD.Placement(App.Vector(0, 0, 0),
                                   App.Rotation(App.Vector(0, 0, 1), phi21))
            p2 = FreeCAD.Placement(App.Vector(0, 0, 0),
                                   App.Rotation(App.Vector(0, 1, 0), alpha))
            r3 = p2.multiply(p1)
            fa2.Placement = r3

            # kreuz
            f = self.obj2.objCross
            rotcross(f, alpha, phi0 + phi)
            FreeCAD.activeDocument().recompute()
Ejemplo n.º 17
0
	def showpath(self):
		''' path as Part.polygon '''
		FreeCAD.s=self
		points=self.Object.Proxy.path
		for p in self.Object.Proxy.path:
			say(str(p))
		pp=Part.makePolygon(points)
		Part.show(pp)
		FreeCAD.ActiveDocument.recompute()
		return FreeCAD.activeDocument().ActiveObject
Ejemplo n.º 18
0
 def attach(self, vobj):
     self.emenu = [["Show Path Data", self.Object.Proxy.show],
                   ["Generate Path", self.Object.Proxy.gen]]
     self.cmenu = self.emenu
     say("attach " + str(vobj.Object.Label))
     self.Object = vobj.Object
     self.obj2 = self.Object
     self.Object.Proxy.Lock = False
     self.Object.Proxy.Changed = False
     return
Ejemplo n.º 19
0
def createFCOs(self,anz,step=1):
	pb=createProgressBar("create FreeCAD objects")
	ts=time.time()
	for i in range(anz-1):
		if i%step == 0: 
			createStepFC(self,i)
			pb.pb.setValue(i*100/(anz-2))
			Gui.updateGui()
	te=time.time()
	say(("createFCOs ",round(te-ts,3)))
Ejemplo n.º 20
0
def createFCOs(self,anz,step=1):
	pb=createProgressBar("create FreeCAD objects")
	ts=time.time()
	for i in range(anz-1):
		if i%step == 0: 
			createStepFC(self,i)
			pb.pb.setValue(i*100/(anz-2))
			Gui.updateGui()
	te=time.time()
	say(("createFCOs ",round(te-ts,3)))
Ejemplo n.º 21
0
 def attach(self, vobj):
     say("attach " + str(vobj.Object.Label))
     self.emenu = [["Reload Track", self.loadtrack],
                   ["Show Track", self.showtrack]]
     self.cmenu = []
     self.Object = vobj.Object
     self.obj2 = self.Object
     self.Object.Proxy.Lock = False
     self.Object.Proxy.Changed = False
     return
Ejemplo n.º 22
0
	def dialer(self):
		''' shows the position at the dialer time'''
		self.obj2.time=float(self.widget.dial.value())/100
		say("dialer self time:" + str(self.obj2.time))
		try:
			say(self.obj2.Proxy.path[round(self.obj2.time,2)])
			self.obj2.target.Placement=self.obj2.Proxy.path[round(self.obj2.time,2)]
		except:
			pass
		FreeCAD.ActiveDocument.recompute()
Ejemplo n.º 23
0
 def dialer(self):
     ''' shows the position at the dialer time'''
     self.obj2.time = float(self.widget.dial.value()) / 100
     say("dialer self time:" + str(self.obj2.time))
     try:
         say(self.obj2.Proxy.path[round(self.obj2.time, 2)])
         self.obj2.target.Placement = self.obj2.Proxy.path[round(
             self.obj2.time, 2)]
     except:
         pass
     FreeCAD.ActiveDocument.recompute()
Ejemplo n.º 24
0
 def attach(self, vobj):
     say("VO attach " + str(vobj.Object.Label))
     vobj.Proxy = self
     self.Object = vobj.Object
     self.obj2 = self.Object
     self.Object.Proxy.Lock = False
     self.Object.Proxy.Changed = False
     icon = '/icons/controlpanel.png'
     self.iconpath = __dir__ + icon
     self.vers = __vers__
     return
Ejemplo n.º 25
0
	def attach(self,vobj):
		say("VO attach " + str(vobj.Object.Label))
		vobj.Proxy = self
		self.Object = vobj.Object
		self.obj2=self.Object
		self.Object.Proxy.Lock=False
		self.Object.Proxy.Changed=False
		icon='/icons/controlpanel.png'
		self.iconpath = __dir__ + icon
		self.vers=__vers__
		return
Ejemplo n.º 26
0
 def attach(self, vobj):
     self.emenu = []
     self.cmenu = []
     say("attach " + str(vobj.Object.Label))
     self.Object = vobj.Object
     self.obj2 = self.Object
     self.Object.Proxy.Lock = False
     self.Object.Proxy.Changed = False
     icon = '/icons/combiner.png'
     self.iconpath = __dir__ + icon
     self.vers = __vers__
     return
Ejemplo n.º 27
0
	def update(self):
		say("update ")
		import math
		time=self.obj2.time/100
		say(str(time))
		if self.obj2.mode=='cartesian':
			pl=FreeCAD.Vector((time*self.xmax)+self.xmin,self.obj2.a*self.fx(time)+self.obj2.b)
		if self.obj2.mode=='polar':
			# pl=FreeCAD.Vector((time*self.xmax)+self.xmin,self.fx(time))
			pl=FreeCAD.Vector(np.cos(np.pi*time*2),np.sin(np.pi*time*2),0)*(self.obj2.a*self.fx(time)+self.obj2.b)
		if self.obj2.target != None:	
			self.obj2.target.Placement.Base=pl
			self.obj2.target.purgeTouched()
Ejemplo n.º 28
0
	def update(self):
		time=self.obj2.time
		try:
			say("update time=" + str(time) + ", "+ self.obj2.Label)
		except:
			say("update (ohne Label)")
		objs=pclgroup().OutList
		for u in objs: 
			u.ViewObject.hide()
			u.ViewObject.ShapeColor=(1.0,0.0,0.0)
		i=int(round(time*(len(objs)-1)))
		try:objs[i].ViewObject.show()
		except: pass
Ejemplo n.º 29
0
    def execute(self, obj):
        # 		obj.end=obj.start+obj.duration
        obj.setEditorMode("end", 1)  #ro
        # obj.setEditorMode("obj", 1) #ro
        obj.setEditorMode("color", 2)  #hidden
        say("execute _Gearing")
        if hasattr(self, 'ignore'):
            if self.ignore:
                say("ignore")
                return

        # wenn noch keine zuordnung erfolgt ist
        App = FreeCAD
Ejemplo n.º 30
0
	def execute(self,obj):
# 		obj.end=obj.start+obj.duration
		obj.setEditorMode("end", 1) #ro
		# obj.setEditorMode("obj", 1) #ro
		obj.setEditorMode("color", 2) #hidden
		say("execute _Gearing")
		if hasattr(self,'ignore'):
			if self.ignore:
				say("ignore")
				return
		
		
		# wenn noch keine zuordnung erfolgt ist
		App=FreeCAD
Ejemplo n.º 31
0
	def step(self,now):
		say("Kardan step!" + str(now))
		FreeCAD.R=self
		
		if now<self.obj2.start or now>=self.obj2.end:
			say("ausserhalb")
			pass
		else:
			if not self.obj2.obj:
				errorDialog("kein Sketch zugeordnet")
				raise Exception(' self.obj2.obj nicht definiert')
			
			# alpha=60
			alpha=self.obj2.angleZenit
			phi=1
			
			# testfall
			phi=10

			# achse 1
			fa1=self.obj2.objAxis1
			p0=fa1.Placement
			phi0=p0.Rotation.Angle/pi*180
			# say("phi0 Basis " + str(phi0))
			p1=FreeCAD.Placement(App.Vector(0,0,0),App.Rotation(App.Vector(0,0,1),phi))
			r1=p1.multiply(p0)
			fa1.Placement=r1

			
			phi20=arctan(tan(phi0*pi/180)*cos(alpha*pi/180))*180/pi
			phi21=arctan(tan((phi0+phi)*pi/180)*cos(alpha*pi/180))*180/pi
			say("phi20 "+str(phi20))
			say("phi21 "+str(phi21))
			
			# achse 2
			timepos=now-self.obj2.start
			if 90/phi-1<=timepos and timepos<270/phi-1: 
				phi21=180+phi21
				say("*************** ! phi21 ="+str(phi21) + " now:" + str(now))

			fa2=self.obj2.objAxis2
			p1=FreeCAD.Placement(App.Vector(0,0,0),App.Rotation(App.Vector(0,0,1),phi21))
			p2=FreeCAD.Placement(App.Vector(0,0,0),App.Rotation(App.Vector(0,1,0),alpha))
			r3=p2.multiply(p1)
			fa2.Placement=r3

			# kreuz
			f=self.obj2.objCross
			rotcross(f,alpha,phi0+phi)
			FreeCAD.activeDocument().recompute()
Ejemplo n.º 32
0
    def execute(self, obj):

        if self.Changed:
            say("self changed")
            self.Changed = False
            return
        if not self.Lock:
            self.obj2 = obj
            self.Lock = True
            try:
                self.update()
            except:
                sayexc('update')
            self.Lock = False
Ejemplo n.º 33
0
	def execute(self,obj):

		if self.Changed:
			say("self changed")
			self.Changed=False
			return
		if not self.Lock:
			self.obj2=obj
			self.Lock=True
			try:
				self.update()
			except:
				sayexc('update')
			self.Lock=False
Ejemplo n.º 34
0
	def update(self):
		time=self.obj2.time
		try:
			say("update time=" + str(time) + ", "+ self.obj2.Label)
		except:
			say("update (ohne Label)")
		objs=pclgroup().OutList
		for u in objs: 
			u.ViewObject.hide()
			u.ViewObject.ShapeColor=(1.0,0.0,0.0)
		i=int(round(time*(len(objs)-1)))
		print i
		try:objs[i].ViewObject.show()
		except: pass
Ejemplo n.º 35
0
	def step(self,now):
		if now==0:
			sufi=''
		else:
			sufi=  "%03d" % (now) 
		if now > 0:
			try:
				ob=self.last
				ob.ViewObject.Visibility=False
			except:
				pass
			ob=FreeCAD.activeDocument().getObject(self.obj2.seqname + sufi)
			say(ob.Name)
			ob.ViewObject.Visibility=True
			self.last=ob
Ejemplo n.º 36
0
 def step(self, now):
     if now == 0:
         sufi = ''
     else:
         sufi = "%03d" % (now)
     if now > 0:
         try:
             ob = self.last
             ob.ViewObject.Visibility = False
         except:
             pass
         ob = FreeCAD.activeDocument().getObject(self.obj2.seqname + sufi)
         say(ob.Name)
         ob.ViewObject.Visibility = True
         self.last = ob
Ejemplo n.º 37
0
	def attach(self,vobj):
		# items for edit dialog  and contextmenue
		self.emenu=[['A',self.funA],['B',self.funB]]
		self.cmenu=[['AC',self.funA],['BC',self.funB]]
		
		say("VO attach " + str(vobj.Object.Label))
		vobj.Proxy = self
		self.Object = vobj.Object
		self.obj2=self.Object
		self.Object.Proxy.Lock=False
		self.Object.Proxy.Changed=False
		self.touchTarget=True
		icon='/icons/placer.png'
		self.iconpath = __dir__ + icon
		return
Ejemplo n.º 38
0
    def attach(self, vobj):
        # items for edit dialog  and contextmenue
        self.emenu = [['A', self.funA], ['B', self.funB]]
        self.cmenu = [['AC', self.funA], ['BC', self.funB]]

        say("VO attach " + str(vobj.Object.Label))
        vobj.Proxy = self
        self.Object = vobj.Object
        self.obj2 = self.Object
        self.Object.Proxy.Lock = False
        self.Object.Proxy.Changed = False
        self.touchTarget = True
        icon = '/icons/placer.png'
        self.iconpath = __dir__ + icon
        return
Ejemplo n.º 39
0
	def step(self,now):
		say("Gearing step!" + str(now))
		FreeCAD.R=self
		self.ignore=True

		if now<self.obj2.start or now>self.obj2.end:
			sayd("ausserhalb")
			pass
		else:
			if not self.obj2.obj:
				errorDialog("kein Sketch zugeordnet")
				raise Exception(' self.obj2.obj nicht definiert')
			sys=self.obj2.obj
			s=sys.Links[0]
			pm=sys.Links[1]
			p=pm.Links[0]
			m=pm.Links[1]
			#say("sonne "+ s.Label)
			#say("planet "+ p.Label)
			#say("moinde" + m.Label)
			
			if now==self.obj2.start:
				s.Placement.Rotation.Axis=FreeCAD.Vector(0,0,1)
				p.Placement.Rotation.Axis=FreeCAD.Vector(0,0,1)
				m.Placement.Rotation.Axis=FreeCAD.Vector(0,0,1)
				
			# Eigenachsen Rotationen
			print(s.Placement.Rotation.Angle)
			an=s.Placement.Rotation.Angle
			ax=s.Placement.Rotation.Axis
			day_star=self.obj2.dayStar
			day_planet=self.obj2.dayPlanet
			day_moon=self.obj2.dayMoon

			rotstep(s,day_star)
			rotstep(p,day_planet)
			rotstep(m,day_moon)
			#p.Placement.Rotation.Angle += math.pi * 2/day_planet
			#m.Placement.Rotation.Angle += math.pi * 2/day_moon
			
			# Schenkel Rotationen
			sys.Placement.Rotation.Angle += 0
			pm.Placement.Rotation.Angle += 0
			
			FreeCAD.activeDocument().recompute()


		self.ignore=False
Ejemplo n.º 40
0
 def update(self):
     say("update ")
     import math
     time = self.obj2.time / 100
     say(str(time))
     if self.obj2.mode == 'cartesian':
         pl = FreeCAD.Vector((time * self.xmax) + self.xmin,
                             self.obj2.a * self.fx(time) + self.obj2.b)
     if self.obj2.mode == 'polar':
         # pl=FreeCAD.Vector((time*self.xmax)+self.xmin,self.fx(time))
         pl = FreeCAD.Vector(
             np.cos(np.pi * time * 2), np.sin(np.pi * time * 2),
             0) * (self.obj2.a * self.fx(time) + self.obj2.b)
     if self.obj2.target != None:
         self.obj2.target.Placement.Base = pl
         self.obj2.target.purgeTouched()
Ejemplo n.º 41
0
    def step(self, now):
        say("Gearing step!" + str(now))
        FreeCAD.R = self
        self.ignore = True

        if now < self.obj2.start or now > self.obj2.end:
            sayd("ausserhalb")
            pass
        else:
            if not self.obj2.obj:
                errorDialog("kein Sketch zugeordnet")
                raise Exception(' self.obj2.obj nicht definiert')
            sys = self.obj2.obj
            s = sys.Links[0]
            pm = sys.Links[1]
            p = pm.Links[0]
            m = pm.Links[1]
            #say("sonne "+ s.Label)
            #say("planet "+ p.Label)
            #say("moinde" + m.Label)

            if now == self.obj2.start:
                s.Placement.Rotation.Axis = FreeCAD.Vector(0, 0, 1)
                p.Placement.Rotation.Axis = FreeCAD.Vector(0, 0, 1)
                m.Placement.Rotation.Axis = FreeCAD.Vector(0, 0, 1)

            # Eigenachsen Rotationen
            print(s.Placement.Rotation.Angle)
            an = s.Placement.Rotation.Angle
            ax = s.Placement.Rotation.Axis
            day_star = self.obj2.dayStar
            day_planet = self.obj2.dayPlanet
            day_moon = self.obj2.dayMoon

            rotstep(s, day_star)
            rotstep(p, day_planet)
            rotstep(m, day_moon)
            #p.Placement.Rotation.Angle += math.pi * 2/day_planet
            #m.Placement.Rotation.Angle += math.pi * 2/day_moon

            # Schenkel Rotationen
            sys.Placement.Rotation.Angle += 0
            pm.Placement.Rotation.Angle += 0

            FreeCAD.activeDocument().recompute()

        self.ignore = False
Ejemplo n.º 42
0
def createStepFC(self,i):
	ts=time.time()
	objs=pclgroup()
	(la,lb)=self.ptsl[i].shape
#	pts=[tuple(self.ptslix[self.ptsl[i][a][b]]) for a in range(la) for b in range(lb)]

	pts=[]
	for a in range(la):
		for b in range(lb):
			t=tuple(self.ptslix[self.ptsl[i][a][b]])
			if np.isnan(t[0]) or np.isnan(t[1]) or np.isnan(t[2]):
##debug				print "found error ", t
#				print (a,b)
				
				pass
# ignore zero points
			elif 	abs(t[0])<10 and  abs(t[1])<20:
##debug				print "ignore inner point ",t
				pass
			else:
				pts.append(t)

	pcl=Points.Points(pts)
	Points.show(pcl)

	App.activeDocument().recompute()
	if i%25==0: Gui.SendMsgToActiveView("ViewFit")

	obj=App.ActiveDocument.ActiveObject
	obj.ViewObject.ShapeColor=(random.random(),random.random(),random.random())


	if len(objs.OutList)==0:
		obj.Placement=self.obj2.startPosition
	else:
		#movePosition=FreeCAD.Placement()
		#movePosition.Rotation=FreeCAD.Rotation(FreeCAD.Vector(0,0,1),10)
		movePosition=self.obj2.deltaPosition
		obj.Placement=objs.OutList[-1].Placement.multiply(movePosition)


	objs.addObject(obj)
	te=time.time()
	say(("createStepFC ",i,"timee",round(te-ts,3)))

	return obj
Ejemplo n.º 43
0
def createStepFC(self,i):
	ts=time.time()
	objs=pclgroup()
	(la,lb)=self.ptsl[i].shape
#	pts=[tuple(self.ptslix[self.ptsl[i][a][b]]) for a in range(la) for b in range(lb)]

	pts=[]
	for a in range(la):
		for b in range(lb):
			t=tuple(self.ptslix[self.ptsl[i][a][b]])
			if np.isnan(t[0]) or np.isnan(t[1]) or np.isnan(t[2]):
				
				pass

			elif 	abs(t[0])<10 and  abs(t[1])<20:

				pass
			else:
				pts.append(t)

	pcl=Points.Points(pts)
	Points.show(pcl)

	App.activeDocument().recompute()
	if i%25==0: Gui.SendMsgToActiveView("ViewFit")

	obj=App.ActiveDocument.ActiveObject
	obj.ViewObject.ShapeColor=(random.random(),random.random(),random.random())


	if len(objs.OutList)==0:
		obj.Placement=self.obj2.startPosition
	else:
		#movePosition=FreeCAD.Placement()
		#movePosition.Rotation=FreeCAD.Rotation(FreeCAD.Vector(0,0,1),10)
		movePosition=self.obj2.deltaPosition
		obj.Placement=objs.OutList[-1].Placement.multiply(movePosition)


	objs.addObject(obj)
	te=time.time()
	say(("createStepFC ",i,"timee",round(te-ts,3)))

	return obj
Ejemplo n.º 44
0
 def step(self, now):
     try:
         # https://github.com/hamish2014/FreeCAD_assembly2/issues/73
         import assembly2lib
         assembly2lib.debugPrint.level = 0  #the default is 2
         assembly2lib.debugPrint.level = self.obj2.debugLevel
         import assembly2solver
         try:
             constraintSystem = assembly2solver.solveConstraints(
                 FreeCAD.ActiveDocument,
                 showFailureErrorDialog=False,
                 printErrors=self.obj2.printErrors)
             if constraintSystem == None:
                 sayErr('Solver failed to satisfy specified constraints')
             else:
                 say("Solver step done " + str(now))
         except:
             sayErr(
                 "problem assembly2solver.solveConstraints(App.ActiveDocument)"
             )
     except:
         sayErr("problem no assembly2 available")
         pass
Ejemplo n.º 45
0
 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)
Ejemplo n.º 46
0
	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)
Ejemplo n.º 47
0
	def step(self,now):
		say("step "+str(now) + str(self))
		self.obj2.time=float(now)/100
Ejemplo n.º 48
0
	def funA(self):
		say("ich bin FunA touch target")
		FreeCAD.ActiveDocument.recompute()
		self.obj2.target.touch()
		FreeCAD.ActiveDocument.recompute()
		say("ich war  FunA")
Ejemplo n.º 49
0
	def __init__(self,vobj):
		say(self)
		Animation._ViewProviderActor.__init__(self,vobj)
		self.attach(vobj)
Ejemplo n.º 50
0
    def eventFilter(self, o, e):
        z = str(e.type())
        try:
            # not used events
            if z == 'PySide.QtCore.QEvent.Type.ChildAdded' or \
              z == 'PySide.QtCore.QEvent.Type.ChildRemoved'or \
              z == 'PySide.QtCore.QEvent.Type.User'  or \
              z == 'PySide.QtCore.QEvent.Type.Paint' or \
              z == 'PySide.QtCore.QEvent.Type.LayoutRequest' or\
              z == 'PySide.QtCore.QEvent.Type.UpdateRequest'   :
                return QtGui.QWidget.eventFilter(self, o, e)

            if z == 'PySide.QtCore.QEvent.Type.HoverMove':
                self.pos = e.pos()
            if z == 'PySide.QtCore.QEvent.Type.KeyPress':
                # ignore editors
                if self.editmode:
                    return QtGui.QWidget.eventFilter(self, o, e)

                # only first time key pressed
                if not self.keypressed:
                    text = e.text()
                    if 0 or text <> '':
                        self.keypressed = True
                        key = ''
                        if e.modifiers() & QtCore.Qt.SHIFT:
                            #FreeCAD.Console.PrintMessage("SHIFT ")
                            key += "SHIFT+"
                        if e.modifiers() & QtCore.Qt.CTRL:
                            #FreeCAD.Console.PrintMessage("CTRL ")
                            key += "CTRL+"
                        if e.modifiers() & QtCore.Qt.ALT:
                            #FreeCAD.Console.PrintMessage("ALT ")
                            key += "ALT+"
                        key += PySide.QtGui.QKeySequence(e.key()).toString()
                        FreeCAD.Console.PrintMessage(" " + str(key) + " \n")

                        pos = self.pos
                        #if e.key()== QtCore.Qt.Key_F10:
                        #	key += "F10#"

                        if pos:
                            if self.debug:
                                FreeCAD.Console.PrintMessage(
                                    key + " at mouse position: " + str(pos) +
                                    "\n")
                            say(pos.x())
                            say(pos.y())
                            step = 1
                            if key == 'F':
                                self.V.Placement.Base.x -= step
                            elif key == 'G':
                                self.V.Placement.Base.x += step
                            elif key == 'T':
                                self.V.Placement.Base.y += step
                            elif key == 'V':
                                self.V.Placement.Base.y -= step
                            elif key == 'Z':
                                self.V.Placement.Base.x += step
                                self.V.Placement.Base.y += step
                            elif key == 'R':
                                self.V.Placement.Base.x -= step
                                self.V.Placement.Base.y += step
                            elif key == 'B':
                                self.V.Placement.Base.x += step
                                self.V.Placement.Base.y -= step
                            elif key == 'C':
                                self.V.Placement.Base.x -= step
                                self.V.Placement.Base.y -= step

                            elif key == 'H':
                                s = Gui.Selection.getSelection()
                                try:
                                    ll = Gui.Selection.getSelectionEx()
                                    pts = ll[0].PickedPoints
                                    V.Placement.Base.x = pts[0].x
                                    V.Placement.Base.y = pts[0].y
                                except:
                                    try:
                                        say("error 11")
                                        self.V.Placement.Base.x = s[
                                            0].Placement.Base.x
                                        self.V.Placement.Base.y = s[
                                            0].Placement.Base.y
                                    except:
                                        say("error 2")
                                        pass
                            self.ctl.Placement = self.V.Placement
                            App.ActiveDocument.recompute()
                        else:
                            self.keypressed = False
            if z == 'PySide.QtCore.QEvent.Type.KeyRelease':
                if self.keypressed:
                    pass
                self.keypressed = False
        except:
            sayexc()
        try:
            return QtGui.QWidget.eventFilter(self, o, e)
        except:
            return None
Ejemplo n.º 51
0
	def funB(self):
		say("ich bin FunB tozch target")
		self.touchTarget=not self.touchTarget
		say(self.touchTarget)
Ejemplo n.º 52
0
	def edit(self):
		say(self)
		self.dialog=controlPanelWidget(self.Object)
		self.dialog.show()
Ejemplo n.º 53
0
	def update(self):
		time=self.obj2.time
		try:
			say("update time=" + str(time) + ", "+ self.obj2.Label)
		except:
			say("update (ohne Label)")

		# get the parameters
		x0=self.obj2.x0
		x1=self.obj2.x1
		y0=self.obj2.y0
		y1=self.obj2.y1
		z0=self.obj2.z0
		z1=self.obj2.z1
		arc0=self.obj2.arc0
		arc1=self.obj2.arc1
		
		if self.obj2.target:
			if self.obj2.target.__class__.__name__ == 'GroupExtension':
				t=self.obj2.target.Group[0]
			else:
				t=self.obj2.target
				
			x=t.Placement.Base.x
			y=t.Placement.Base.y
			z=t.Placement.Base.z
			rx=t.Placement.Rotation.Axis.x
			ry=t.Placement.Rotation.Axis.y
			rz=t.Placement.Rotation.Axis.z
			arc=t.Placement.Rotation.Angle
		try:
			sx=self.obj2.src.Placement.Base.x
			sy=self.obj2.src.Placement.Base.y
			sz=self.obj2.src.Placement.Base.z
			srx=self.obj2.src.Placement.Rotation.Axis.x
			sry=self.obj2.src.Placement.Rotation.Axis.y
			srz=self.obj2.src.Placement.Rotation.Axis.z
			sarc=self.obj2.src.Placement.Rotation.Angle
		except:
			pass 
			# saye("keine src festgelegt")

		# compute the new placement
		xv=eval(self.obj2.x)
		yv=eval(self.obj2.y)
		zv=eval(self.obj2.z)
		arcv=eval(self.obj2.arc)

		rot=FreeCAD.Rotation(self.obj2.RotAxis,arcv)

#		say(self.obj2.target.Label)
#		say("Vorgabe arcv " + str(arcv) +" ->Rotation ..." + str(rot.Axis) + "winkel " + str(rot.Angle))

		pl=FreeCAD.Placement(FreeCAD.Vector(xv,yv,zv),rot,self.obj2.RotCenter)
		#say(pl)
		if self.obj2.target!=None:
			if self.obj2.target.__class__.__name__ == 'GroupExtension':
				for t in self.obj2.target.Group:
					if str(t.TypeId) == 'App::Annotation':
						t.Position=(xv,yv,zv)
					else:
						pl2=pl.multiply(self.obj2.prePlacement)
						t.Placement=pl2
			else:
				if str(self.obj2.target.TypeId) == 'App::Annotation':
					self.obj2.target.Position=(xv,yv,zv)
				else:
					pl2=pl.multiply(self.obj2.prePlacement)
					self.obj2.target.Placement=pl2

		for t in self.obj2.Group:
			if str(t.TypeId) == 'App::Annotation':
				t.Position=(xv,yv,zv)
			else:
				pl2=pl.multiply(self.obj2.prePlacement)
				t.Placement=pl2



		self.obj2.Placement=pl
		if self.obj2.followers:
			for f in self.obj2.followers:
		#	FreeCAD.ActiveDocument.Ergebnis.Proxy.execute(FreeCAD.ActiveDocument.Ergebnis)
				f.Proxy.execute(f)
Ejemplo n.º 54
0
	def eventFilter(self, o, e):
		z=str(e.type())
		try:
			# not used events
			if z == 'PySide.QtCore.QEvent.Type.ChildAdded' or \
					z == 'PySide.QtCore.QEvent.Type.ChildRemoved'or \
					z == 'PySide.QtCore.QEvent.Type.User'  or \
					z == 'PySide.QtCore.QEvent.Type.Paint' or \
					z == 'PySide.QtCore.QEvent.Type.LayoutRequest' or\
					z == 'PySide.QtCore.QEvent.Type.UpdateRequest'   :
				return QtGui.QWidget.eventFilter(self, o, e)
			
			if z == 'PySide.QtCore.QEvent.Type.HoverMove' :
				self.pos=e.pos()
			if z == 'PySide.QtCore.QEvent.Type.KeyPress':
				# ignore editors
				if self.editmode:
					return QtGui.QWidget.eventFilter(self, o, e)
				
				# only first time key pressed
				if not self.keypressed:
					text=e.text()
					if 0 or text !='':
						self.keypressed=True
						key=''
						if e.modifiers() & QtCore.Qt.SHIFT:
							#FreeCAD.Console.PrintMessage("SHIFT ")
							key +="SHIFT+"
						if e.modifiers() & QtCore.Qt.CTRL:
							#FreeCAD.Console.PrintMessage("CTRL ")
							key +="CTRL+"
						if e.modifiers() & QtCore.Qt.ALT:
							#FreeCAD.Console.PrintMessage("ALT ")
							key +="ALT+"
						key +=PySide.QtGui.QKeySequence(e.key()).toString() 
						FreeCAD.Console.PrintMessage(" "+str(key)  +" \n" )
						
						pos=self.pos
						#if e.key()== QtCore.Qt.Key_F10:
						#	key += "F10#"

						if pos:
							if self.debug: FreeCAD.Console.PrintMessage( key + " at mouse position: " +str(pos) + "\n")
							say(pos.x())
							say(pos.y())
							step=1
							if key == 'F':
								self.V.Placement.Base.x -= step
							elif key == 'G':
								self.V.Placement.Base.x += step
							elif key == 'T':
								self.V.Placement.Base.y += step
							elif key == 'V':
								self.V.Placement.Base.y -= step
							elif key == 'Z':
								self.V.Placement.Base.x += step
								self.V.Placement.Base.y += step
							elif key == 'R':
								self.V.Placement.Base.x -= step
								self.V.Placement.Base.y += step
							elif key == 'B':
								self.V.Placement.Base.x += step
								self.V.Placement.Base.y -= step
							elif key == 'C':
								self.V.Placement.Base.x -= step
								self.V.Placement.Base.y -= step

								
							elif key == 'H':
								s=Gui.Selection.getSelection()
								try:
									ll=Gui.Selection.getSelectionEx()
									pts=ll[0].PickedPoints
									V.Placement.Base.x=pts[0].x
									V.Placement.Base.y=pts[0].y
								except:
									try:
										say("error 11")
										self.V.Placement.Base.x=s[0].Placement.Base.x
										self.V.Placement.Base.y=s[0].Placement.Base.y
									except:
										say("error 2")
										pass
							self.ctl.Placement=self.V.Placement
							App.ActiveDocument.recompute()
						else:
							self.keypressed=False
			if z == 'PySide.QtCore.QEvent.Type.KeyRelease':
				if self.keypressed:
					pass
				self.keypressed=False
		except:
			sayexc()
		try:
			return QtGui.QWidget.eventFilter(self, o, e)
		except:
			return None
Ejemplo n.º 55
0
    def update(self):
        time = self.obj2.time
        try:
            say("update time=" + str(time) + ", " + self.obj2.Label)
        except:
            say("update (ohne Label)")

        # get the parameters
        x0 = self.obj2.x0
        x1 = self.obj2.x1
        y0 = self.obj2.y0
        y1 = self.obj2.y1
        z0 = self.obj2.z0
        z1 = self.obj2.z1
        arc0 = self.obj2.arc0
        arc1 = self.obj2.arc1

        if self.obj2.target:
            x = self.obj2.target.Placement.Base.x
            y = self.obj2.target.Placement.Base.y
            z = self.obj2.target.Placement.Base.z
            rx = self.obj2.target.Placement.Rotation.Axis.x
            ry = self.obj2.target.Placement.Rotation.Axis.y
            rz = self.obj2.target.Placement.Rotation.Axis.z
            arc = self.obj2.target.Placement.Rotation.Angle
        try:
            sx = self.obj2.src.Placement.Base.x
            sy = self.obj2.src.Placement.Base.y
            sz = self.obj2.src.Placement.Base.z
            srx = self.obj2.src.Placement.Rotation.Axis.x
            sry = self.obj2.src.Placement.Rotation.Axis.y
            srz = self.obj2.src.Placement.Rotation.Axis.z
            sarc = self.obj2.src.Placement.Rotation.Angle
        except:
            pass
            # saye("keine src festgelegt")

        # compute the new placement
        xv = eval(self.obj2.x)
        yv = eval(self.obj2.y)
        zv = eval(self.obj2.z)
        arcv = eval(self.obj2.arc)

        rot = FreeCAD.Rotation(self.obj2.RotAxis, arcv)
        say(self.obj2.target.Label)
        say("Vorgabe arcv " + str(arcv) + " ->Rotation ..." + str(rot.Axis) +
            "winkel " + str(rot.Angle))
        pl = FreeCAD.Placement(FreeCAD.Vector(xv, yv, zv), rot,
                               self.obj2.RotCenter)
        #say(pl)
        if str(self.obj2.target.TypeId) == 'App::Annotation':
            self.obj2.target.Position = (xv, yv, zv)
        else:
            pl2 = pl.multiply(self.obj2.prePlacement)
            self.obj2.target.Placement = pl2

        self.obj2.Placement = pl
        if self.obj2.followers:
            for f in self.obj2.followers:
                #	FreeCAD.ActiveDocument.Ergebnis.Proxy.execute(FreeCAD.ActiveDocument.Ergebnis)
                f.Proxy.execute(f)
Ejemplo n.º 56
0
 def funB(self):
     say("ich bin FunB tozch target")
     self.touchTarget = not self.touchTarget
     say(self.touchTarget)
Ejemplo n.º 57
0
 def funA(self):
     say("ich bin FunA touch target")
     FreeCAD.ActiveDocument.recompute()
     self.obj2.target.touch()
     FreeCAD.ActiveDocument.recompute()
     say("ich war  FunA")
Ejemplo n.º 58
0
 def __init__(self, vobj):
     say(self)
     Animation._ViewProviderActor.__init__(self, vobj)
     self.attach(vobj)