WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rating: Thread Rating: 8 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 09-05-2012, 09:58 AM
shivanangel shivanangel is offline
Member
 
Join Date: Feb 2006
Location: New Jersey
Posts: 182
Question Properly handling Inheritance of VizNode and using copy

Hello Vizard support.

I had a question on how to properly implement the <viz.VizNode>.copy method when using inheritance.

I have created several class that inherit from VizNode, however they have their own __init__ functions that take in additional parameters beyond what VizNode might utilize.

When I create a copy of these objects using the original copy method provided by Vizard, I get an error that indicates I am not getting the correct number of parameters into the class __init__ method I created.

When I looked at how copy was implemented, it looks like you return an instance of self.__class__(Vizard Stuff In Here) when I call copy.

Below is my __init__ method, as you can see I take in an additional template parameter.

Code:
class GreenObject(Model3D, Properties):
	def __init__(self, modelString, GOTemplate):
		Model3D.__init__(self, modelString)
		
		self.publicVariables = []
	
		self.variableValues = [0.0] * len(GreenObject.properties2Indices)
		
		self.greenObjectTemplate = GOTemplate
If possible, I would like to call the original copy functionality along with doing some copying of my own when <*>.copy is called.

Normally, I would just call the base classes version then add my own code. But I don't know much about what VizNode is doing behind the scenes and I figured you'd have a better idea on how to handle this.

Thanks,
George
Reply With Quote
 

Tags
inheritance, viznode

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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 01:49 PM.


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