MAXScript Exposure: Power Importing Quick Help

Overview

nPower version 7.0 and greater allows the importing of files via MAXScript. This allows scripts to be created for batch importing with the nPower plug-ins. The settings available in the import dialog are also exposed to MAXScript.

Importing a File

Using the ImportFile call in MAXScript you can import a file with any of the nPower importers. An example is seen in the code below.

importfile "C:\fileToBeImported.igs" #noPrompt using:Pwr_Import

You do this by specifying one of the nPower Importers following the argument using:

The #noPrompt flag disables our dialog from popping up, and uses the previous import settings or import settings as determined via MAXScript as detailed here.

The above example code imports a file using the default settings as seen in the import dialog if no import has been made during the current session of 3DS MAX. However if you have imported in the current session of 3DS MAX, then the above script will use those settings. These settings can be changed as detailed here.

The table below lists the names of the different nPower importers to use, along with a description of the filetypes that the importer supports.

ImporterFile Types
Pwr_Import*.IGES, *.3DM, *.STEP, *.SAT, *.IGS, *.STP
Pwr_SolidWorksImport*.SLDPRT, *.SLDASM
Parasolids_Import*.X_T, *.XML, *.X_B
Pwr_IW*.IWPRODASCII, *.IWBREP, *.IWBREPB,*.IWPROD
Pwr_Catia*.MODEL, *.SESSION, *.CATPRODUCT, *.CATPART, *.DLV, *.EXP
Pro_E_Import*.PRT, *.ASM, *.1, *.2, *.3, *.4, *.5, *.6, *.7, *.8, *.9, *.10, *.11, *.12, *.13, *.14, *.15, *.16, *.17, *.18, *.19, *.20, *.21, *.22, *.23, *.24, *.25, *.26, *.27, *.28, *.29, *.30, *.31, *.32, *.33, *.34, *.35, *.36, *.37, *.38, *.39, *.40, *.41, *.42, *.43, *.44, *.45, *.46, *.47, *.48, *.49, *.50. *.XAS
Pro_E_2_Import*.PRT, *.ASM, *.51, *.51, *.53, *.54, *.55, *.56, *.57, *.58, *.59, *.60, *.61, *.62, *.63, *.64, *.65, *.66, *.67, *.68, *.69, *.70, *.71, *.72, *.73, *.74, *.75, *.76, *.77, *.78, *.79, *.80, *.81, *.82, *.83, *.84, *.85, *.86, *.87, *.88, *.89, *.90, *.91, *.92, *.93, *.94, *.95, *.96, *.97, *.98, *.99, *.100, *.101, *.102, *.103, *.104, *.105, *.106, *.107, *.108, *.109, *.110, *.XAS
Pwr_UG*.PRT
Solid_Edge_Import*.PAR
Datakit_Solidworks_Import*.SLDPRT, *SLDASM
Datakit_Parasolids_Import*.X_T, *.XML, *.X_B
JT_Import*.JT

Note: Not all of the above importers may be avaiable to you. It depends on the type of plugin you have purchased.

Changing Import Settings

Importing with Default Settings
If no previous imports have occurred during the current session of 3DS MAX, then the example MAXScript code (as seen here), will use the default settings. The default settings can be seen by going to File > Import, selecting one of our importers, picking a file, press OK, which should then bring up the nPower Import Dialog. The values that are set in the dialog are the default import values.

Changing Import Settings via the Import Dialog
Since the import code (as shown here), uses the settings of the previous import, one way to set the import settings for the script would be to do a regular import with one of the nPower Importers. Then choose the appropriate settings in the dialog. After the import occurs, the settings chosen will be used on subsequent imports via MAXScript.

Changing Import Settings via MAXScript
You can programmatically set the import settings with MAXScript. It is detailed in the section below.

Changing Import Settings via MAXScript

The following methods are used to change the nPower Import settings. (The boxed items are examples of MAXScript code)

