UF_MB_ask_button_id 测试

# tesy UF_MB_ask_button_id
import NXOpen

import NXOpen_UF as nuf


def main():
    ses = NXOpen.Session.GetSession()
    lw = ses.ListingWindow
    lineLength = 130 
    
    def info(obj, lw=lw):
    
        if lw is None:
            lw = ses.ListingWindow
        s = str(obj)
        l = len(s)
        if not lw.IsOpen:
            lw.Open()
        for i in range(l // lineLength + 1):
            lw.WriteLine(s[i * lineLength: i * lineLength + lineLength])
    
    if not nuf.Uf.IsInitialized:
        nuf.Uf.Initialize()
        
    a = "UG_VIEW_REFRESH"
    try:
        b = nuf.UFSession.GetUFSession().Mb.AskButtonId(a)
        info(f"button [{a}], id:{b}")
    except Exception as e:
        info(f"button [{a}], id: not found. error:[ {e} ]") 
            

if __name__ == '__main__':
    main()

posted @ 2022-03-15 14:50  方头狮  阅读(169)  评论(0)    收藏  举报