Blender cmod export script (updated)

Post requests, images, descriptions and reports about work in progress here.
Topic author
cartrite
Posts: 1725
Joined: 15.09.2005
With us: 13 years 4 months
Location: Pocono Mountains, Pennsylvania, USA

Blender cmod export script (updated)

Post #1by cartrite » 17.09.2009, 12:44

After I redid the cmod export script while working with John Van Vliet last week, I decided to try and take it one step further. This script has been tested on a model from the Celestia Motherlode called sts-67. I didn't change anything, I just imported the 3ds file and saved it as a blend file. Then I exported it. This model had 644 meshes and 644 material definitions. If this is not correct, let me know. So the script should be able to export almost anything. Let me know if it doesn't. This script assigns UV textures to each mesh in the cmod file with material indexing. It also assigns diffuse and specular colors to each mesh.

A problem that I still have seems to be with this model and the way Blender imports the 3ds file. Some of the normals get flipped. So the bay doors (as seen from above) and parts of the nose are invisible. I could probably edit the file and flip the normals, but that has nothing to do with the export script.

EDIT. I found problems when I worked with the Atlantis model so I deleted the script. Back to the drawing board. I'll upload it again after it passes further tests.
cartrite
Toshiba Satellite P875=S7200 laptop, Intel i5 processor 2.5 ghz 6 gb ram, Graphics Intel(R) HD Graphics 4000 openSUSE Leap42.3
and Tumbleweed

Topic author
cartrite
Posts: 1725
Joined: 15.09.2005
With us: 13 years 4 months
Location: Pocono Mountains, Pennsylvania, USA

Re: Blender cmod export script (updated)

Post #2by cartrite » 17.09.2009, 18:55

This was tested with Endeavour, Atlantis, and the Asgard Warship. All from the Motherlode. Endeavour came in first place with 644 meshes and materials. 8O :D
Then came Atlantis. That package had 3 models. Normal and in space had 215 meshes and materials. Cargo doors open had 222 meshes and materials. The launch vehicle had 261. The Asgard Warship had 51 meshes and materials. There are probably some 3ds files or blend files that will fail but it's better now than it has been. It should probably do planets just as well. Did John Van Vliet's phobos blend model without any problems.
viewtopic.php?p=117793#p117793
This file was last updated on Sun September 20, 2009.
Updates include a warning for file overwrites and abilities to export more materials. These include emissive, specpower, and opacity. More overwrite protection.

cartrite
Last edited by cartrite on 20.09.2009, 14:13, edited 6 times in total.
Toshiba Satellite P875=S7200 laptop, Intel i5 processor 2.5 ghz 6 gb ram, Graphics Intel(R) HD Graphics 4000 openSUSE Leap42.3
and Tumbleweed

Vorthon
Posts: 26
Joined: 21.04.2009
Age: 25
With us: 9 years 8 months

Re: Blender cmod export script (updated)

Post #3by Vorthon » 18.09.2009, 12:18

Just one question: Would I just be able to throw somehing together in blender and use the script without saving? Just curious.

Topic author
cartrite
Posts: 1725
Joined: 15.09.2005
With us: 13 years 4 months
Location: Pocono Mountains, Pennsylvania, USA

Re: Blender cmod export script (updated)

Post #4by cartrite » 18.09.2009, 13:09

Vorthon wrote:Just one question: Would I just be able to throw somehing together in blender and use the script without saving? Just curious.
I'm not sure what you mean. If you create a model in Blender from scratch, you save it as a .blend file, right? This script doesn't change the blend file unless you change the default name to a file that already exists. It automatically appends a .cmod extension unless you remove that extension. It removes the .blend extension. In other words, if you have a file called foo.blend and want to create foo.cmod, just run the export script. It will automatically remove the .blend and put .cmod in it's place. Now if you change that automatically produced filename, it will overwrite/destroy a file if it already exists. So be careful here. I'll look into adding overwrite protection. But that protection will only be a confirm overwrite tab. I may be able to automatically rename the file so no overwrites are possible. I'll look into this also. Currently, if you already had a file called foo.cmod, it will overwrite it. So be careful here too.
cartrite
Toshiba Satellite P875=S7200 laptop, Intel i5 processor 2.5 ghz 6 gb ram, Graphics Intel(R) HD Graphics 4000 openSUSE Leap42.3
and Tumbleweed

Vorthon
Posts: 26
Joined: 21.04.2009
Age: 25
With us: 9 years 8 months

Re: Blender cmod export script (updated)

Post #5by Vorthon » 18.09.2009, 13:56

cartrite wrote:
Vorthon wrote:Just one question: Would I just be able to throw somehing together in blender and use the script without saving? Just curious.
I'm not sure what you mean. If you create a model in Blender from scratch, you save it as a .blend file, right? This script doesn't change the blend file unless you change the default name to a file that already exists. It automatically appends a .cmod extension unless you remove that extension. It removes the .blend extension. In other words, if you have a file called foo.blend and want to create foo.cmod, just run the export script. It will automatically remove the .blend and put .cmod in it's place. Now if you change that automatically produced filename, it will overwrite/destroy a file if it already exists. So be careful here. I'll look into adding overwrite protection. But that protection will only be a confirm overwrite tab. I may be able to automatically rename the file so no overwrites are possible. I'll look into this also. Currently, if you already had a file called foo.cmod, it will overwrite it. So be careful here too.
cartrite

What I meant was, If I used the script after making a model from scratch but before saving it.

Topic author
cartrite
Posts: 1725
Joined: 15.09.2005
With us: 13 years 4 months
Location: Pocono Mountains, Pennsylvania, USA

Re: Blender cmod export script (updated)

Post #6by cartrite » 18.09.2009, 14:24

What I meant was, If I used the script after making a model from scratch but before saving it.
That is a dangerous practice. Why would you want to do that? I would save the file in blend format before running anything on it. Then you can export it.
For some 3ds models, the model disappeared after exporting so I had to open it again. This doesn't happen with all models and I'm not sure why it happens. Probably because the models I tested were not completely imported into Blender. Object Mode was the only mode available. It hasn't happened with a fully imported functional model.
cartrite
Toshiba Satellite P875=S7200 laptop, Intel i5 processor 2.5 ghz 6 gb ram, Graphics Intel(R) HD Graphics 4000 openSUSE Leap42.3
and Tumbleweed

Topic author
cartrite
Posts: 1725
Joined: 15.09.2005
With us: 13 years 4 months
Location: Pocono Mountains, Pennsylvania, USA

Re: Blender cmod export script (updated)

Post #7by cartrite » 19.09.2009, 16:12

