Start a new topic

Making Master.flt via script

Original Post by: jwill222 Mon Jun 16 15:48:49 2014

I'm currently working on a python script that would create a master openflight file given a directory with openflight files. I understand that I would probably first have to use -> mgNewDB("Master.flt"). Then what would be the correct function to reference the other files in the directory? Thanks for any help.

Original Post by: SteveThompson Mon Jun 16 16:08:40 2014

Just like groups or objects, external references are simply nodes in the master db. Whereas groups are type fltGroup and objects are type fltObject, external references are type fltXref and the fltXrefFilename attribute of the fltXref node is the file associated to the external reference. So just as you would create any node in the db you would use mgNewRec to create the external reference, passing fltXref as the code for the new node. Of course you need to attach it in the scene. Use mgAttach, mgAppend or mgInsert depending on where you want to attach it. Now that you have the external reference in the master db, simply set the fltXrefFilename attribute of the new node to the path and file name of the db you want to associate to it.

In OpenFlight script, this might look like this:

db = mgGetCurrentDb()

g2 = mgGetChild(mgGetChild(db))

xRef = mgNewRec(fltXref)

mgAttach(g2, xRef)

mgSetAttList(xRef, fltXrefFilename, "E:/db/externalref.flt")

This snippet creates and attaches an external reference to the first grandchild of db.

Original Post by: jwill222 Mon Jun 16 16:25:01 2014

Wow! This really helps a ton. Thanks for the super quick response.

Original Post by: jwill222 Mon Jun 16 17:24:05 2014

I'm having a problem with creating a new record.

Whenever I do -> xRef = mgNewRec(fltXref) I get this error:

Traceback(most recent call last):

File "<pyshell#8>", line 1, in <module>

xRef = mgNewRec(fltXref)

NameError: name 'fltXref' is not defined

When i pass the function a integer I don't get the error. Any suggestions on making this work?

Original Post by: jwill222 Mon Jun 16 17:40:49 2014

Never mind found out what the problem was. All is well now.

Login to post a comment