Open RasmusGOlsen opened 1 year ago
The fileset is not linked / in the same project, that's why the error is
Fileset '....' is not associated to this design.
fileset = Fileset('myfileset')
Is a standalone fileset, not linked to project
.
Try this:
project = Project('default')
fileset = Fileset('myfileset', project=project)
project.DefaultDesign.DefaultFileSet = fileset
The idea was: If you have 2 projects (A and B) in your application, you can't mix filesets from A and use/assign them in project B. That's why like 1194 looks up the fileset if its a known fileset, but not yet the default fileset.
Ok, that makes sense, that you cannot assign a default fileset if it's not part of the design. However, I find this line confusing.
fileset = Fileset('myfileset', project=project)
If you create a fileset with a reference to the project, it is not clear to me how the project has a reference to the fileset. I would believe I would have to do this.
project = Project('default')
fileset = Fileset('myfileset')
project.project.DefaultDesign.AddFileSet(fileset)
project.DefaultDesign.DefaultFileSet = fileset
The AddFileSet
method would then set the references to the project and the design for the FileSet and all its children.
I guess the project and design reference should also be a list if the FileSet is part of multiple designs and projects.
Almost all objects are double linked. So e.g. a project knows its designs and a design knows its project.
To enhance the speed, keep work from users setting up the linking and ensuring data structure integrity, this linking is done when ever A is linked to B or B to A. I always try to implement data structures that top-down assembly and bottom-up assembly words as well. Sometimes one is slightly faster then the other (usually top-down).
So you can create an object and hand over the parent object (like shown in my example) or you use later a property to set the relation. In both cases the code takes care of linking forward and backward and sometimes ever for updating statistics and fast lookup structures.
Top-down:
project = Project('default')
fileset = Fileset('myfileset', project=project)
Bottom-up:
fileset = Fileset('myfileset')
project = Project('default')
fileset.Project = project
BUG:
As I looked into the code and saw the reverse linking is missing in Fileset. argh
I get an exception when trying to set the default fileset in the design. Using
fileset.Name
work, but not with the fileset object. Looking at the source it seems like both ways should be supported.https://github.com/edaa-org/pyEDAA.ProjectModel/blob/38aa30fa778c04e3949ac9599047906628c20d35/pyEDAA/ProjectModel/__init__.py#L1186-L1195