The script was updated today. The updates included a warning for file overwrites, emissive export, specpower export, and opacity export.
cartrite
Toshiba Satellite P875=S7200 laptop, Intel i5 processor 2.5 ghz 6 gb ram, Graphics Intel(R) HD Graphics 4000 openSUSE Leap42.3
and Tumbleweed

Topic author
cartrite
Posts: 1725
Joined: 15.09.2005
With us: 13 years 4 months
Location: Pocono Mountains, Pennsylvania, USA

Re: Blender cmod export script (updated)

Post #8by cartrite » 20.09.2009, 14:10

Updated again on Sunday. This will probably be the last update for a while. But I am going to keep playing around with it. The next thing I want to do is create a QT4 GUI using PyQT4. It will also default to using Blender's FileSelector Window if PyQT4 is not available. I hope. Anyhow this update has more overwrite protection. The Blender File Selector should open up in the current working directory with a default filename called 'untitled.cmod'. If you have a file that is currently being worked on, it will open up with that basename - the .blend extension and + .cmod extension. If the file already exists, it will automatically add a _# before the extension. Where # is a number beyond the latest number. So if you have a file called foo.cmod, it will display foo_1.cmod. If you already have foo_1.cmod, foo_2.cmod will be displayed and so on. If you change the name, it will be possible to change it to another file that already exists. In that case, an overwrite warning should be displayed. If you click on that warning the file will be overwritten. If you move the cursor off of the warning, it should return to the window without overwriting.
blender-cmod-exporter-2.zip


cartrite
Last edited by cartrite on 24.09.2009, 20:26, edited 17 times in total.
Toshiba Satellite P875=S7200 laptop, Intel i5 processor 2.5 ghz 6 gb ram, Graphics Intel(R) HD Graphics 4000 openSUSE Leap42.3
and Tumbleweed

BobHegwood
Posts: 1803
Joined: 12.10.2007
With us: 11 years 3 months

Re: Blender cmod export script (updated)

Post #9by BobHegwood » 20.09.2009, 18:26

Don't know if I will *ever* be smart enough to figure out how to use Blender correctly, but I
would just like to express my sincere appreciation for all you are doing here, Cartrite. :wink:

Much appreciated by the Brain-Dead (and I'm sure, others.)
Brain-Dead Geezer Bob is now using...
Windows Vista Home Premium, 64-bit on a
Gateway Pentium Dual-Core CPU E5200, 2.5GHz
7 GB RAM, 500 GB hard disk, Nvidia GeForce 7100
Nvidia nForce 630i, 1680x1050 screen, Latest SVN

Avatar
John Van Vliet
Posts: 2700
Joined: 28.08.2002
With us: 16 years 4 months

Re: Blender cmod export script (updated)

Post #10by John Van Vliet » 21.09.2009, 20:10

--- edit ---
Last edited by John Van Vliet on 20.10.2013, 07:56, edited 1 time in total.

Topic author
cartrite
Posts: 1725
Joined: 15.09.2005
With us: 13 years 4 months
Location: Pocono Mountains, Pennsylvania, USA

Re: Blender cmod export script (updated)

Post #11by cartrite » 22.09.2009, 01:12

Updated again, Monday September 21, 2009.
There was still one thing that bugged me. Blender's File Selection Window can be tricky sometimes. I had gotten careless a few times and overwrote a good file .blend and destroyed it. So I added one more layer of protection from overwrites. Now a backup will be created with a "~" character affixed to the end of the original file. If a name is changed to a Blender .blend file, it will back that up with a "2" affixed to the end. I uploaded the new file to my previous post.
viewtopic.php?p=117793#p117793
cartrite
Toshiba Satellite P875=S7200 laptop, Intel i5 processor 2.5 ghz 6 gb ram, Graphics Intel(R) HD Graphics 4000 openSUSE Leap42.3
and Tumbleweed

Topic author
cartrite
Posts: 1725
Joined: 15.09.2005
With us: 13 years 4 months
Location: Pocono Mountains, Pennsylvania, USA

Re: Blender cmod export script (updated)

Post #12by cartrite » 23.09.2009, 03:22

Updated again, Tuesday September 22, 2009.
I decided on a different approach to file overwrite protection. Make it impossible. :wink: I decided to rename the file after the export button has been pushed. If a possible overwrite occurs, the script will put a number _ extension at the end of the file. If you run Blender from a terminal, a message will be printed out telling you the new name of the file. If it ever fails, let me know. There are also 3 other messages that should be printed on the terminal every time. There is a counter for materials, meshes, and a test counter. These 3 counters that should all match or something went wrong with the export.

I did get a GTK gui to partially work. I can use the GTK File Chooser to select the filename. QT4 has a ways to go yet though.
I probably won't be uploading them anytime soon though.
The newest file is still here.
viewtopic.php?p=117793#p117793
cartrite
Toshiba Satellite P875=S7200 laptop, Intel i5 processor 2.5 ghz 6 gb ram, Graphics Intel(R) HD Graphics 4000 openSUSE Leap42.3
and Tumbleweed

swright
Posts: 2
Joined: 21.05.2010
With us: 8 years 7 months

Re: Blender cmod export script (updated)

Post #13by swright » 24.05.2010, 02:27

I know this is a fairly old posting, but I would like a bit of support, either from the original author of the plug-in script, or anyone who has sufficient experience with Python to assist. When using the script offered above, I get the following error from Blender (ver. 2.6.2)...

error text from console

Code: Select all

Traceback <most recent call last>:
  File "<string>", line 1, in <module>
  File "C:\...\scripts\cmod-exports-mesh.py", line 338, in <module> main()
  File "C:\...\scripts\cmod-exports-mesh.py", line 306, in main path_dir = '%s' % os.environ['PWD']
  File "C:\...\Blender\python26.zip\os.py", line 423, in __getitem__
    return self.data[key.upper()]
KeyError: 'PWD'
Note: script paths abbreviated

System OS is Windows XP, SP3 under a single core P4 @ 1.8 GHz. I've provided the code for both the export script and os.py, which seems to be where the problem manifests itself to the compiler. Note that os.py ships with the 2.6.2 package and appears to be an os platform handling script.

cmod-export-mesh.py

Code: Select all

#!BPY

"""
Name: 'CMOD-export-mesh (.cmod)...'
Blender: 248
Group: 'Export'
Tooltip: 'cmod exporter'
"""

# ***** BEGIN GPL LICENSE BLOCK *****
#
# Script copyright (C) Stephen Popovich 2009
# Insights were gained by reading/using parts of export_obj.py
# written by "Campbell Barton, Jiri Hnidek, Paolo Ciccone"
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#
# ***** END GPL LICENCE BLOCK *****
# --------------------------------------------------------------------------


import Blender
from Blender import *
import BPyMessages
import sys, os

def write_file(filename):
   count1 = 0
   count2 = 0
   count3 = 0

   out = open(filename, "w")
   out.write('#celmodel__ascii\n')
   objects = Blender.Object.GetSelected()
   for object in objects:
#   parts were written by "Campbell Barton, Jiri Hnidek, Paolo Ciccone" export_obj.py
#   ************************************************************************
      mesh = Mesh.Get(object.name)
      materials = mesh.materials
      materialNames = []
      materialItems = materials[:]
      count1a = 0
      for f in mesh.faces:
         for mat in materials:
            if mat:
               materialNames.append(mat.name)
            else:
               materialNames.append(None)
         materialNames.extend((16-len(materialNames)) * [None])
         materialItems.extend((16-len(materialItems)) * [None])
#   ************************************************************************
         idx_mat = min(f.mat, len(materialNames)-1)
         if mesh.faceUV:
            image = f.image
         else:
            image = None
         if image:
            img = ('%s' % (image.name))
         else:
            img = None
         mat = materialItems[idx_mat]
         if mat:
            if mat.emit > 0:
               dif_r = (mat.emit*mat.rgbCol[0])
               dif_g = (mat.emit*mat.rgbCol[1])
               dif_b = (mat.emit*mat.rgbCol[2])
               spec_r = (mat.spec*mat.specCol[0])
               spec_g = (mat.spec*mat.specCol[1])
               spec_b = (mat.spec*mat.specCol[2])
               if mat.hard > 0:
                  spec_pwr = (mat.hard)
               if mat.alpha:
                  opac_a = (mat.alpha)
            else:
               dif_r = (mat.ref*mat.rgbCol[0])
               dif_g = (mat.ref*mat.rgbCol[1])
               dif_b = (mat.ref*mat.rgbCol[2])
               spec_r = (mat.spec*mat.specCol[0])
               spec_g = (mat.spec*mat.specCol[1])
               spec_b = (mat.spec*mat.specCol[2])
               if mat.hard > 0:
                  spec_pwr = (mat.hard)
               if mat.alpha:
                  opac_a = (mat.alpha)
         else:
            dif_r = 0.8
            dif_g = 0.8
            dif_b = 0.8
            spec_r = 0.5
            spec_g = 0.5
            spec_b = 0.5
         if mesh.faceUV:
            if (count1a < 1):
               if img:
                  out.write('\n')
                  out.write('material\n')
                  out.write('texture0 "%s"\n' % (img))
                  if mat.emit > 0:
                     out.write('emissive %f %f %f\n' % (dif_r, dif_g, dif_b))
                  else:
                     out.write('diffuse %f %f %f\n' % (dif_r, dif_g, dif_b))
                  out.write('specular %f %f %f\n' % (spec_r, spec_g, spec_b))
                  if mat.hard > 0:
                     out.write('specpower %f\n' % (spec_pwr))
                  if mat.alpha < 1:
                     out.write('opacity %f\n' % (opac_a))
                  out.write('end_material\n')
                  count1 +=1
                  count1a +=1
               elif mat:
                  for mtex in mat.getTextures():
                     if mtex and mtex.tex.type == Blender.Texture.Types.IMAGE and count1a < 1:
                        filename = mtex.tex.image.filename.split('\\')[-1].split('/')[-1]
                        out.write('\n')
                        out.write('material\n')
                        out.write('texture0 %s\n' % filename)
                        out.write('diffuse %f %f %f\n' % (dif_r, dif_g, dif_b))
                        out.write('specular %f %f %f\n' % (spec_r, spec_g, spec_b))
                        out.write('end_material\n')
                        count1 +=1
                        count1a +=1
                     elif count1a < 1:
                        out.write('\n')
                        out.write('material\n')
                        out.write('diffuse %f %f %f\n' % (dif_r, dif_g, dif_b))
                        out.write('specular %f %f %f\n' % (spec_r, spec_g, spec_b))
                        out.write('end_material\n')
                        count1 +=1
                        count1a +=1
               else:
                  out.write('\n')
                  out.write('material\n')
                  out.write('diffuse %f %f %f\n' % (dif_r, dif_g, dif_b))
                  out.write('specular %f %f %f\n' % (spec_r, spec_g, spec_b))
                  out.write('end_material\n')
                  count1 +=1
                  count1a +=1
         else:
            if (count1a < 1):
               if mat:
                  out.write('\n')
                  out.write('material\n')
                  if mat.emit > 0:
                     out.write('emissive %f %f %f\n' % (dif_r, dif_g, dif_b))
                  else:
                     out.write('diffuse %f %f %f\n' % (dif_r, dif_g, dif_b))
                  out.write('specular %f %f %f\n' % (spec_r, spec_g, spec_b))
                  if mat.hard > 0:
                     out.write('specpower %f\n' % (spec_pwr))
                  if mat.alpha < 1:
                     out.write('opacity %f\n' % (opac_a))
                  out.write('end_material\n')
                  count1 +=1
                  count1a +=1
               elif img and count1a < 1:
                  for mtex in mat.getTextures():
                     if mtex and mtex.tex.type == Blender.Texture.Types.IMAGE and count1a < 1:
                        filename = mtex.tex.image.filename.split('\\')[-1].split('/')[-1]
                        out.write('\n')
                        out.write('material\n')
                        out.write('texture0 %s\n' % filename)
                        out.write('diffuse %f %f %f\n' % (dif_r, dif_g, dif_b))
                        out.write('specular %f %f %f\n' % (spec_r, spec_g, spec_b))
                        out.write('end_material\n')
                        count1 +=1
                        count1a +=1
                     elif count1a < 1:
                        out.write('\n')
                        out.write('material\n')
                        out.write('diffuse %f %f %f\n' % (dif_r, dif_g, dif_b))
                        out.write('specular %f %f %f\n' % (spec_r, spec_g, spec_b))
                        out.write('end_material\n')
                        count1 +=1
                        count1a +=1
               else:
                  out.write('\n')
                  out.write('material\n')
                  out.write('diffuse %f %f %f\n' % (dif_r, dif_g, dif_b))
                  out.write('specular %f %f %f\n' % (spec_r, spec_g, spec_b))
                  out.write('end_material\n')
                  count1 +=1
                  count1a +=1

      count3 +=1
   print "materials = %i" % count1
   print "test = %i" % count3
   
   e = -1
   objects = Blender.Object.GetSelected()
   for object in objects:   
      mesh = Mesh.Get(object.name)
      mesh.transform(object.matrix)
      mesh.calcNormals()
      a = 0
      b = 0
      c = 0
      d = 0

      out.write('\n')
      out.write('mesh\n')
      out.write('vertexdesc\n')
      out.write('position f3\n')
      out.write('normal f3\n')
      count2 +=1
      if mesh.faceUV:
         out.write('texcoord0 f2\n')
      out.write('end_vertexdesc\n\n')
        #counter for vertice desc
        #This part goes thru the list twice counting for a the verts 1,2,3 and 0,1,2
        #it counts the number of triangles to build.
      for face in mesh.faces:
         d = 0
              for vert in face.verts:
            if d > 2:
               a +=3
               d +=1
            else:
               a +=1
               d +=1
      out.write( 'vertices %i\n' % (a))

        # writes a line for verts 2,3,0 and 0,1,2.
      for face in mesh.faces:
         d = 0
         for vert in face.verts:
            if d > 2:
               out.write( '%f %f %f %f %f %f' % (face.verts[2].co.x, face.verts[2].co.y, face.verts[2].co.z, face.verts[2].no.x, face.verts[2].no.y, face.verts[2].no.z,))
               if mesh.faceUV:
                  out.write( ' %f %f\n' % (face.uv[2].x, face.uv[2].y))
               else:
                  out.write( '\n')
               out.write( '%f %f %f %f %f %f' % (face.verts[d].co.x, face.verts[d].co.y, face.verts[d].co.z, face.verts[d].no.x, face.verts[d].no.y, face.verts[d].no.z,))
               if mesh.faceUV:
                  out.write( ' %f %f\n' % (face.uv[d].x, face.uv[d].y))
               else:
                  out.write( '\n')
               out.write( '%f %f %f %f %f %f' % (face.verts[0].co.x, face.verts[0].co.y, face.verts[0].co.z, face.verts[0].no.x, face.verts[0].no.y, face.verts[0].no.z,))
               if mesh.faceUV:
                  out.write( ' %f %f\n' % (face.uv[0].x, face.uv[0].y))
               else:
                  out.write( '\n')
            else:
               out.write( '%f %f %f %f %f %f' % (face.verts[d].co.x, face.verts[d].co.y,    face.verts[d].co.z, face.verts[d].no.x, face.verts[d].no.y, face.verts[d].no.z,))
               if mesh.faceUV:
                  out.write( ' %f %f\n' % (face.uv[d].x, face.uv[d].y))
               else:
                  out.write( '\n')   
            d +=1
      e +=1
      out.write( '\n\ntrilist %i %i\n' % (e, a))
        #write the triangle list 12 per line, e is the trilist material index
      while b < a:
         if c <= 12:
            if b <= a:
               out.write( '%i ' % (b))
               b +=1
               c +=1
            else:
               out.write( '\n' )
         else:
            out.write( '\n' )
            c = 0
      out.write( '\nend_mesh\n' )
   out.close()
   print "meshes = %i" % count2

def chk_name(filename):
   filename_new = filename
   if not filename.lower().endswith('.cmod'):
      filename += '.cmod'
      filename_new += '.cmod'
   x = 0
   switch = 0
   
   if not BPyMessages.Warning_SaveOver(filename):
      return

   if os.path.exists(filename) == True:
      switch = 1
      while switch > 0:
         if os.path.exists(filename_new) == True:
            x +=1
            filename1, ext = os.path.splitext(filename)
            filename_new = filename1 + ('_%i.cmod' % x)
         else:
            switch = 0
            print 'Your file has been renamed to %s' % filename_new
            write_file(filename_new)
   else:
      write_file(filename)

def main():
   file_name = Blender.Get('filename')
   path_dir = '%s' % os.environ['PWD']
   if os.path.isdir(path_dir):
      if os.path.isfile(file_name):
         name = Blender.Get('filename')
         name, ext = os.path.splitext(name)
         file_name = name
      else:
         file_name = 'untitled'
   else:
      Blender.Window.FileSelector(chk_name, "Export", Blender.sys.makename(ext='.cmod'))

   filename = os.path.join(path_dir, file_name)
   filename_new = os.path.join(path_dir, file_name)
   if not filename.lower().endswith('.cmod'):
      filename += '.cmod'
      filename_new += '.cmod'
   x = 0
   switch = 0
   if os.path.exists(filename) == True:
      switch = 1
      while switch > 0:
         if os.path.exists(filename_new) == True:
            x +=1
            filename1, ext = os.path.splitext(filename)
            filename_new = filename1 + ('_%i.cmod' % x)
            print filename_new
         else:
            switch = 0
            Blender.Window.FileSelector(chk_name, "Export", filename_new)
   else:
      Blender.Window.FileSelector(chk_name, "Export", filename)
if __name__=='__main__':
   main()


os.py

Code: Select all

r"""OS routines for Mac, NT, or Posix depending on what system we're on.

This exports:
  - all functions from posix, nt, os2, or ce, e.g. unlink, stat, etc.
  - os.path is one of the modules posixpath, or ntpath
  - os.name is 'posix', 'nt', 'os2', 'ce' or 'riscos'
  - os.curdir is a string representing the current directory ('.' or ':')
  - os.pardir is a string representing the parent directory ('..' or '::')
  - os.sep is the (or a most common) pathname separator ('/' or ':' or '\\')
  - os.extsep is the extension separator ('.' or '/')
  - os.altsep is the alternate pathname separator (None or '/')
  - os.pathsep is the component separator used in $PATH etc
  - os.linesep is the line separator in text files ('\r' or '\n' or '\r\n')
  - os.defpath is the default search path for executables
  - os.devnull is the file path of the null device ('/dev/null', etc.)

Programs that import and use 'os' stand a better chance of being
portable between different platforms.  Of course, they must then
only use functions that are defined by all platforms (e.g., unlink
and opendir), and leave all pathname manipulation to os.path
(e.g., split and join).
"""

#'

import sys, errno

_names = sys.builtin_module_names

# Note:  more names are added to __all__ later.
__all__ = ["altsep", "curdir", "pardir", "sep", "extsep", "pathsep", "linesep",
           "defpath", "name", "path", "devnull",
           "SEEK_SET", "SEEK_CUR", "SEEK_END"]

def _get_exports_list(module):
    try:
        return list(module.__all__)
    except AttributeError:
        return [n for n in dir(module) if n[0] != '_']

if 'posix' in _names:
    name = 'posix'
    linesep = '\n'
    from posix import *
    try:
        from posix import _exit
    except ImportError:
        pass
    import posixpath as path

    import posix
    __all__.extend(_get_exports_list(posix))
    del posix

elif 'nt' in _names:
    name = 'nt'
    linesep = '\r\n'
    from nt import *
    try:
        from nt import _exit
    except ImportError:
        pass
    import ntpath as path

    import nt
    __all__.extend(_get_exports_list(nt))
    del nt

elif 'os2' in _names:
    name = 'os2'
    linesep = '\r\n'
    from os2 import *
    try:
        from os2 import _exit
    except ImportError:
        pass
    if sys.version.find('EMX GCC') == -1:
        import ntpath as path
    else:
        import os2emxpath as path
        from _emx_link import link

    import os2
    __all__.extend(_get_exports_list(os2))
    del os2

elif 'ce' in _names:
    name = 'ce'
    linesep = '\r\n'
    from ce import *
    try:
        from ce import _exit
    except ImportError:
        pass
    # We can use the standard Windows path.
    import ntpath as path

    import ce
    __all__.extend(_get_exports_list(ce))
    del ce

elif 'riscos' in _names:
    name = 'riscos'
    linesep = '\n'
    from riscos import *
    try:
        from riscos import _exit
    except ImportError:
        pass
    import riscospath as path

    import riscos
    __all__.extend(_get_exports_list(riscos))
    del riscos

else:
    raise ImportError, 'no os specific module found'

sys.modules['os.path'] = path
from os.path import (curdir, pardir, sep, pathsep, defpath, extsep, altsep,
    devnull)

del _names

# Python uses fixed values for the SEEK_ constants; they are mapped
# to native constants if necessary in posixmodule.c
SEEK_SET = 0
SEEK_CUR = 1
SEEK_END = 2

#'

# Super directory utilities.
# (Inspired by Eric Raymond; the doc strings are mostly his)

def makedirs(name, mode=0777):
    """makedirs(path [, mode=0777])

    Super-mkdir; create a leaf directory and all intermediate ones.
    Works like mkdir, except that any intermediate path segment (not
    just the rightmost) will be created if it does not exist.  This is
    recursive.

    """
    head, tail = path.split(name)
    if not tail:
        head, tail = path.split(head)
    if head and tail and not path.exists(head):
        try:
            makedirs(head, mode)
        except OSError, e:
            # be happy if someone already created the path
            if e.errno != errno.EEXIST:
                raise
        if tail == curdir:           # xxx/newdir/. exists if xxx/newdir exists
            return
    mkdir(name, mode)

def removedirs(name):
    """removedirs(path)

    Super-rmdir; remove a leaf directory and all empty intermediate
    ones.  Works like rmdir except that, if the leaf directory is
    successfully removed, directories corresponding to rightmost path
    segments will be pruned away until either the whole path is
    consumed or an error occurs.  Errors during this latter phase are
    ignored -- they generally mean that a directory was not empty.

    """
    rmdir(name)
    head, tail = path.split(name)
    if not tail:
        head, tail = path.split(head)
    while head and tail:
        try:
            rmdir(head)
        except error:
            break
        head, tail = path.split(head)

def renames(old, new):
    """renames(old, new)

    Super-rename; create directories as necessary and delete any left
    empty.  Works like rename, except creation of any intermediate
    directories needed to make the new pathname good is attempted
    first.  After the rename, directories corresponding to rightmost
    path segments of the old name will be pruned way until either the
    whole path is consumed or a nonempty directory is found.

    Note: this function can fail with the new directory structure made
    if you lack permissions needed to unlink the leaf directory or
    file.

    """
    head, tail = path.split(new)
    if head and tail and not path.exists(head):
        makedirs(head)
    rename(old, new)
    head, tail = path.split(old)
    if head and tail:
        try:
            removedirs(head)
        except error:
            pass

__all__.extend(["makedirs", "removedirs", "renames"])

def walk(top, topdown=True, onerror=None, followlinks=False):
    """Directory tree generator.

    For each directory in the directory tree rooted at top (including top
    itself, but excluding '.' and '..'), yields a 3-tuple

        dirpath, dirnames, filenames

    dirpath is a string, the path to the directory.  dirnames is a list of
    the names of the subdirectories in dirpath (excluding '.' and '..').
    filenames is a list of the names of the non-directory files in dirpath.
    Note that the names in the lists are just names, with no path components.
    To get a full path (which begins with top) to a file or directory in
    dirpath, do os.path.join(dirpath, name).

    If optional arg 'topdown' is true or not specified, the triple for a
    directory is generated before the triples for any of its subdirectories
    (directories are generated top down).  If topdown is false, the triple
    for a directory is generated after the triples for all of its
    subdirectories (directories are generated bottom up).

    When topdown is true, the caller can modify the dirnames list in-place
    (e.g., via del or slice assignment), and walk will only recurse into the
    subdirectories whose names remain in dirnames; this can be used to prune
    the search, or to impose a specific order of visiting.  Modifying
    dirnames when topdown is false is ineffective, since the directories in
    dirnames have already been generated by the time dirnames itself is
    generated.

    By default errors from the os.listdir() call are ignored.  If
    optional arg 'onerror' is specified, it should be a function; it
    will be called with one argument, an os.error instance.  It can
    report the error to continue with the walk, or raise the exception
    to abort the walk.  Note that the filename is available as the
    filename attribute of the exception object.

    By default, os.walk does not follow symbolic links to subdirectories on
    systems that support them.  In order to get this functionality, set the
    optional argument 'followlinks' to true.

    Caution:  if you pass a relative pathname for top, don't change the
    current working directory between resumptions of walk.  walk never
    changes the current directory, and assumes that the client doesn't
    either.

    Example:

    import os
    from os.path import join, getsize
    for root, dirs, files in os.walk('python/Lib/email'):
        print root, "consumes",
        print sum([getsize(join(root, name)) for name in files]),
        print "bytes in", len(files), "non-directory files"
        if 'CVS' in dirs:
            dirs.remove('CVS')  # don't visit CVS directories
    """

    from os.path import join, isdir, islink

    # We may not have read permission for top, in which case we can't
    # get a list of the files the directory contains.  os.path.walk
    # always suppressed the exception then, rather than blow up for a
    # minor reason when (say) a thousand readable directories are still
    # left to visit.  That logic is copied here.
    try:
        # Note that listdir and error are globals in this module due
        # to earlier import-*.
        names = listdir(top)
    except error, err:
        if onerror is not None:
            onerror(err)
        return

    dirs, nondirs = [], []
    for name in names:
        if isdir(join(top, name)):
            dirs.append(name)
        else:
            nondirs.append(name)

    if topdown:
        yield top, dirs, nondirs
    for name in dirs:
        path = join(top, name)
        if followlinks or not islink(path):
            for x in walk(path, topdown, onerror, followlinks):
                yield x
    if not topdown:
        yield top, dirs, nondirs

__all__.append("walk")

# Make sure os.environ exists, at least
try:
    environ
except NameError:
    environ = {}

def execl(file, *args):
    """execl(file, *args)

    Execute the executable file with argument list args, replacing the
    current process. """
    execv(file, args)

def execle(file, *args):
    """execle(file, *args, env)

    Execute the executable file with argument list args and
    environment env, replacing the current process. """
    env = args[-1]
    execve(file, args[:-1], env)

def execlp(file, *args):
    """execlp(file, *args)

    Execute the executable file (which is searched for along $PATH)
    with argument list args, replacing the current process. """
    execvp(file, args)

def execlpe(file, *args):
    """execlpe(file, *args, env)

    Execute the executable file (which is searched for along $PATH)
    with argument list args and environment env, replacing the current
    process. """
    env = args[-1]
    execvpe(file, args[:-1], env)

def execvp(file, args):
    """execp(file, args)

    Execute the executable file (which is searched for along $PATH)
    with argument list args, replacing the current process.
    args may be a list or tuple of strings. """
    _execvpe(file, args)

def execvpe(file, args, env):
    """execvpe(file, args, env)

    Execute the executable file (which is searched for along $PATH)
    with argument list args and environment env , replacing the
    current process.
    args may be a list or tuple of strings. """
    _execvpe(file, args, env)

__all__.extend(["execl","execle","execlp","execlpe","execvp","execvpe"])

def _execvpe(file, args, env=None):
    if env is not None:
        func = execve
        argrest = (args, env)
    else:
        func = execv
        argrest = (args,)
        env = environ

    head, tail = path.split(file)
    if head:
        func(file, *argrest)
        return
    if 'PATH' in env:
        envpath = env['PATH']
    else:
        envpath = defpath
    PATH = envpath.split(pathsep)
    saved_exc = None
    saved_tb = None
    for dir in PATH:
        fullname = path.join(dir, file)
        try:
            func(fullname, *argrest)
        except error, e:
            tb = sys.exc_info()[2]
            if (e.errno != errno.ENOENT and e.errno != errno.ENOTDIR
                and saved_exc is None):
                saved_exc = e
                saved_tb = tb
    if saved_exc:
        raise error, saved_exc, saved_tb
    raise error, e, tb

# Change environ to automatically call putenv() if it exists
try:
    # This will fail if there's no putenv
    putenv
except NameError:
    pass
else:
    import UserDict

    # Fake unsetenv() for Windows
    # not sure about os2 here but
    # I'm guessing they are the same.

    if name in ('os2', 'nt'):
        def unsetenv(key):
            putenv(key, "")

    if name == "riscos":
        # On RISC OS, all env access goes through getenv and putenv
        from riscosenviron import _Environ
    elif name in ('os2', 'nt'):  # Where Env Var Names Must Be UPPERCASE
        # But we store them as upper case
        class _Environ(UserDict.IterableUserDict):
            def __init__(self, environ):
                UserDict.UserDict.__init__(self)
                data = self.data
                for k, v in environ.items():
                    data[k.upper()] = v
            def __setitem__(self, key, item):
                putenv(key, item)
                self.data[key.upper()] = item
            def __getitem__(self, key):
                return self.data[key.upper()]
            try:
                unsetenv
            except NameError:
                def __delitem__(self, key):
                    del self.data[key.upper()]
            else:
                def __delitem__(self, key):
                    unsetenv(key)
                    del self.data[key.upper()]
                def clear(self):
                    for key in self.data.keys():
                        unsetenv(key)
                        del self.data[key]
                def pop(self, key, *args):
                    unsetenv(key)
                    return self.data.pop(key.upper(), *args)
            def has_key(self, key):
                return key.upper() in self.data
            def __contains__(self, key):
                return key.upper() in self.data
            def get(self, key, failobj=None):
                return self.data.get(key.upper(), failobj)
            def update(self, dict=None, **kwargs):
                if dict:
                    try:
                        keys = dict.keys()
                    except AttributeError:
                        # List of (key, value)
                        for k, v in dict:
                            self[k] = v
                    else:
                        # got keys
                        # cannot use items(), since mappings
                        # may not have them.
                        for k in keys:
                            self[k] = dict[k]
                if kwargs:
                    self.update(kwargs)
            def copy(self):
                return dict(self)

    else:  # Where Env Var Names Can Be Mixed Case
        class _Environ(UserDict.IterableUserDict):
            def __init__(self, environ):
                UserDict.UserDict.__init__(self)
                self.data = environ
            def __setitem__(self, key, item):
                putenv(key, item)
                self.data[key] = item
            def update(self,  dict=None, **kwargs):
                if dict:
                    try:
                        keys = dict.keys()
                    except AttributeError:
                        # List of (key, value)
                        for k, v in dict:
                            self[k] = v
                    else:
                        # got keys
                        # cannot use items(), since mappings
                        # may not have them.
                        for k in keys:
                            self[k] = dict[k]
                if kwargs:
                    self.update(kwargs)
            try:
                unsetenv
            except NameError:
                pass
            else:
                def __delitem__(self, key):
                    unsetenv(key)
                    del self.data[key]
                def clear(self):
                    for key in self.data.keys():
                        unsetenv(key)
                        del self.data[key]
                def pop(self, key, *args):
                    unsetenv(key)
                    return self.data.pop(key, *args)
            def copy(self):
                return dict(self)


    environ = _Environ(environ)

def getenv(key, default=None):
    """Get an environment variable, return None if it doesn't exist.
    The optional second argument can specify an alternate default."""
    return environ.get(key, default)
__all__.append("getenv")

def _exists(name):
    try:
        eval(name)
        return True
    except NameError:
        return False

# Supply spawn*() (probably only for Unix)
if _exists("fork") and not _exists("spawnv") and _exists("execv"):

    P_WAIT = 0
    P_NOWAIT = P_NOWAITO = 1

    # XXX Should we support P_DETACH?  I suppose it could fork()**2
    # and close the std I/O streams.  Also, P_OVERLAY is the same
    # as execv*()?

    def _spawnvef(mode, file, args, env, func):
        # Internal helper; func is the exec*() function to use
        pid = fork()
        if not pid:
            # Child
            try:
                if env is None:
                    func(file, args)
                else:
                    func(file, args, env)
            except:
                _exit(127)
        else:
            # Parent
            if mode == P_NOWAIT:
                return pid # Caller is responsible for waiting!
            while 1:
                wpid, sts = waitpid(pid, 0)
                if WIFSTOPPED(sts):
                    continue
                elif WIFSIGNALED(sts):
                    return -WTERMSIG(sts)
                elif WIFEXITED(sts):
                    return WEXITSTATUS(sts)
                else:
                    raise error, "Not stopped, signaled or exited???"

    def spawnv(mode, file, args):
        """spawnv(mode, file, args) -> integer

Execute file with arguments from args in a subprocess.
If mode == P_NOWAIT return the pid of the process.
If mode == P_WAIT return the process's exit code if it exits normally;
otherwise return -SIG, where SIG is the signal that killed it. """
        return _spawnvef(mode, file, args, None, execv)

    def spawnve(mode, file, args, env):
        """spawnve(mode, file, args, env) -> integer

Execute file with arguments from args in a subprocess with the
specified environment.
If mode == P_NOWAIT return the pid of the process.
If mode == P_WAIT return the process's exit code if it exits normally;
otherwise return -SIG, where SIG is the signal that killed it. """
        return _spawnvef(mode, file, args, env, execve)

    # Note: spawnvp[e] is't currently supported on Windows

    def spawnvp(mode, file, args):
        """spawnvp(mode, file, args) -> integer

Execute file (which is looked for along $PATH) with arguments from
args in a subprocess.
If mode == P_NOWAIT return the pid of the process.
If mode == P_WAIT return the process's exit code if it exits normally;
otherwise return -SIG, where SIG is the signal that killed it. """
        return _spawnvef(mode, file, args, None, execvp)

    def spawnvpe(mode, file, args, env):
        """spawnvpe(mode, file, args, env) -> integer

Execute file (which is looked for along $PATH) with arguments from
args in a subprocess with the supplied environment.
If mode == P_NOWAIT return the pid of the process.
If mode == P_WAIT return the process's exit code if it exits normally;
otherwise return -SIG, where SIG is the signal that killed it. """
        return _spawnvef(mode, file, args, env, execvpe)

if _exists("spawnv"):
    # These aren't supplied by the basic Windows code
    # but can be easily implemented in Python

    def spawnl(mode, file, *args):
        """spawnl(mode, file, *args) -> integer

Execute file with arguments from args in a subprocess.
If mode == P_NOWAIT return the pid of the process.
If mode == P_WAIT return the process's exit code if it exits normally;
otherwise return -SIG, where SIG is the signal that killed it. """
        return spawnv(mode, file, args)

    def spawnle(mode, file, *args):
        """spawnle(mode, file, *args, env) -> integer

Execute file with arguments from args in a subprocess with the
supplied environment.
If mode == P_NOWAIT return the pid of the process.
If mode == P_WAIT return the process's exit code if it exits normally;
otherwise return -SIG, where SIG is the signal that killed it. """
        env = args[-1]
        return spawnve(mode, file, args[:-1], env)


    __all__.extend(["spawnv", "spawnve", "spawnl", "spawnle",])


if _exists("spawnvp"):
    # At the moment, Windows doesn't implement spawnvp[e],
    # so it won't have spawnlp[e] either.
    def spawnlp(mode, file, *args):
        """spawnlp(mode, file, *args) -> integer

Execute file (which is looked for along $PATH) with arguments from
args in a subprocess with the supplied environment.
If mode == P_NOWAIT return the pid of the process.
If mode == P_WAIT return the process's exit code if it exits normally;
otherwise return -SIG, where SIG is the signal that killed it. """
        return spawnvp(mode, file, args)

    def spawnlpe(mode, file, *args):
        """spawnlpe(mode, file, *args, env) -> integer

Execute file (which is looked for along $PATH) with arguments from
args in a subprocess with the supplied environment.
If mode == P_NOWAIT return the pid of the process.
If mode == P_WAIT return the process's exit code if it exits normally;
otherwise return -SIG, where SIG is the signal that killed it. """
        env = args[-1]
        return spawnvpe(mode, file, args[:-1], env)


    __all__.extend(["spawnvp", "spawnvpe", "spawnlp", "spawnlpe",])


# Supply popen2 etc. (for Unix)
if _exists("fork"):
    if not _exists("popen2"):
        def popen2(cmd, mode="t", bufsize=-1):
            """Execute the shell command 'cmd' in a sub-process.  On UNIX, 'cmd'
            may be a sequence, in which case arguments will be passed directly to
            the program without shell intervention (as with os.spawnv()).  If 'cmd'
            is a string it will be passed to the shell (as with os.system()). If
            'bufsize' is specified, it sets the buffer size for the I/O pipes.  The
            file objects (child_stdin, child_stdout) are returned."""
            import warnings
            msg = "os.popen2 is deprecated.  Use the subprocess module."
            warnings.warn(msg, DeprecationWarning, stacklevel=2)

            import subprocess
            PIPE = subprocess.PIPE
            p = subprocess.Popen(cmd, shell=True, bufsize=bufsize,
                                 stdin=PIPE, stdout=PIPE, close_fds=True)
            return p.stdin, p.stdout
        __all__.append("popen2")

    if not _exists("popen3"):
        def popen3(cmd, mode="t", bufsize=-1):
            """Execute the shell command 'cmd' in a sub-process.  On UNIX, 'cmd'
            may be a sequence, in which case arguments will be passed directly to
            the program without shell intervention (as with os.spawnv()).  If 'cmd'
            is a string it will be passed to the shell (as with os.system()). If
            'bufsize' is specified, it sets the buffer size for the I/O pipes.  The
            file objects (child_stdin, child_stdout, child_stderr) are returned."""
            import warnings
            msg = "os.popen3 is deprecated.  Use the subprocess module."
            warnings.warn(msg, DeprecationWarning, stacklevel=2)

            import subprocess
            PIPE = subprocess.PIPE
            p = subprocess.Popen(cmd, shell=True, bufsize=bufsize,
                                 stdin=PIPE, stdout=PIPE, stderr=PIPE,
                                 close_fds=True)
            return p.stdin, p.stdout, p.stderr
        __all__.append("popen3")

    if not _exists("popen4"):
        def popen4(cmd, mode="t", bufsize=-1):
            """Execute the shell command 'cmd' in a sub-process.  On UNIX, 'cmd'
            may be a sequence, in which case arguments will be passed directly to
            the program without shell intervention (as with os.spawnv()).  If 'cmd'
            is a string it will be passed to the shell (as with os.system()). If
            'bufsize' is specified, it sets the buffer size for the I/O pipes.  The
            file objects (child_stdin, child_stdout_stderr) are returned."""
            import warnings
            msg = "os.popen4 is deprecated.  Use the subprocess module."
            warnings.warn(msg, DeprecationWarning, stacklevel=2)

            import subprocess
            PIPE = subprocess.PIPE
            p = subprocess.Popen(cmd, shell=True, bufsize=bufsize,
                                 stdin=PIPE, stdout=PIPE,
                                 stderr=subprocess.STDOUT, close_fds=True)
            return p.stdin, p.stdout
        __all__.append("popen4")

import copy_reg as _copy_reg

def _make_stat_result(tup, dict):
    return stat_result(tup, dict)

def _pickle_stat_result(sr):
    (type, args) = sr.__reduce__()
    return (_make_stat_result, args)

try:
    _copy_reg.pickle(stat_result, _pickle_stat_result, _make_stat_result)
except NameError: # stat_result may not exist
    pass

def _make_statvfs_result(tup, dict):
    return statvfs_result(tup, dict)

def _pickle_statvfs_result(sr):
    (type, args) = sr.__reduce__()
    return (_make_statvfs_result, args)

try:
    _copy_reg.pickle(statvfs_result, _pickle_statvfs_result,
                     _make_statvfs_result)
except NameError: # statvfs_result may not exist
    pass

if not _exists("urandom"):
    def urandom(n):
        """urandom(n) -> str

        Return a string of n random bytes suitable for cryptographic use.

        """
        try:
            _urandomfd = open("/dev/urandom", O_RDONLY)
        except (OSError, IOError):
            raise NotImplementedError("/dev/urandom (or equivalent) not found")
        try:
            bs = b""
            while n - len(bs) >= 1:
                bs += read(_urandomfd, n - len(bs))
        finally:
            close(_urandomfd)
        return bs


Any assistance in figuring this out would be greatly appreciated. My Python experience is extremely limited.

SWright
Windows XP SP3,Pentium 4 1.8Ghz 1.5gb ram, ATI Radeon HD 3650, 1gb DDR2 ram

Avatar
John Van Vliet
Posts: 2700
Joined: 28.08.2002
With us: 16 years 4 months

Re: Blender cmod export script (updated)

Post #14by John Van Vliet » 24.05.2010, 03:41

--- edit ---
Last edited by John Van Vliet on 20.10.2013, 07:56, edited 1 time in total.

Topic author
cartrite
Posts: 1725
Joined: 15.09.2005
With us: 13 years 4 months
Location: Pocono Mountains, Pennsylvania, USA

Re: Blender cmod export script (updated)

Post #15by cartrite » 24.05.2010, 16:54

John was right. This was written for a Linux box. I thought it would run on Windows but I never was able to test it on Windows. The line that seems to be giving you trouble is using a PWD command that works with Linux to get the working dirctory. You can try to change the line

Code: Select all

path_dir = '%s' % os.environ['PWD']
to

Code: Select all

path_dir = '%s' % os.curdir
From what I remember, I think that latter line gave me trouble with linux for some reason but I wrote this a while ago and I can't really remember.
cartrite
Toshiba Satellite P875=S7200 laptop, Intel i5 processor 2.5 ghz 6 gb ram, Graphics Intel(R) HD Graphics 4000 openSUSE Leap42.3
and Tumbleweed

Avatar
t00fri
Posts: 8771
Joined: 29.03.2002
Age: 16
With us: 16 years 9 months
Location: Hamburg, Germany

Re: Blender cmod export script (updated)

Post #16by t00fri » 24.05.2010, 20:03

Hey Steve!

How are you?? It has been a long time... Are you coming back now on a more regular frequency?

Fridger
Image

swright
Posts: 2
Joined: 21.05.2010
With us: 8 years 7 months

Re: Blender cmod export script (updated)

Post #17by swright » 25.05.2010, 11:45

Thanks for code fix, runs perfectly on my Winblows box now. I really appreciate the quick response.

Great exporter, really saves time not having to use a converter. Not to mention the added versatility. Awsome work!
Windows XP SP3,Pentium 4 1.8Ghz 1.5gb ram, ATI Radeon HD 3650, 1gb DDR2 ram

Topic author
cartrite
Posts: 1725
Joined: 15.09.2005
With us: 13 years 4 months
Location: Pocono Mountains, Pennsylvania, USA

Re: Blender cmod export script (updated)

Post #18by cartrite » 25.05.2010, 19:12

t00fri wrote:Hey Steve!

How are you?? It has been a long time... Are you coming back now on a more regular frequency?

Fridger
I have been looking at the forums and emails. So I can respond to emails and forum questions by using a library computer. Trouble is, I'm still using an old back up computer at home. An old P2. The other computer bit the dust. I still can get it started but it freezes up all the time so I stopped using it to save the data on my hard drives. Work is still slow so I haven't been able to save enough for an Internet connection or to build a new computer which is what I am hoping to do some day soon. I seem to be one of those that fell through the cracks in the robust economy.

swright wrote:Thanks for code fix, runs perfectly on my Winblows box now. I really appreciate the quick response.

Great exporter, really saves time not having to use a converter. Not to mention the added versatility. Awsome work!
Great to hear that. I was shooting in the dark so I'm glad it worked out.
cartrite
Toshiba Satellite P875=S7200 laptop, Intel i5 processor 2.5 ghz 6 gb ram, Graphics Intel(R) HD Graphics 4000 openSUSE Leap42.3
and Tumbleweed

mmmeghele
Posts: 8
Joined: 15.02.2010
With us: 8 years 11 months

Re: Blender cmod export script (updated)

Post #19by mmmeghele » 29.08.2010, 13:38

Hi all,
I' trying to export a model form blender to celestia. I used the script cmod-export-mesh.py but I probably did something wrong because I obtained an error. I very new with celestia and blender (and python to say the truth...) so if someone could give me a hint I'd be grateful...
This is what I've done:

[mike@pcfluka ~]$ blender lpf.blend -P cmod-export-mesh.py
Compiled with Python version 2.6.2.
Checking for installed Python... got it!
Traceback (most recent call last):
File "cmod-export-mesh.py", line 302, in chk_name
write_file(filename)
File "cmod-export-mesh.py", line 50, in write_file
mesh = Mesh.Get(object.name)
NameError: Mesh "Transform" not found

Avatar
John Van Vliet
Posts: 2700
Joined: 28.08.2002
With us: 16 years 4 months

Re: Blender cmod export script (updated)

Post #20by John Van Vliet » 29.08.2010, 23:55

--- edit ---
Last edited by John Van Vliet on 19.10.2013, 23:02, edited 1 time in total.


Return to “Add-on development”

Who is online

Users browsing this forum: Janus And 7 guests