Skip to content
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

Enable usage of local use/include statements #3

Closed
wants to merge 1 commit into from
Closed

Enable usage of local use/include statements #3

wants to merge 1 commit into from

Conversation

mgsb
Copy link
Contributor

@mgsb mgsb commented Mar 15, 2023

Openscad enables code re-use via the include and use methods. https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Include_Statement This change generates the temporary file for the scad buffer in the default-directory so local files can be found via use or include statements during preview or flymake operations.

Openscad enables code re-use via the include and use methods.
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Include_Statement
This change generates the temporary file for the scad buffer
in the default-directory so local files can be found via use or
include statements during preview or flymake operations.
@minad minad closed this in e45793d Mar 15, 2023
@minad
Copy link
Member

minad commented Mar 15, 2023

Thanks, good point. I am not fond of creating files in the working directory, but it seems there is no other way, since openscad does not have a search path command line option.

@t-paul
Copy link
Member

t-paul commented Mar 15, 2023

Currently only the environment variable exists, but that sounds like a useful feature request.

@mgsb
Copy link
Contributor Author

mgsb commented Mar 15, 2023

Thanks for the change. I agree that local temporary files are not great, but it seems the simplest approach.

@minad
Copy link
Member

minad commented Mar 15, 2023

@t-paul

Currently only the environment variable exists, but that sounds like a useful feature request.

Can you please point me to the documentation? We should better change this to instead add the default-directory to the environment variable.

@mgsb

Thanks for the change. I agree that local temporary files are not great, but it seems the simplest approach.

It is not great to go with the simplest approach. I will revert and we can hopefully use the environment variables.

minad added a commit that referenced this pull request Mar 15, 2023
…irectory (Fix #3)"

This reverts commit e45793d.

See the discussion in #3. It is
better to use an environment variable to specify the search path.
@t-paul
Copy link
Member

t-paul commented Mar 15, 2023

It's mentioned in the Library section:
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Libraries#Library_locations

It's intended to work like the usual PATH variables, providing a list of root directories for relative file lookup.

@mgsb
Copy link
Contributor Author

mgsb commented Mar 15, 2023

Yes, this is a better approach - I missed the environment variable in my googling of the topic.

@minad
Copy link
Member

minad commented Mar 15, 2023

@t-paul Thanks! I only looked at https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Include_Statement and it wasn't mentioned there.

@mgsb Would you like to prepare an improved PR which uses OPENSCADPATH?

@t-paul
Copy link
Member

t-paul commented Mar 15, 2023

Ah, good point, I've added a short note mentioning the variable to that page.

@mgsb
Copy link
Contributor Author

mgsb commented Mar 16, 2023

Ok, I'll give it a try. I don't see a command-line option for openscad, so I'll use process-environment.

@mgsb
Copy link
Contributor Author

mgsb commented Mar 16, 2023

In testing this, I found another issue with copying the source scad file. Import statements with relative file paths https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Importing_Geometry are not found when the source is moved. There does not appear to be a search path for these statements.
Why is it necessary to make a copy of the source? Just use the original file associated with the buffer and "compile" it seems like it would work.

@minad
Copy link
Member

minad commented Mar 16, 2023 via email

@mgsb
Copy link
Contributor Author

mgsb commented Mar 16, 2023

Ok, I remember - the preview is updated periodically based on buffer changes - not file changes/saves.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants