Beispiel #1
0
 def loadNewTdoLibrary(self):
     fileNameWithPath = ""
     
     fileNameWithPath = usupport.getFileOpenInfo(usupport.kFileTypeTdo, udomain.domain.defaultTdoLibraryFileName, "Choose a 3D object library (tdo) file")
     if fileNameWithPath == "":
         return
     udomain.domain.defaultTdoLibraryFileName = fileNameWithPath
     self.readTdosFromFile()
Beispiel #2
0
 def changeTdoLibraryClick(self, Sender):
     fileNameWithPath = ""
     
     fileNameWithPath = usupport.getFileOpenInfo(usupport.kFileTypeTdo, udomain.domain.defaultTdoLibraryFileName, "Choose a 3D object library (tdo) file")
     if fileNameWithPath == "":
         return
     self.currentTdoLibraryFileName.Text = fileNameWithPath
     udomain.domain.defaultTdoLibraryFileName = self.currentTdoLibraryFileName.Text
     self.currentTdoLibraryFileName.SelStart = len(self.currentTdoLibraryFileName.Text)
Beispiel #3
0
    def changeTdoLibraryClick(self, Sender):
        fileNameWithPath = ""

        fileNameWithPath = usupport.getFileOpenInfo(usupport.kFileTypeTdo, udomain.domain.defaultTdoLibraryFileName, "Choose a 3D object library (tdo) file")
        if fileNameWithPath == "":
            return
        self.currentTdoLibraryFileName.Text = fileNameWithPath
        udomain.domain.defaultTdoLibraryFileName = self.currentTdoLibraryFileName.Text
        self.currentTdoLibraryFileName.SelStart = len(self.currentTdoLibraryFileName.Text)
Beispiel #4
0
 def reconcileFileWithTdoLibrary(self, plantFileName, tdoLibrary):
     result = 0
     plantFileTdos = TListCollection()
     libraryFileTdos = TListCollection()
     plantFile = TextFile()
     tdoFile = TextFile()
     outputTdoFile = TextFile()
     i = 0
     j = 0
     tdo = KfObject3d()
     plantFileTdo = KfObject3d()
     libraryTdo = KfObject3d()
     matchInLibrary = false
     aLine = ""
     fileInfo = SaveFileNamesStructure()
     
     result = 0
     if not FileExists(plantFileName):
         # check that files exist
         plantFileName = usupport.getFileOpenInfo(usupport.kFileTypePlant, plantFileName, "Choose a plant file")
         if plantFileName == "":
             return result
     if not FileExists(tdoLibrary):
         tdoLibrary = usupport.getFileOpenInfo(usupport.kFileTypeTdo, tdoLibrary, "Choose a 3D object library (tdo) file")
         if tdoLibrary == "":
             return result
     plantFileTdos = ucollect.TListCollection().Create()
     libraryFileTdos = ucollect.TListCollection().Create()
     try:
         ucursor.cursor_startWait()
         # read tdos from plants
         AssignFile(plantFile, plantFileName)
         try:
             # v1.5
             usupport.setDecimalSeparator()
             Reset(plantFile)
             while not UNRESOLVED.eof(plantFile):
                 UNRESOLVED.readln(plantFile, aLine)
                 if UNRESOLVED.pos(utdo.kStartTdoString, aLine) > 0:
                     tdo = utdo.KfObject3D().create()
                     tdo.readFromFileStream(plantFile, utdo.kInTdoLibrary)
                     plantFileTdos.Add(tdo)
         finally:
             CloseFile(plantFile)
         # read tdos from library
         AssignFile(tdoFile, tdoLibrary)
         try:
             # v1.5
             usupport.setDecimalSeparator()
             Reset(tdoFile)
             while not UNRESOLVED.eof(tdoFile):
                 tdo = utdo.KfObject3D().create()
                 tdo.readFromFileStream(tdoFile, utdo.kInTdoLibrary)
                 libraryFileTdos.Add(tdo)
         finally:
             CloseFile(tdoFile)
         if plantFileTdos.Count > 0:
             for i in range(0, plantFileTdos.Count):
                 # add plant tdos not in library list to library list
                 plantFileTdo = utdo.KfObject3D(plantFileTdos.Items[i])
                 matchInLibrary = false
                 if libraryFileTdos.Count > 0:
                     for j in range(0, libraryFileTdos.Count):
                         libraryTdo = utdo.KfObject3D(libraryFileTdos.Items[j])
                         if plantFileTdo.isSameAs(libraryTdo):
                             matchInLibrary = true
                             break
                 if not matchInLibrary:
                     tdo = utdo.KfObject3D().create()
                     tdo.copyFrom(plantFileTdo)
                     libraryFileTdos.Add(tdo)
                     result += 1
         if result > 0:
             if usupport.getFileSaveInfo(usupport.kFileTypeTdo, usupport.kDontAskForFileName, tdoLibrary, fileInfo):
                 # if any tdos in plant file but not in library, rewrite library
                 AssignFile(outputTdoFile, fileInfo.tempFile)
                 try:
                     # v1.5
                     usupport.setDecimalSeparator()
                     Rewrite(outputTdoFile)
                     usupport.startFileSave(fileInfo)
                     if libraryFileTdos.Count > 0:
                         for i in range(0, libraryFileTdos.Count):
                             tdo = UNRESOLVED.TObject(libraryFileTdos.Items[i]) as utdo.KfObject3D
                             if tdo == None:
                                 continue
                             tdo.writeToFileStream(outputTdoFile, utdo.kInTdoLibrary)
                     fileInfo.writingWasSuccessful = true
                 finally:
                     CloseFile(outputTdoFile)
                     usupport.cleanUpAfterFileSave(fileInfo)
     finally:
         plantFileTdos.free
         libraryFileTdos.free
         ucursor.cursor_stopWait()
     return result