MCPcopy Create free account
hub / github.com/KhronosGroup/OpenCOLLADA / writer

Method writer

COLLADAMaya/src/COLLADAMayaFileTranslator.cpp:227–293  ·  view source on GitHub ↗

/ The writer() method provides a message through the script editor and /* returns a status to indicate the results. /* In this example, only "export all" and "export selection" options are /* allowed when trying to save data. Other options will result in the /* display of a failure message through the script editor and returns a /* MS:kFailure, which indicates that the file typ

Source from the content-addressed store, hash-verified

225 /* by the translator.
226 /************************************************************************/
227 MStatus FileTranslator::writer ( const MFileObject& file,
228 const MString& options,
229 MPxFileTranslator::FileAccessMode mode )
230 {
231 MStatus status = MStatus::kFailure;
232
233 try
234 {
235 // Save current selection
236 MSelectionList selection;
237 MGlobal::getActiveSelectionList(selection);
238
239 // Extract the filename
240#if defined (OSMac_)
241 char nameBuffer[MAXPATHLEN];
242 strcpy ( nameBuffer, file.fullName().asChar() );
243 const MString fileName ( nameBuffer );
244#else
245 const MString fileName = file.fullName();
246#endif // OSMac
247
248 // TODO Export the referenced files!
249 // Maya forces the write of all the references, on export.
250 // Intentionally skip known reference file paths.
251 for ( MItDependencyNodes it ( MFn::kReference ); !it.isDone(); it.next() )
252 {
253 MObject refNode = it.item();
254 MString refNodeName = MFnDependencyNode ( refNode ).name();
255
256 MString refNodeFilename;
257 MGlobal::executeCommand ( MString ( "reference -rfn \"" ) + refNodeName + MString ( "\" -q -filename" ),
258 refNodeFilename );
259
260 if ( refNodeFilename == fileName ) return MStatus::kSuccess;
261
262 if ( ExportOptions::exportXRefs() )
263 {
264 // TODO Open file export dialog ( !? HOW ?! ) to get a DAE filename
265 // to export the referenced file.
266
267 }
268 }
269
270 // Parse the export options
271 ExportOptions::set ( options );
272
273 // Check, if we should just export the selected Objects
274 exportSelection = mode == MPxFileTranslator::kExportActiveAccessMode;
275
276 // Do the actual export now
277 status = exportIntoFile ( fileName, exportSelection );
278
279 // Restore selection
280 MGlobal::setActiveSelectionList(selection);
281 }
282 catch ( COLLADASW::StreamWriterException* swException )
283 {
284 String message = "StreamWriterException: " + swException->getMessage();

Callers

nothing calls this directly

Calls 4

c_strMethod · 0.80
nextMethod · 0.45
nameMethod · 0.45
getMessageMethod · 0.45

Tested by

no test coverage detected