Ignore:
Timestamp:
Sep 21, 2020 3:43:06 PM (3 years ago)
Author:
toby
Message:

RB extensions and minor bug fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIconstrGUI.py

    r4505 r4573  
    4444import GSASIIpy3 as G2py3
    4545import GSASIIphsGUI as G2phG
     46import GSASIIIO as G2IO
    4647import GSASIIscriptable as G2sc
    4748VERY_LIGHT_GREY = wx.Colour(235,235,235)
     
    20552056                Page2()
    20562057
     2058            if 'macromolecular' == rd.Phase['General']['Type']:
     2059                # for PDB imports, lets see if a quick reformat of atoms list will work
     2060                rd.Phase['Atoms'] = [a[3:] for a in rd.Phase['Atoms']]
     2061                rd.Phase['General']['AtomPtrs']  = [i-3 for i in rd.Phase['General']['AtomPtrs']]
     2062                rd.Phase['General']['Type'] = 'nuclear'
    20572063            SetupDrawing(rd.Phase) # add information to reader object to allow plotting
    20582064            atomlist = [atom[0] for atom in rd.Phase['Atoms']]
     
    22672273                UpdateDraw()
    22682274
     2275            def onWriteXYZ(event):
     2276                '''Writes selected atoms in a .xyz file for use in Avogadro, etc.
     2277                '''
     2278                grid.completeEdits()
     2279                center = np.array([0.,0.,0.])
     2280                count = 0
     2281                for i in range(len(rd.Phase['RBselection'])):
     2282                    if rd.Phase['RBselection'][i]:
     2283                        count += 1
     2284                        center += rd.Phase['RBcoords'][i]
     2285                if count:
     2286                    center /= count
     2287                else:
     2288                    print('nothing selected')
     2289                    return
     2290                obj = G2IO.ExportBaseclass(G2frame,'XYZ','.xyz')
     2291                #obj.InitExport(None)
     2292                if obj.ExportSelect():    # set export parameters; ask for file name
     2293                    return
     2294                fp = obj.OpenFile()
     2295                obj.Write(str(count))
     2296                obj.Write('')
     2297                for i in range(len(rd.Phase['RBselection'])):
     2298                    if rd.Phase['RBselection'][i]:
     2299                        line = ' ' + rd.Phase['RBtypes'][i]
     2300                        for xyz in rd.Phase['RBcoords'][i]:
     2301                            line += ' ' + str(xyz)
     2302                        obj.Write(line)
     2303                obj.CloseFile()
     2304                #GSASIIpath.IPyBreak()
     2305               
    22692306            def onAddVector(event):
    22702307                '''Adds selected atoms as a new vector rigid body.
     
    23812418                0,wx.ALL)
    23822419            btnSizer.Add((-1,5))
     2420            btn = wx.Button(RBImpPnl, wx.ID_ANY, 'export as xyz')
     2421            btn.Bind(wx.EVT_BUTTON,onWriteXYZ)
     2422            btnSizer.Add(btn,0,wx.ALIGN_CENTER)
     2423            btnSizer.Add((-1,10))
    23832424            btn = wx.Button(RBImpPnl, wx.ID_ANY, 'a Vector Body')
    23842425            btn.Bind(wx.EVT_BUTTON,onAddVector)
     
    24822523            else:
    24832524                col = None
     2525                return
    24842526        finally:
    24852527            dlg.Destroy()
Note: See TracChangeset for help on using the changeset viewer.