|
发表于 2015-8-7 20:19
|
显示全部楼层
来自: 中国广东广州
曾经做过tribon二次开发,对删除修改等功能进行重写,增加操作日志记录。
各种修改都可以记录下来。
下面是删除重写的PY代码
----------------------------------------------------------------
import kcs_ui
import kcs_util
import kcs_struct
import kcs_draft
import KcsPoint2D
import KcsModel
import win32api
import datetime
import os
from rytpath import *
def run(*args):
p= KcsPoint2D.Point2D()
model=KcsModel.Model()
res,p=kcs_ui.point2D_req("请选取要删除的对象:", p)
if res== kcs_util.operation_complete() or res== kcs_util.cancel() :
pass
else:
try:
model=kcs_draft.model_identify(p, model)
struct_name=model[0].Name
str_Question="是否确认删除:"+ struct_name+"?"
res1=kcs_ui.answer_req("Question", str_Question)
if res1==201:
kcs_struct.struct_delete (struct_name)
kcs_draft.model_delete(model[0])
kcs_ui.message_noconfirm("成功删除:"+struct_name)
string="%s struct_name='%s' was deleted. On ComputerName=%s By User=%s \n" %(datetime.datetime.now(),
struct_name ,win32api.GetComputerName(),
win32api.GetUserName())
proj= kcs_util.TB_environment_get("SB_PROJ")
filepath=data+"\\deletelog\\"+proj+"\\delete.log"
if not os.path.exists(data+"\\deletelog"):
os.mkdir (data+"\\deletelog")
os.mkdir (data+"\\deletelog\\"+proj)
f=open(filepath,"w")
f.write(string)
f.close()
elif not os.path.exists(data+"\\deletelog\\"+proj):
os.mkdir (data+"\\deletelog\\"+proj)
f=open(filepath,"w")
f.write(string)
f.close()
elif not os.path.exists(filepath):
f=open(filepath,"w")
f.write(string)
f.close()
elif os.path.exists(filepath):
f=open(filepath,"r")
filestr=f.readlines()
filestr.append(string)
f.close()
f=open(filepath,"w")
f.writelines(filestr)
f.close()
elif res1==202:
kcs_ui.message_noconfirm("你取消了删除:"+ struct_name)
except:
kcs_ui.message_noconfirm("未找到模型!")
|
|