Results 1 to 11 of 11

Thread: How import 3DS file with Python

  1. #1

    How import 3DS file with Python

    Hi:

    I am trying to load some 3DS files with Python, but I don't have any
    idea. I try with the Load method of Blender class, but itīs not possible,
    becuase only can load .blend files.

    Does anybody know how can load 3DS files with Python?

    Thanks and sorry for my bad english.



  2. #2
    Member Michael W's Avatar
    Join Date
    Nov 2007
    Location
    UK
    Posts
    4,992
    the 3ds importer is just another python script.

    load it as a module using "import"....

    it's probably a good idea to read through the 3ds script and work out which function is the main one so you can call it without needing the ui!
    Mike Williamson
    www.cowtoolsmedia.co.uk



  3. #3
    Originally Posted by Michael W View Post
    the 3ds importer is just another python script.

    load it as a module using "import"....

    it's probably a good idea to read through the 3ds script and work out which function is the main one so you can call it without needing the ui!
    I have found the script "3ds_import.py", but I don't know how can i use. I have done import 3ds_import.py, but I have an error.

    Can anybody help me? Thanks.



  4. #4
    Member Michael W's Avatar
    Join Date
    Nov 2007
    Location
    UK
    Posts
    4,992
    if i recall you use
    import 3ds_import
    ie no .py on the end....
    then you can access functions within using a "." and function name....
    3ds_import.main
    which will open a filebrowser to select the file to import

    or
    3ds_import.load_3ds(filename, context, IMPORT_CONSTRAIN_BOUNDS=10.0, IMAGE_SEARCH=True, APPLY_MATRIX=False)
    which will need you to pass a filename to open and the context....

    PS the filename will be a complete path to the file or a relative path from the working directory....
    Mike Williamson
    www.cowtoolsmedia.co.uk



  5. #5
    import Blender as B
    import 3ds_import

    class MyLoad:

    def __init__(self):

    def run(self):
    print "Hello world"

    Carga = MyLoad()
    Carga.run()

    This is my code, but I have a invalid syntax error in the 2nd line, on the import.

    Thanks for your help and sorry for my bad english



  6. #6
    Member Michael W's Avatar
    Join Date
    Nov 2007
    Location
    UK
    Posts
    4,992
    are you writing for 2.5 or 2.49?


    in 2.5 you can:

    bpy.ops.import_scene.autodesk_3ds()

    http://www.blender.org/documentation...e.autodesk_3ds

    I'll have a look at 2.49 where you'd have to import the py script
    Mike Williamson
    www.cowtoolsmedia.co.uk



  7. #7
    I am in 2.49...
    Thanks!!



  8. #8
    Member Michael W's Avatar
    Join Date
    Nov 2007
    Location
    UK
    Posts
    4,992
    the "import" command doesn't like the 3 at the start of the script name... also it seems to want it in the root of the scripts folder,(i had it in a symbollic-linked sub folder)

    I suggest you copy it to the right place and rename it (eg "autodesk_import") and then in your script you should be able to use
    import autodesk_import as ai

    filename = '/mypathto/myfile.3ds"
    ai.load_3ds(filename, PREF_UI= True)
    Mike Williamson
    www.cowtoolsmedia.co.uk



  9. #9
    Where I have to put the 3ds? In the same folder that i have the .blend file? Or all the path to the file (C:\\....)

    Thanks for your help!!

    Edit: I have solve the problem!!
    Last edited by aske; 07-May-10 at 02:29.



  10. #10
    And what was the solution? can you show the code?



  11. #11
    Member
    Join Date
    Jun 2009
    Location
    madrid, spain
    Posts
    5
    Originally Posted by ederhazael View Post
    And what was the solution? can you show the code?
    try this...
    Code:
    import bpy
    bpy.ops.import_scene.autodesk_3ds(filepath = 'path/to/your/file.3DS', axis_forward='-Y', axis_up='Z', constrain_size=10, use_image_search=True, use_apply_transform=True)
    You can change "axis_forward" and "axis_up" values if the models appear rotated.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •