What's new

Export as STEP 242


New Member
I'm looking for a way to export parts in STEP 242 with a script. I know how to export them in STEP 203 and 214 (using ExportSTEP203() and ExportSTEP214()), but is there a way to do the same with 242 (ExportSTEP242() doesn't work)?



New Member
Yes, it says:
Traceback (most recent call last):
File "<string>", line 75, in <module>
AttributeError: 'Part' object has no attribute 'ExportSTEP242'

I only have expanded the example script "Part Exporter" with STEP242, so if it works for you, I think this is the wrong way to do this.

The edited lines are 13 (added STEP242 to the ExportTypes) and 74 - 76 (copied the export-part from STEP214 and changed it to STEP242).

# Part exporter script
# Demonstrates exporting a set of parts
# For use with Alibre Design

import fnmatch
import os
from os.path import expanduser

Win = Windows()

ScriptName = 'Part Exporter'

ExportTypes = ['STEP203', 'STEP214', 'STEP242', 'STL', 'IGES', 'SAT', 'BMP']

Options = []
Options.append(['Folder containing parts', WindowsInputTypes.Folder, expanduser('~'), 'Choose a folder containing the parts.'])
Options.append(['Output folder', WindowsInputTypes.Folder, expanduser('~'), 'Choose a folder to put the exported files'])
Options.append(['Export type', WindowsInputTypes.StringList, ExportTypes, ExportTypes[0]])

Values = Win.OptionsDialog(ScriptName, Options, 300)
if Values == None:

# get the inputs
PartsFolder = Values[0]
OutputFolder = Values[1]
ExportType = ExportTypes[Values[2]]

# validate
if not PartsFolder:
  Win.ErrorDialog('No part folder selected', ScriptName)
if os.path.isdir(PartsFolder) == False:
  Win.ErrorDialog('Folder containing parts does not exist', ScriptName)
if not OutputFolder:
  Win.ErrorDialog('No output folder selected', ScriptName)
if os.path.isdir(OutputFolder) == False:
  Win.ErrorDialog('Output folder does not exist', ScriptName)

print "Searching for parts..."

# create empty lists
Parts = []

# perform the search
for Root, Dirnames, Filenames in os.walk(PartsFolder):
  for Filename in fnmatch.filter(Filenames, '*.AD_PRT'):
    Parts.append(os.path.join(Root, Filename))

# if no parts found...
if len(Parts) == 0:
  Win.ErrorDialog('No parts found', ScriptName)

# export each part
for PartFileName in Parts:
  print "Exporting {0}...".format(PartFileName)
  Folder = os.path.dirname(os.path.abspath(PartFileName))
  FileName = os.path.basename(PartFileName)
  FileNameNoExt, Ext = os.path.splitext(FileName)
  OutputFileName = OutputFolder + '\\' + FileNameNoExt

  # open, export, close
  P = Part(Folder, FileName)
  if ExportType == 'STEP203':
    P.ExportSTEP203(OutputFileName + '.stp')
    print "Created {0} (203)".format(OutputFileName + '.stp')
  elif ExportType == 'STEP214':
    P.ExportSTEP214(OutputFileName + ".stp")
    print "Created {0} (214)".format(OutputFileName + '.stp')
  elif ExportType == 'STEP242':
    P.ExportSTEP242(OutputFileName + ".stp")
    print "Created {0} (242)".format(OutputFileName + '.stp')
  elif ExportType == 'STL':
    P.ExportSTL(OutputFileName + ".stl")
    print "Created {0}".format(OutputFileName + '.stl')
  elif ExportType == 'IGES':
    P.ExportIGES(OutputFileName + ".igs")
    print "Created {0}".format(OutputFileName + '.igs')
  elif ExportType == 'SAT':
    P.ExportSAT(OutputFileName + ".sat", 18, True)
    print "Created {0}".format(OutputFileName + '.sat')
  elif ExportType == 'BMP':
    P.SaveSnapshot(OutputFileName + '.bmp', 800, 600, True, False)
    print "Created {0}".format(OutputFileName + '.bmp')

Win.InfoDialog('Exported {0} parts'.format(len(Parts)), ScriptName)


Alibre Super User
i've checked mine and found an typing error... file was exported as 204, sorry
Checkes API and IADDesignSession.ExportAP242 isn't available...



Senior Member
So far as I can tell (I peeked into the decompiled API) there is no such method as ExportSTEP242.

Decompiled code for the other step export methods is:

    // Method ExportSTEP203 with token 06000274
    public void ExportSTEP203(/*Parameter with token 08000303*/string FileName) => this._Part.ExportAP203(FileName);

    // Method ExportSTEP214 with token 06000275
    public void ExportSTEP214(/*Parameter with token 08000304*/string FileName) => this._Part.ExportAP214(FileName);

this._Part is a reference to an IADPartSession.



New Member
Sorry for the late reply and thanks for your help. So if I got it right, I'll have to wait for it to (maybe) be implemented.