WorldViz User Forum  

Go Back   WorldViz User Forum > Plug-in development

Reply
 
Thread Tools Rating: Thread Rating: 3 votes, 5.00 average. Display Modes
  #1  
Old 06-15-2010, 04:12 PM
jsnider jsnider is offline
Member
 
Join Date: Jul 2009
Posts: 9
sensor wrapper

Hi,
I want to wrap an interface around a sensor plugin. I've done it before with a CustomObject ( derive from viz.CustomChild and use viz.upgradeCustomNode ...), and that works great. It looks like the same thing should work for a VizSensor object, but on the following it won't let me call the functions in the derived class (testCall).

Code:
import viz

class SensorClass(viz.VizSensor):
	def testCall(self):
		self.command(1, '', 1)
		
viz.upgradeSensor('sensor.dls',SensorClass)
def addMySensor():
	return viz.add('sensor.dls')
	
if __name__ == '__main__':
	viz.go()
	
	S1 = addMySensor()
	ball = viz.add('ball.wrl')
	viz.link(S1, ball)

	S1.testCall()
sensor.dls is just the sample sensor from the SDK and it works fine (the ball moves around in a circle), but the call to testCall throws an error:
AttributeError: 'VizSensor' object has no attribute 'testCall'
Is there a way to get access to the functions I define in the derived class?
Thanks,
Joe
Reply With Quote
  #2  
Old 06-15-2010, 04:16 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Remove the extension when you call viz.upgradeSensor:
Code:
viz.upgradeSensor('sensor',SensorClass)
Reply With Quote
  #3  
Old 06-15-2010, 04:32 PM
jsnider jsnider is offline
Member
 
Join Date: Jul 2009
Posts: 9
Works great.
Thanks,
Joe
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 03:18 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC