- // Collect names of GEOM objects to exclude same names of SMESH objects
- GEOM::string_array_var aGeomNames = geom->GetAllDumpNames();
- int ign = 0, nbgn = aGeomNames->length();
- for (; ign < nbgn; ign++) {
- aName = aGeomNames[ign];
- theObjectNames.Bind(aName, "1");
- }
-
- bool importGeom = false;
- for (Standard_Integer i = 1; i <= aLen; i += 2) {
- anUpdatedScript += aScript.SubString(aStart, aSeq->Value(i) - 1);
- anEntry = aScript.SubString(aSeq->Value(i), aSeq->Value(i + 1));
- // is a GEOM object?
- aName = geom->GetDumpName( anEntry.ToCString() );
- if (aName.IsEmpty()) {
- // is a SMESH object
- if (theObjectNames.IsBound(anEntry)) {
- // The Object is in Study
- aName = theObjectNames.Find(anEntry);
- // check validity of aName
- bool isValidName = fixPythonName( aName );
- if (theObjectNames.IsBound(aName) && anEntry != theObjectNames(aName)) {
- // diff objects have same name - make a new name by appending a digit
- TCollection_AsciiString aName2;
- Standard_Integer i = 0;
+ // Treat every script line and add it to anUpdatedScript
+ for ( linesIt = lines.begin(); linesIt != lines.end(); ++linesIt )
+ {
+ TCollection_AsciiString& aLine = *linesIt;
+ anUpdatedScript += tab;
+ {
+ //Replace characters used instead of quote marks to quote notebook variables
+ int pos = 1;
+ while (( pos = aLine.Location( 1, SMESH::TVar::Quote(), pos, aLine.Length() )))
+ aLine.SetValue( pos, '"' );
+ }
+ // Find entries to be replaced by names
+ Handle(TColStd_HSequenceOfInteger) aSeq = FindEntries(aLine);
+ const Standard_Integer aSeqLen = aSeq->Length();
+ Standard_Integer aStart = 1;
+ for (Standard_Integer i = 1; i <= aSeqLen; i += 2)
+ {
+ if ( aStart < aSeq->Value(i) )
+ anUpdatedScript += aLine.SubString( aStart, aSeq->Value(i) - 1 ); // line part before i-th entry
+ anEntry = aLine.SubString( aSeq->Value(i), aSeq->Value(i + 1) );
+ // is a GEOM object?
+ CORBA::String_var geomName = geom->GetDumpName( anEntry.ToCString() );
+ if ( !geomName.in() || !geomName.in()[0] ) {
+ // is a SMESH object
+ if ( theObjectNames.IsBound( anEntry )) {
+ // The Object is in Study
+ aName = theObjectNames.Find( anEntry );
+ // check validity of aName
+ bool isValidName = fixPythonName( aName );
+ if (theObjectNames.IsBound(aName) && anEntry != theObjectNames(aName)) {
+ // diff objects have same name - make a new name by appending a digit
+ TCollection_AsciiString aName2;
+ Standard_Integer i = 0;
+ do {
+ aName2 = aName + "_" + ++i;
+ } while (theObjectNames.IsBound(aName2) && anEntry != theObjectNames(aName2));
+ aName = aName2;
+ isValidName = false;
+ }
+ if ( !isValidName )
+ theObjectNames(anEntry) = aName;
+
+ if ( aLine.Value(1) != '#' )
+ mapEntries.Bind(anEntry, aName);
+ }
+ else
+ {
+ // Removed Object