You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature] Multi-File Project on PrimeHub/InventorHub #189
cool projectProjects built by awesome users using Pybrickshub: primehub/inventorhubIssues related to the LEGO SPIKE Prime hub and LEGO MINDSTORMS Robot Invetor hub
Happy New Year to you! Antoni and I are looking forward to exciting PyBricks releases this year.
Antoni and I are trying out PyBricks on the InventorHub, and we would like to ask if it is possible yet/soon to download multiple files of one same project onto the InventorHub and import code classes/functions among such files?
Each robot in the Inventor set has many variants and plays many different games, so it would be great if we can organize a base class and many subclasses for each robot.
we would like to ask if it is possible yet/soon to download multiple files of one same project onto the InventorHub and import code classes/functions among such files?
In the long run, probably yes. However, knowing how fast you are, probably not before you have built all the models 😄
Each robot in the Inventor set has many variants and plays many different games, so it would be great if we can organize a base class and many subclasses for each robot.
However, a base class for each robot is probably still a good idea. You'd have to have a copy in each program for now. Perhaps we could split it out to a library (or something like it) later when we have file system support.
Since this system is a bit different from EV3, I do have a few suggestions for minor style changes for these projects. Perhaps we can discuss those when you make the first pull request.
Since this system is a bit different from EV3, I do have a few suggestions for minor style changes for these projects. Perhaps we can discuss those when you make the first pull request.
Since you've shared a snippet in #190, perhaps I can share what I mean here. These are some performance considerations as well as suggestions to make them easier to read for beginning users.
Basically I think we can rely on the building instructions for cables/ports, just like we assume users have built the rest of the robot according to the instructions.
Within the class methods, it may be better to use regular arguments for required arguments, while using keyword arguments only for optional arguments. Sometimes, this makes the script a bit easier to read, and on these hubs it is also better for performance.
Omitting if __name__ == '__main__': would be fine as well.
This is now possible in both Pybricks Code Beta and pybricksdev. Both "magically" search for imports and include imports in the same directory as the main script when downloading and running.
cool projectProjects built by awesome users using Pybrickshub: primehub/inventorhubIssues related to the LEGO SPIKE Prime hub and LEGO MINDSTORMS Robot Invetor hub
Activity
laurensvalk commentedon Jan 2, 2021
Wow, you guys are quick! 🚀
In the long run, probably yes. However, knowing how fast you are, probably not before you have built all the models 😄
However, a base class for each robot is probably still a good idea. You'd have to have a copy in each program for now. Perhaps we could split it out to a library (or something like it) later when we have file system support.
Since this system is a bit different from EV3, I do have a few suggestions for minor style changes for these projects. Perhaps we can discuss those when you make the first pull request.
laurensvalk commentedon Jan 2, 2021
Since you've shared a snippet in #190, perhaps I can share what I mean here. These are some performance considerations as well as suggestions to make them easier to read for beginning users.
#!/usr/bin/env pybricks-micropython. This was specific to ev3devBasically I think we can rely on the building instructions for cables/ports, just like we assume users have built the rest of the robot according to the instructions.
if __name__ == '__main__':would be fine as well.What do you think?
laurensvalk commentedon Aug 23, 2022
We've got a proof of concept where this works! If you want to give it a go:
See pybricks/pybricks-micropython#115 for details.
dlech commentedon Oct 21, 2022
This is now possible in both Pybricks Code Beta and pybricksdev. Both "magically" search for imports and include imports in the same directory as the main script when downloading and running.