Help in maya import code

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Display Modes
  07 July 2015
Help in maya import code

Hi I wanna write a code to not to get error if I don't have file on my computer
For example: This code is for not to get error from the object which is not is scene:
string $sel[] = `ls "nj_liberty01_Mesh"`;
int $selsize = size($sel);
if ($selsize > 0){
select -r "nj_liberty01_Mesh";
print "Model was in scene so it's now selected";
print "Model wan't in scene :|";
Now I wanna use it for import code which is as you know:
file -import -type "OBJ" -ra true -mergeNamespacesOnClash false -rpr "nj_liberty01" -options "mo=1" -pr -loadReferenceDepth "all" "C:/Users/Sherlock/Desktop/work/map/nj_liberty01.obj";
Okay so what do I use instead of
string $sel[] = `ls "nj_liberty01_Mesh"`;
int $selsize = size($sel);
if ($selsize > 0){
I mean $selsize help me plz
  08 August 2015
You can use the file -exists option to check if a file exists.

Something like this

string $filename = "C:/Users/Sherlock/Desktop/work/map/nj_liberty01.obj";
bool $exists = `file -exists $filename`;
if ($exists) {
    file -import -type "OBJ" -ra true -mergeNamespacesOnClash false
         -rpr "nj_liberty01" -options "mo=1" -pr -loadReferenceDepth "all" $filename;
else {
    print "This file does not exist:";
    print $filename;
reply share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 10:05 PM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.