Code Monkey home page Code Monkey logo

Comments (6)

JoshTheDerf avatar JoshTheDerf commented on August 18, 2024

The only potential annoyance I see with this is that it is quite simple to install ldraw in whatever directory you want (EG: C:\Users\MYACCOUNT\My Videos\Lego\Random Stuff\ldraw,) I believe even on Windows, so some people might prefer that you:

  1. Try to auto detect as above,
  2. Save presets to a configuration file
  3. Load presets after trying to auto detect (if they exist) and auto-select one instead.

from ldr-importer.

le717 avatar le717 commented on August 18, 2024

Ah, but what kind of configuration file? Thanks to @Banbury, we can save our installation path using the Blender present option, but they cannot be automatically loaded without a long custom process, it seems.

Am I wee bit confused on step 3.

from ldr-importer.

JoshTheDerf avatar JoshTheDerf commented on August 18, 2024

Hmm.
I've never worked on blender addons before, but my project TitleTool (runs blend files with python scripts) makes use of configuration files. Theres a little trick you can use to write an actual python file, then execute the code in it anywhere in the script as part of the script (kind of like a PHP include). Its kind of dirty and probably frowned upon, but it works quite well.

Clarification on step 3:

  1. Check configuration file for user-set path
  2. If user-set path exists, attempt to locate ldraw using it.
  3. If ldraw is not found, auto-detect. If auto-detect fails, set to default
  4. If ldraw is found, use user-set path

from ldr-importer.

le717 avatar le717 commented on August 18, 2024

Where is the code for the configuration files? I'll take a look at it. I was actually about to begin working on the process when I got an email with your comment.

That makes sense. Will attempt to do.

from ldr-importer.

JoshTheDerf avatar JoshTheDerf commented on August 18, 2024

First, use whatever you want to write a vaild python file, eg (file config.py):

userSelectedLdrawDir = "~/Software/ldraw"

Then in your addon file: write

filename = os.getcwd()+"/config.py"
exec(compile(open(filename).read(), filename, 'exec'))
print(userSelectedLdrawDir)

That's How I interfaced TitleTool's Java program, and the Python blender bootstrap.

Like I said, quick and dirty, basically equivalent to doing a

from config import *

but with more control over the directory location.

from ldr-importer.

le717 avatar le717 commented on August 18, 2024

Feature added in 15b4a91. Please review code in #16 instead of here so we can keep track of comment origin. :)

from ldr-importer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.