#文件名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' #幫助文檔路徑指定
)