Modules and Namespaces
Larry Bates
larry.bates at websafe.com
Thu Oct 20 12:21:46 EDT 2005
One way is to pass the RS object when you instantiate
an instance of srfBase, something like:
class srfBase:
'''Base class inherited by the srf* classes, binding general Rhino
surface functionality to a particular
surface generation method'''
def __init__(self, RS):
self.id = 'self.id srfBase'
self.RS=RS
return
def isBrep(self):
return self.RS.IsBrep(self.id)
def isPointInSurface(self, coord):
return self.RS.IsPointInSurface(self.id, coord)
This is how most of wxWindows seems to do things.
-Larry Bates
Jelle Feringa / EZCT Architecture & Design Research wrote:
> ##I'm sorry to stir up such a well discussed topic yet again, but namespaces
> are a point of confusion to me...
>
> I took the effort of organizing my Python code (scripting a cad program
> calles Rhino) in well defined classes, which would be a terrific thing if I
> didn't got stuck in namespace issues.
>
> I have a module that launches the application I'm scripting via win32com;
> rhino.load
>
> from rhino import load
> RS = load.RS
>
> So the application, with all its methods are now available through the RS
> (RhinoScript) object
>
> from rhino import SRF # is where things get stuck
>
> The RS object is the application scripted via COM, where all its method
> reside.
> In my module, SRF, I'm not importing anything, though it refers to the RS
> object all the time.
> Such as:
>
> class srfBase:
> '''Base class inherited by the srf* classes, binding general Rhino
> surface functionality to a particular
> surface generation method'''
> def __init__(self):
> self.id = 'self.id srfBase'
> pass
> def isBrep(self):
> return RS.IsBrep(self.id)
> def isPointInSurface(self, coord):
> return RS.IsPointInSurface(self.id, coord)
>
>
> How do I make the RS object available to the imported SRF module, such that
> my module code and program code both refer to RS as the application object
> being scripted?
>
> Cheers,
>
> Jelle.
>
>
More information about the Python-list
mailing list