PwrImportType [ "Standard" | "SingleObjects" | "SeparateObjects" ]

Import Types

  • "Standard" : Standard Import
  • "SingleObjects" : Force Surfaces into Single Objects
  • "SeparateObjects" : Explode Surfaces into Separate Objects
PwrImportType "Standard"

PwrImportRenderQuality [ "Coarse" | "Medium" | "Fine" ]

Render Quality

  • "Coarse" : Coarse Render Quality
  • "Medium" : Medium Render Quality
  • "Fine" : Fine Render Quality
PwrImportRenderQuality "Fine"

PwrImportMeshQuality [ "Coarse" | "Medium" | "Fine" | "VeryFine" | "SuperFine" ]

Mesh Quality

  • "Coarse" : Coarse Mesh Quality
  • "Medium" : Medium Mesh Quality
  • "Fine" : Fine Mesh Quality
  • "VeryFine" : Very Fine Mesh Quality
  • "SuperFine" : Super Fine Mesh Quality
PwrImportMeshQuality "Coarse"

PwrImportMeshOnly [ "True" | "False" ]

Import Model As Mesh Only

  • "True" : Import Model As Mesh Only
  • "False" : Don't Import Model As Mesh Only
PwrImportMeshOnly "False"

PwrImportMeshType [ "PowerEdgeMesh" | "NormalMax" ]

Mesh Type

  • "PowerEdgeMesh" : Power Edge Mesh
  • "NormalMax" : Normal Max
PwrImportMeshType "PowerEdgeMesh"

PwrImportAsAssembly [ "True" | "False" ]

Import Model As Assembly

  • "True" : Import Model As Assembly
  • "False" : Don't Import Model As Assembly
PwrImportAsAssembly "False"

PwrImportModelUpAxis [ "X" | "Y" | "Z" ]

Model Up Axis

  • "X" : X-axis up
  • "Y" : Y-axis up
  • "Z" : Z-axis up
PwrImportModelUpAxis "Z"

PwrImportSizeDependentMesh [ "True" | "False" ]

Produce Size Dependent Render Mesh

  • "True" : Produce Size Dependent Render Mesh
  • "False" : Don't Produce Size Dependent Render Mesh
PwrImportSizeDependentMesh "False"

PwrImportTwoSidedMesh [ "True" | "False" ]

Two Sided Meshes

  • "True" : Two Sided Meshes
  • "False" : Don't use Two Sided Meshes
PwrImportTwoSidedMesh "False"

PwrImportOrientSurfaces [ "True" | "False" ]

Orient Surfaces

  • "True" : Orient Surfaces
  • "False" : Don't Orient Surfaces
PwrImportOrientSurfaces "False"

Calling the above functions with no arguments, will return the current value.

PwrImportType()

The above code might return "Standard" if the default import settings are intact.

Example Script

The following is an example script that uses what is detailed in this documentation.

--set the settings for import
--in this example, I just set everything to default
PwrImportType "Standard"
PwrImportRenderQuality "Fine"
PwrImportMeshQuality "Coarse"
PwrImportMeshOnly "False"
PwrImportMeshType "PowerEdgeMesh"
PwrImportAsAssembly "False"
PwrImportModelUpAxis "Z"
PwrImportSizeDependentMesh "False"
PwrImportTwoSidedMesh "False"
PwrImportOrientSurfaces "False"

--now that we have the correct import settings, lets do some importing!
--assuming C:\folder contains valid files that you want to import
--(in this case perhaps a folder of .stp files)
files = getFiles "c:\\folder\\*.*"
for f in files do
(
importFile f #noPrompt using:PwrImport

--perhaps save the file so that you can import all the files overnight
--and open them some other time
SaveMaxFile f
resetMaxFile #noPrompt--reset the max file to prepare for another import
)

Document last updated: April 2010 (nPower version 7.0). Tested with Firefox 3.6.3, Internet Explorer 7.0.6002.