-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Copying an EntityList from a loaded blueprint throws InvalidAssociationError if any entities have connections #117
Comments
Thanks for the report, I'll take a look at this over the weekend. |
Once I created a workaround, I discovered the I will throw some more scenarios at it and see if that resolves the issue. |
After taking a look at what you're intending, this seems to be another case of a sore spot between interacting with Blueprintables, similar to issue #48. Basically, when you Because Draftsman doesn't have this information when copying one-at-a-time, it defaults to keeping the Associations in the copied entity identical to the original. This means that the entities in The reason why A clearer option might be to wipe any entity Associations when copying individually, giving a user a hint that what they're attempting to do is somewhat malformed by definition... but it could also be equally as confusing to have entities with connections mysteriously lose them after a copy. One could have it so that any entity associated with a copied entity is also copied to ensure that all Associations are preserved, but I'm not sure this is clearer, would probably not be always desired, and would likely have a performance impact to boot. It should be noted that the Suggestions on improving this are obviously welcome, particularly from an outsider's perspective. Structural changes can also be made, since I'm planning on releasing 2.0 in the near future so any breaking change is tolerable there. |
I think my main issue was not understanding how best to copy entities with connections. The docs don't call out a best practice (which sounds like it should be As for making partial copies of the I will look into making the best practice for copying between blueprints & groups clearer in the docs. That might be the best resolution to this particular issue. |
When loading a blueprint from an external source, or building it in code, and then copying its
.entities
to aGroup
, Draftsman throws anInvalidAssociationError
if any entities have any connections of either kind (circuit or power). The external blueprint is valid in-game, and this can be reproduced in a blueprint with two entities: two power poles with a single electric connection. Test case available as gist.Current Behavior
Blueprint
object, or create one in code..entities
to a newGroup
(group.entities.extend(bp.entities)
).InvalidAssociationError
exception will be thrown, with explanatory text like this:Attempting to connect to <ElectricPole 'medium-02'>{'name': 'medium-electric-pole', 'position': {'x': 3.0, 'y': 0.0}, 'neighbours': [<Association to ElectricPole at 0x00007F62A442FED0>]} which lies outside this EntityCollection; are all Associations between entities contained within this EntityCollection being copied?
Expected behavior
Copying a list of entities from a blueprint should work the same as copying them from a group that was generated in code. All connections should be preserved, and no errors should be thrown.
Additional context
Related to #22.
Draftsman version:
1.1.0
Python version:
3.12.0
I wanted to find out if this can be supported natively, as I use this in a tool that "remixes" blueprints by loading them into Groups and modifying and combining them according to the user's config.
The text was updated successfully, but these errors were encountered: