Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

developer:onreadnotes [2015/09/14] (current)
Line 1: Line 1:
 +======Reading Notes from a 3DM file ======
 +> **Developer:​** //​[[developer:​cplusplusplugins|C++]],​ [[developer:​opennurbs:​home|openNURBS]]//​
 +> **Summary:​** //​Demonstrates how to read the user-added notes field from a 3DM file using either the Rhino C++ SDK or the openNURBS toolkit.//
 +
 +===== Example =====
 +<code c++>
 +bool ReadNotesFromRhino3dmFile( const wchar_t* filename, ON_wString&​ notes )
 +{
 +  if( 0 == filename || 0 == filename[0] )
 +    return false;
 +
 +  // STEP 1: Open the file
 +  FILE* archive_fp = ON::​OpenFile( filename, L"​rb"​ );
 +  if( 0 == archive_fp )
 +    return false;
 +
 +  // STEP 2: Create a binary archive object
 +  ON_BinaryFile archive( ON::​read3dm,​ archive_fp );
 +  ​
 +  // STEP 3: Read 3dm start section
 +  int file_version = 0;
 +  ON_String start_section_comments;​
 +  if( !archive.Read3dmStartSection(&​file_version,​ start_section_comments) )
 +  {
 +    ON::​CloseFile( archive_fp );
 +    return false;
 +  }
 +
 +  // STEP 4: Read 3dm properties section
 +  ON_3dmProperties properties;
 +  if( !archive.Read3dmProperties(properties) )
 +  {
 +    ON::​CloseFile( archive_fp );
 +    return false;
 +  }
 +
 +  // STEP 5: Close the file
 +  ON::​CloseFile( archive_fp );
 +
 +  // return the notes
 +  notes = properties.m_Notes.m_notes;​
 +
 +  return true;
 +}
 +</​code>​
 +
 +\\
 +
 +{{tag>​Developer cplusplus openNURBS}}
  
developer/onreadnotes.txt ยท Last modified: 2015/09/14 (external edit)