Error With Relative Path And Linked Projects When Printing Drawing

by ADMIN 67 views

Introduction

Bonsai is a powerful tool for working with linked projects and creating drawings. However, when generating a drawing that includes a linked project with a relative path, an error arises. In this article, we will explore this issue and provide a solution.

Understanding the Issue

When generating a drawing that includes a linked project, Bonsai works fine if the linked project's path is absolute. However, if the linked project's path is set to be relative, an error occurs. This error is not related to the file path or name, but rather to the relative path of the linked project.

Error Message

The error message is as follows:

Traceback (most recent call last):
  File "C:\Users\glopez\AppData\Roaming\Blender Foundation\Blender\4.3\extensions\.local\lib\python3.11\site-packages\bonsai\bim\module\drawing\operator.py", line 298, in execute
    linework_svg = self.generate_linework(context)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\glopez\AppData\Roaming\Blender Foundation\Blender\4.3\extensions\.local\lib\python3.11\site-packages\bonsai\bim\module\drawing\operator.py", line 719, in generate_linework
    IfcStore.session_files[link.name] = ifcopenshell.open(link.name)
                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\glopez\AppData\Roaming\Blender Foundation\Blender\4.3\extensions\.local\lib\python3.11\site-packages\ifcopenshell\__init__.py", line 162, in open
    raise FileNotFoundError(f"File does not exist: '{path}'.")
FileNotFoundError: File does not exist: 'untitled_.ifc'.

Test to Reproduce the Error

To reproduce this error, you can create two blank projects, one linked to the other. This will allow you to test the issue and understand the cause of the error.

System Information

The following system information is relevant to this issue:

  • os: Windows
  • os_version: 10.0.19041
  • python_version: 3.11.9
  • architecture: ('64bit', 'WindowsPE')
  • machine: AMD64
  • processor: Intel64 Family 6 Model 142 Stepping 10, GenuineIntel
  • blender_version: 4.3.2
  • bonsai_version: 0.8.1
  • bonsai_commit_hash: None
  • last_actions:
  • last_error: None
  • ifc: untitled.ifc
  • schema: IFC4X3
  • preprocessor_version: IfcOpenShell 0.8.1
  • originating_system: Bonsai 0.8.1

Solution

To solve this issue, you need to ensure that the linked project's path is absolute. You can do this by setting the path to the linked project to an absolute path, such as C:\linked_project\untitled.ifc.

Alternatively, you can modify the Bonsai code to handle relative paths correctly. This may involve modifying the generate_linework function to correctly handle relative paths.

Conclusion

In conclusion, the error with relative path and linked projects when printing a drawing is a known issue in Bonsai. To solve this issue, you need to ensure that the linked project's path is absolute. Alternatively, you can modify the Bonsai code to handle relative paths correctly.

Troubleshooting Tips

  • Make sure that the linked project's path is absolute.
  • Check that the file path and name are correct.
  • Verify that the Bonsai code is correctly handling relative paths.

Related Issues

Future Development

In future versions of Bonsai, we plan to improve the handling of relative paths in linked projects. This will ensure that users can work with linked projects without encountering this issue.

Acknowledgments

Q: What is the issue with relative path and linked projects in Bonsai?

A: The issue arises when generating a drawing that includes a linked project with a relative path. Bonsai works fine if the linked project's path is absolute, but an error occurs when the path is relative.

Q: What is the error message I see when I try to print a drawing with a linked project?

A: The error message is a FileNotFoundError with the message "File does not exist: 'untitled_.ifc'".

Q: How can I reproduce this error?

A: To reproduce this error, you can create two blank projects, one linked to the other. This will allow you to test the issue and understand the cause of the error.

Q: What system information is relevant to this issue?

A: The following system information is relevant to this issue:

  • os: Windows
  • os_version: 10.0.19041
  • python_version: 3.11.9
  • architecture: ('64bit', 'WindowsPE')
  • machine: AMD64
  • processor: Intel64 Family 6 Model 142 Stepping 10, GenuineIntel
  • blender_version: 4.3.2
  • bonsai_version: 0.8.1
  • bonsai_commit_hash: None
  • last_actions:
  • last_error: None
  • ifc: untitled.ifc
  • schema: IFC4X3
  • preprocessor_version: IfcOpenShell 0.8.1
  • originating_system: Bonsai 0.8.1

Q: How can I solve this issue?

A: To solve this issue, you need to ensure that the linked project's path is absolute. You can do this by setting the path to the linked project to an absolute path, such as C:\linked_project\untitled.ifc.

Alternatively, you can modify the Bonsai code to handle relative paths correctly. This may involve modifying the generate_linework function to correctly handle relative paths.

Q: What are some troubleshooting tips for this issue?

A: Here are some troubleshooting tips for this issue:

  • Make sure that the linked project's path is absolute.
  • Check that the file path and name are correct.
  • Verify that the Bonsai code is correctly handling relative paths.

Q: Are there any related issues that I should be aware of?

A: Yes, there are two related issues that you should be aware of:

Q: What is the future development plan for Bonsai regarding relative paths?

A: In future versions of Bonsai, we plan to improve the handling of relative paths in linked projects. This will ensure that users can work with linked projects without encountering this issue.

Q: How can I contribute to the development of Bonsai?

A: We welcome contributions from the community! You can contribute to the development of Bonsai by reporting issues, suggesting features, and submitting pull requests.