I want to import .dat files. I can import .dat files clicking option in menu, cause I've install an plugin from here. But I don't know how to import .dat files in scripts.

I have tried read the plugin's code. The plugin's code has a folder structure like this:


In importldraw.py, I found something might be relevant to my question: loadldraw.loadFromFile(self, self.filepath) I put my script named render_script.py and files above in the same folder. But after I import loadldraw and code relevant above in my script, an error occurred. My script and the error are shown below:

import bpy
from bpy import context
import os
import sys
import importldraw
import loadldraw
path = 'D:/lego_part/ldraw/parts/8.dat'

my = loadldraw.loadFromFile(importldraw.ImportLDrawOps, r'D:\lego_part\ldraw\parts\8.dat')

Traceback (most recent call last):
  File "\render_script.py", line 7, in <module>

  File "C:\Users\HL\Desktop\blender_script\importldraw.py", line 111, in <module>
    class ImportLDrawOps(bpy.types.Operator, ImportHelper):
  File "C:\Users\HL\Desktop\blender_script\importldraw.py", line 134, in ImportLDrawOps
    default=prefs.get("ldrawDirectory", loadldraw.Configure.findDefaultLDrawDirectory())
AttributeError: module 'loadldraw' has no attribute 'Configure'
Error: Python script failed, check the message in the system console

I neither know how to fix the error nor know how to import .dat files in script. Can someone help me? Any help would be greatly appreciated :)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.