XSIPLUGINCALLBACK CStatus Coat3DExport_Execute( CRef& in_ctxt ) { // Unpack the command argument values Context ctxt( in_ctxt ); CValueArray args = ctxt.GetAttribute(L"Arguments"); CString string; // A 3d object with a mesh geometry must be selected Selection selection(app.GetSelection()); bool isPolymesh = true; for(int i =0; i< selection.GetCount(); i++) { X3DObject obj(selection[i]); //app.LogMessage(L"obj.IsA(siPolygonMeshID): " + CString(obj.GetType())); if(obj.GetType() != L"polymsh" ) { isPolymesh = false; break; } } if (selection.GetCount() > 0 && isPolymesh) { gV = 0; gVn = 0; gVt = 0; gVprev = 0; gVnPrev = 0; gVtPrev = 0; // prepare the output text file CString strOut = Get3DCoatParam( L"tempLocation" ).GetValue(); std::ofstream mfw; mfw.open(strOut.GetAsciiString(), std::ios_base::out | std::ios_base::trunc); if (mfw.is_open()) { bar.PutMaximum( selection.GetCount() ); bar.PutStep( 1 ); bar.PutVisible( true ); OutputHeader( mfw); // output the data for (int i=0; i < selection.GetCount(); i++) { gObjCnt = i; gVprev = gV; gVtPrev = gVt; gVnPrev = gVn; X3DObject xobj(selection.GetItem(i)); bar.PutValue(i); bar.PutCaption( L"Exporting " + xobj.GetName()); mfw << "\n"; mfw << "# Hierarchy (from self to top father)\n"; string = L"g " + xobj.GetName() + L"\n"; mfw << string.GetAsciiString(); mfw << "\n"; // Get a geometry accessor from the selected object Primitive prim = xobj.GetActivePrimitive(); PolygonMesh mesh = prim.GetGeometry(); if (!mesh.IsValid()) return CStatus::False; CGeometryAccessor ga = mesh.GetGeometryAccessor(); OutputVertices( mfw, ga, xobj ); if (bar.IsCancelPressed()) return CStatus::False; OutputPolygonComponents( mfw, ga ); if (bar.IsCancelPressed()) return CStatus::False; //bar.Increment(); } } mfw.close(); if(Get3DCoatParam(L"bExpMat").GetValue()) { OutputMaterials(selection ); } bar.PutStatusText( L"import.txt" ); OutputImportTxt(); bar.PutVisible(false); app.LogMessage(L"Export done!"); } else { app.LogMessage(L"Please, select objects!", siWarningMsg); return CStatus::False; } return CStatus::OK; }