#文件名createplatewithhole_plugin.py
#中文编码
# -* - coding:utf-8 -*-
from abaqusgui import *
from abaqusconstants import all
import osutils, os
#####################################################################
# class definition
#####################################################################
class createplatewithhole_plugin(afxform): #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def __init__(self, owner): # construct the base class. # afxform.__init__(self, owner) self.radiobuttongroups = {} self.cmd = afxguicommand(mode=self, method='createplatefunction', objectname='createplatemodul', registerquery=false) pickeddefault = '' self.partnamekw = afxstringkeyword(self.cmd, 'partname', true, 'part-1') self.widthkw = afxfloatkeyword(self.cmd, 'width', true,100) self.heightkw = afxfloatkeyword(self.cmd, 'height', true,100) self.radiuskw = afxfloatkeyword(self.cmd, 'radius', true,5) #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def getfirstdialog(self): import createplatewithholedb return createplatewithholedb.createplatewithholedb(self) #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def docustomchecks(self): # try to set the appropriate radio button on. if the user did # not specify any buttons to be on, do nothing. # for kw1,kw2,d in self.radiobuttongroups.values(): try: value = d[ kw1.getvalue() ] kw2.setvalue(value) except: pass #对输入数据格式进行检查,不满足要求时提示警告 if self.widthkw.getvalue()<=0: showafxerrordialog(getafxapp().getafxmainwindow(), '宽度必须为正数') return false elif self.heightkw.getvalue()<=0: showafxerrordialog(getafxapp().getafxmainwindow(), '高度必须为正数') return false elif self.radiuskw.getvalue()<=0: showafxerrordialog(getafxapp().getafxmainwindow(), '孔半径必须是正数.') return false else: return true #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def oktocancel(self): # no need to close the dialog when a file operation (such # as new or open) or model change is executed. # return false #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# register the plug-in
#
thispath = os.path.abspath(__file__) #指定路径
thisdir = os.path.dirname(thispath)
toolset = getafxapp().getafxmainwindow().getplugintoolset()
toolset.registerguimenubutton( buttontext='创建带孔板', object=createplatewithhole_plugin(toolset), messageid=afxmode.id_activate, icon=none, #指定图标为空 kernelinitstring='import createplatemodul' , #内核初始化指令 applicablemodules=all, #指定使用模块,默认为全部 version='1.0', #软件版本 author='jly', #软件作者 description='n/a', #软件描述 helpurl='n/a' #帮助文档路径指定
)