Create multiple outfitting modules using Vitesse script

2011/10/16 21:15

Setting up a new Tribon project for the outfitting applications involves the creation of new outfitting modules. Boring job that has to be done. The usual way is to use "Tribon design manager" - an interactive application where the outfitting modules can be created one by one. Imagine that the number of these modules is 50 or 100 or more?

Here is one simple Vitesse script, that will help you create all outfitting modules at once. It uses an external text file for input.

import sys
import kcs_ui
import kcs_util
import kcs_draft
import kcs_modelstruct
import os
import string

filename = 'C:\\Tribon\\m3\\temp\\new_modules.txt'

in_file = open(filename,"r")
module_name = in_file.readline()
while(module_name != ''):
module_name = module_name[:-1]
try:
kcs_modelstruct.module_new(module_name)
kcs_ui.message_debug(module_name)
except:
message = 'Error on module : ' + module_name
kcs_ui.message_debug(message)
module_name = in_file.readline()
in_file.close()

How it works?

When the script is run (let say in Drafting), it looks for file with name new_modules.txt located in C:\Tribon\m3\temp\ . The file syntax is simple - one outfitting module name per row. For example:

module1
module2
module3

The script reads each row - module_name = in_file.readline() and try to create new module with name equal to the one it has read from the input file row -

kcs_modelstruct.module_new(module_name).

If module with the same name already exists or the module name is not valid (for example module-05) it is skipped, an error message is shown in the Vitesse log window and the script continues with the following row.

When the end of file is reached while(module_name != ''): ,

the script close the file - in_file.close() and terminates.

The newly created outfitting modules can be verified running a fresh instance of Tribon Design Manager for example.