Re: [Modeling-users] different models in same package
Status: Abandoned
Brought to you by:
sbigaret
From: Mario R. <ma...@ru...> - 2003-12-05 10:37:48
|
Hi! > Hi Mario, > > My best bet is that the second model is not loaded at all. Keep in > mind that the model is loaded as soon as the package itself is = accessed > --ie. when the package's __init__.py is "traversed". Thus it's no > surprise that those two statements have the very same effect: > >>>>> from packone.EntInOne import EntInOne >>>>> from packone.EntInTwo import EntInTwo > > What happens here is probably that, since you generated the package w/ > the 1st model, the package's __init__.py only loads the 1st model. = When > you generated the code for the second model *in the same package*, > __init__.py already exists so it's not overwritten, nor it is changed. > > The relevant lines in __init__.py are: > > model=3DModel.searchModel("pymone", mydir, verbose=3D0) > if not model: > import warnings > warnings.warn("Couldn't load model pymone") > else: > ModelSet.defaultModelSet().addModel(model) > > they should probably be changed into something like: > > pymone=3DModel.searchModel("pymone", mydir, verbose=3D0) > pymtwo=3DModel.searchModel("pymtwo", mydir, verbose=3D0) > if not pymone or not pymtwo: > import warnings > warnings.warn("Couldn't load model(s) pymone and/or pymtwo") > else: > ModelSet.defaultModelSet().addModel(pymone) > ModelSet.defaultModelSet().addModel(pymtwo) > Ah, yes, this seems exactly right. I have switched to different packages for each model now, so to test it properly I need to go back to previous set-up (not sure which one I prefer now ;). However, I wonder if this code in __init__ can be parametrized somehow. All it needs as input is the list of models in the package. Maybe the list of models may be calculated by looking into the custom classes -- if model for this class is unknown yet, then it is added to the list... Otherwise, I could live with having to make such a modification=20 manually, but I would need to know about it (if I did know this last night I would have gained a few hours ;-) Thus, maybe at least an FAQ entry, such as: How can I automatically generate one package from several models? Thanks! mario > HTH, cheers, > > > -- S=E9bastien. |