BaseFile question
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 13/02/2011 at 11:19, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 12
Platform: Windows ;
Language(s) : C++ ;---------
I am using a BaseFile to create presets for my plugin. The plugin writes all of the AM descriptions to a file and calls those from the file when a preset is loaded. This works great unless I use a LONG or dropdown box. When I try to call the long from the file I get nothing. Here's the code I am using to write to the file and read from the file.WRITING TO THE BASEFILE
//Open the BaseFile for writing. bf->Open(file, FILEOPEN_WRITE, FILEDIALOG_IGNOREOPEN, BYTEORDER_INTEL, MACTYPE_CINEMA, MACCREATOR_CINEMA); //Rotation Direction if (bc->GetLong(PLANETX_GENERAL_ROTATION_DIRECTION) == PLANETX_GENERAL_ROTATION_CLOCKWISE) { bf->WriteLong(bc->GetLong(PLANETX_GENERAL_ROTATION_CLOCKWISE)); } else { bf->WriteLong(bc->GetLong(PLANETX_GENERAL_ROTATION_COUNTER_CLOCKWISE)); }
READING THE BASEFILE
//Open the BaseFile for Reading. bf->Open(file, FILEOPEN_READ, FILEDIALOG_IGNOREOPEN, BYTEORDER_INTEL, MACTYPE_CINEMA, MACCREATOR_CINEMA); //Rotation Direction LONG rotdir; bf->ReadLong(&rotdir); bc->SetLong(PLANETX_GENERAL_ROTATION_DIRECTION, enrot);
Any reason why it wouldn't read the data stored in the LONG that holds the dropdown box options. ? Am I using it wrong?
Thanks,
Shawn
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 13/02/2011 at 11:21, xxxxxxxx wrote:
Also.. How would I store the information in a gradient in the BaseFile?
Thanks,
Shawn
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 13/02/2011 at 14:40, xxxxxxxx wrote:
This doesn't work because PLANETX_GENERAL_ROTATION_CLOCKWISE is not an element in the description, it's one of the options in the dropdown. Therefore it can't be accessed through the base container and written to the file, which means it can't be read back, either. Do:
bf->WriteLong(bc->GetLong(PLANETX_GENERAL_ROTATION_DIRECTION));
instead and it should be okay.
Can't help with the gradient, I'm afraid!
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 13/02/2011 at 14:54, xxxxxxxx wrote:
hmm.. still doesn't work. I can't figure out why.
btw IO solved the gradient problem ...
save to file.
//Atmosphere Color Gradient *atmColor =(Gradient* )bc->GetCustomDataType(PLANETX_ATMOSPHERE_COLOR,CUSTOMDATATYPE_GRADIENT); LONG knotCount = atmColor->GetKnotCount(); bf->WriteLong(knotCount); for(int i = 0; i < knotCount; i++){ GradientKnot knot = atmColor->GetKnot(i); bf->WriteLVector(knot.col); bf->WriteLReal(knot.pos); } //Transparency Color Gradient *atmtColor =(Gradient* )bc->GetCustomDataType(PLANETX_ATMOSPHERE_TRANSPARENCY, CUSTOMDATATYPE_GRADIENT); LONG tknotCount = atmtColor->GetKnotCount(); bf->WriteLong(tknotCount); for(int i = 0; i < tknotCount; i++){ GradientKnot tknot = atmtColor->GetKnot(i); bf->WriteLVector(tknot.col); bf->WriteLReal(tknot.pos); }
Read From File
//Atmosphere Color Gradient *atmColor =(Gradient* )bc->GetCustomDataType(PLANETX_ATMOSPHERE_COLOR,CUSTOMDATATYPE_GRADIENT); Gradient *blank = Gradient::Alloc(); LONG knotCount; bf->ReadLong(&knotCount); bc->SetParameter((DescID)PLANETX_ATMOSPHERE_COLOR, GeData(CUSTOMDATATYPE_GRADIENT, *blank)); for(int i = 0; i < knotCount; i++){ Vector color; LReal position; bf->ReadLVector(&color); bf->ReadLReal(&position); GradientKnot knot; knot.col = color; knot.pos = position; atmColor->InsertKnot(knot); } bc->SetParameter((DescID)PLANETX_ATMOSPHERE_COLOR, GeData(CUSTOMDATATYPE_GRADIENT, *atmColor)); //Transparency Color Gradient *atmtColor =(Gradient* )bc->GetCustomDataType(PLANETX_ATMOSPHERE_TRANSPARENCY, CUSTOMDATATYPE_GRADIENT); Gradient *tblank = Gradient::Alloc(); LONG tknotCount; bf->ReadLong(&tknotCount); bc->SetParameter((DescID)PLANETX_ATMOSPHERE_TRANSPARENCY, GeData(CUSTOMDATATYPE_GRADIENT, *tblank)); for(int i = 0; i < tknotCount; i++){ Vector tcolor; LReal tposition; bf->ReadLVector(&tcolor); bf->ReadLReal(&tposition); GradientKnot tknot; tknot.col = tcolor; tknot.pos = tposition; atmtColor->InsertKnot(tknot); } bc->SetParameter((DescID)PLANETX_ATMOSPHERE_TRANSPARENCY, GeData(CUSTOMDATATYPE_GRADIENT, *atmtColor));
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 13/02/2011 at 15:56, xxxxxxxx wrote:
Originally posted by xxxxxxxx
hmm.. still doesn't work. I can't figure out why.
Looking again at the read method for the setting, you're reading into a variable called rotdir, but storing the variable named enrot into the base container.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 13/02/2011 at 17:20, xxxxxxxx wrote:
DOH! The things that tired eyes overlook.
Thanks Spedler.
~Shawn
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 14/02/2011 at 08:08, xxxxxxxx wrote:
Been there, done that, got lots of T-shirts...
Steve