PDA

View Full Version : simple way to get catenated print output?


cgbeige
10-22-2010, 04:33 PM
I don't have a background in programming so some of the basics escape me. I'm looking for a way to make this command spit out both the Primary and Secondary schemes as a single line. I thought that print needed a new line character to put something on the next line but the output from this is on to lines:

global proc engineQuery()
{
$primaryE = `getAttr vraySettings.primaryEngine`;
$secondaryE = `getAttr vraySettings.secondaryEngine`;

if ($primaryE == 0)
{
print "Primary Engine is Irradiance Map";
}
else if ($primaryE == 1)
{
print "Primary Engine is Photon Map";
}
else if ($primaryE == 2)
{
print "Primary Engine is Brute Force";
}
else if ($primaryE == 3)
{
print "Primary Engine is Light Cache";
}
else if ($primaryE == 4)
{
print "Primary Engine is Spherical Harmonics";
}

if ($secondaryE == 0)
{
print "Secondary Engine is None";
}
else if ($secondaryE == 1)
{
print "Secondary Engine is Photon Map";
}
else if ($secondaryE == 2)
{
print "Secondary Engine is Brute Force";
}
else if ($secondaryE == 3)
{
print "Secondary Engine is Light Cache" ;
}

}

cgbeige
10-22-2010, 04:55 PM
I think that I'm probably going about this the wrong way. Am I right in assuming that I should be using a function to get the value of the primary and secondary schemes and then just substituting the integer output of each with a text string and printing the catenated result?

NaughtyNathan
10-22-2010, 08:53 PM
I have no idea what it is you are doing and why Dave, but rather than using if..else at all just make a list/array and use the integer as the index into that array. for example:

global proc engineQuery()
{
int $primaryE = `getAttr vraySettings.primaryEngine`;
int $secondaryE = `getAttr vraySettings.secondaryEngine`;
string $primes[] = { "Irradiance Map", "Photon Map", "Brute Force", "Light Cache", "Spherical Harmonics" };
string $second[] = { "None", "Photon Map", "Brute Force", "Light Cache" };
print ("Primary Engine is " + $primes[$primaryE] + ", Secondary Engine is " + $second[$secondaryE] + "\n");
}
:nathaN

cgbeige
10-22-2010, 09:02 PM
sorry, I should have been more specific. I'm making a button that you click that will tell you what V-Ray primary/secondary schemes are currently active. When you query these, they are returned as "0, 1, 2, 3" so they aren't descriptive in themselves. I need to turn two separately-returned integers into a descriptive output (You are set to use Light Cache and Brute Force, for example).

mlefevre
10-23-2010, 09:46 PM
From your description, it looks as if Nathans suggestion would do the job. :curious:
Are you still having an issue with it?

CGTalk Moderation
10-23-2010, 09:46 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.