试用期员工
- UID
- 665
- 积分
- 258
- 金币
-
- 活跃
-
- 阅读权限
- 30
- 注册时间
- 2006-9-18
- 最后登录
- 1970-1-1
|
楼主 |
发表于 2023-8-2 11:31
|
显示全部楼层
来自: 中国上海
- # -*- coding: cp936 -*-
- #
- # 肖恢满 VX:56095181
- #
- ####################################################################################################################
- # All Module File
- ####################################################################################################################
- from wxPython.wx import *
- from wxPython.grid import *
- from wxPython.lib.anchors import LayoutAnchors
- from win32api import *
- import wx.lib.mixins.listctrl
- import kcs_hullpan
- import kcs_ui
- import kcs_util
- import kcs_dex
- import KcsPanelSchema
- import time
- import xyf
- import string
- import os
- import sys
- import win32api
- import kcs_hull
- import kcs_draft
- import CommonSample
- import KcsModel
- import odbc
- import KcsCaptureRegion2D
- import KcsLinetype
- import KcsPoint2D
- import getpass
- import KcsContour2D
- import KcsColour
- import KcsLinetype
- import KcsRline2D
- import re
- import copy
- import KcsRectangle2D
- import KcsText
- import KcsTransformation2D
- import KcsVector2D
- import KcsVector3D
- import math
- import KcsPolygon2D
- import KcsPrintOptions
- import KcsCursorType
- import KcsStat_point2D_req
- import kcs_struct
- import kcs_db
- import kcs_modelstruct
- import KcsPoint3D
- import kcs_assembly
- from KcsStringlist import Stringlist
- from KcsObject import Object
- from KcsObjectCriteria import ObjectCriteria
- from KcsDateTime import DateTime
- kcs_draft.highlight_off(0)
- tbenvtable = xyf.get_env()
- sch_path = kcs_util.TB_environment_get('SB_SHIPSCH')
- proj_str = kcs_util.TB_environment_get("SB_PROJ_HULL")
- bin_path = kcs_util.TB_environment_get('SB_SYSTEM')
- block = kcs_util.TB_environment_get('HH_BLOCK_NO')
- blocks = [block]
- try:
- rblock = kcs_util.TB_environment_get('HH_BLOCK_NO_MIRROR')
- if rblock != block:
- blocks.append(rblock)
- except:
- pass
-
- def ListSubAssemblies(resultList, offset, name):
- try:
- subAssemblies = kcs_assembly.assembly_sub_get(name)
- for assembly in subAssemblies:
- resultList.append((0, assembly[0], assembly[1], offset))
- ListSubAssemblies(resultList, offset + 1, assembly[1])
- except:
- pass
-
- TreeList = []
- for block_str in blocks:
- block_ass_str = kcs_assembly.assembly_internal_name_get('-' + block_str)
- rootass = kcs_assembly.assembly_sub_get(block_ass_str)
- for assembly in rootass:
- TreeList.append((0, assembly[0], assembly[1], 0))
- ListSubAssemblies(TreeList, 1, assembly[1])
- TreeList.sort()
- TreeDic = {}
- TreeDic1 = {}
- TreeLis = []
- for a in TreeList:
- TreeDic[a[2]] = a[1]
- TreeDic1[a[1]] = a[2]
- TreeLis.append(a[1])
- class MyFrame(wxFrame):
- __module__ = __name__
- def __init__(self, parent, ID, title):
- wxFrame.__init__(self, parent, ID, title, wxPoint(GetSystemMetrics(0) - 553, 130),
- wxSize(520, 725), style=wxDEFAULT_FRAME_STYLE | wxCLIP_CHILDREN)
- # global text_plan_name, text_patr_typ, text_old_sch, bt_select_model, ResuwxGrid1, text_new_sch, bt_modify_model, text_patr_id
- # global bt_paste_model, bt_copy_model, text_tree_sch
- self.panel = wxPanel(size=wxSize(510, 725), parent=self, id=-1, name='panel1',
- style=wxTAB_TRAVERSAL | wxCLIP_CHILDREN, pos=wxPoint(0, 0))
- self.panel.SetAutoLayout(True)
- wxStaticText(self.panel, -1, '板架名:', wxPoint(10, 10)) # 放置文字
- self.text_plan_name = wxTextCtrl(self.panel, -1, "", wxPoint(60, 7), wxSize(150, -1))
- wxStaticText(self.panel, -1, '零件类型:', wxPoint(220, 10)) # 放置文字
- self.text_patr_typ = wxTextCtrl(self.panel, -1, "", wxPoint(280, 7), wxSize(70, -1))
- wxStaticText(self.panel, -1, 'ID:', wxPoint(360, 10)) # 放置文字
- self.text_patr_id = wxTextCtrl(self.panel, -1, "", wxPoint(390, 7), wxSize(20, -1))
- self.text_patr_id.Enable(False)
-
- self.sb1 = wxStaticBox(self.panel, -1, "原SCH语句", wxPoint(10, 35), wxSize(490, 100))
- self.sb1.SetConstraints(LayoutAnchors(self.sb1, True, True, True, False))
-
- self.text_old_sch = wxTextCtrl(self.sb1, -1, "", wxPoint(5, 15), wxSize(480, 80), style=wxTE_MULTILINE)
- self.text_old_sch.SetConstraints(LayoutAnchors(self.text_old_sch, True, True, True, False)) ##布局限制
-
- self.sb2 = wxStaticBox(self.panel, -1, "新SCH语句", wxPoint(10, 550), wxSize(490, 100))
- self.sb2.SetConstraints(LayoutAnchors(self.sb2, True, True, True, False))
-
- self.text_new_sch = wxTextCtrl(self.sb2, -1, "", wxPoint(5, 15), wxSize(480, 80), style=wxTE_MULTILINE)
- self.text_new_sch.SetConstraints(LayoutAnchors(self.text_new_sch, True, True, True, False)) ##布局限制
-
- self.bt_select_model = wxButton(self.panel, -1, "选择零件", wxPoint(430, 6), wxSize(70, -1))
- EVT_BUTTON(self, self.bt_select_model.GetId(), self.Evt_select_model)
- self.bt_select_model.SetBackgroundColour(wxCYAN)
-
-
- self.bt_modify_model = wxButton(self.panel, -1, "保存编辑SCH修改", wxPoint(10, 655), wxSize(485, -1))
- EVT_BUTTON(self, self.bt_modify_model.GetId(), self.Evt_modify_model)
- self.bt_modify_model.SetConstraints(LayoutAnchors(self.bt_modify_model, True, True, True, False))
- self.bt_modify_model.SetBackgroundColour(wxCYAN)
-
- ########################################## 绘制列表 ##################################################################
- self.GR = wxGrid(self.panel, -1, wxPoint(10, 145), wxSize(480, 395))
- self.GR.SetConstraints(LayoutAnchors(self.GR, True, True, True, False)) ##布局限制
- self.GR.CreateGrid(0, 3)
- self.GR.SetColLabelValue(0, "说明")
- self.GR.SetColLabelValue(1, "参数")
- self.GR.SetColLabelValue(2, "值")
- self.GR.SetRowLabelSize(0)
- self.GR.SetColLabelSize(20)
- self.GR.SetColSize(0, 80)
- self.GR.SetColSize(1, 80)
- self.GR.SetColSize(2, 290)
- self.select_model()
- EVT_GRID_CELL_CHANGE(self, self.Evt_grid_edit)
-
- EVT_CLOSE(self, self.OnClose)
-
- ##关闭窗口
- def OnClose(self, event):
- kcs_draft.highlight_off(0)
- self.Destroy()
-
- def Evt_select_model(self, event):
- self.select_model()
- self.Show(False)
- self.Show(True)
-
-
- def Evt_modify_model(self, event):
- try:
- kcs_hull.pan_modify(self.text_plan_name.GetValue(), 2)
- kcs_hullpan.stmt_exec_single(int(self.text_patr_id.GetValue()), self.text_new_sch.GetValue(),
- self.text_plan_name.GetValue())
- kcs_hull.pan_store()
- kcs_hull.pan_skip()
- kcs_ui.message_noconfirm('笑遥佛HOOK:' + self.text_plan_name.GetValue() + '修改完成')
- except:
- kcs_ui.message_confirm('笑遥佛HOOK:' + self.text_plan_name.GetValue() + '修改失败')
- kcs_hull.pan_skip()
-
-
- def Evt_grid_edit(self, event):
- self.xyf_new_sch()
- try:
- kcs_hull.pan_modify(self.text_plan_name.GetValue(), 2)
- kcs_hullpan.stmt_exec_single(int(self.text_patr_id.GetValue()), self.text_new_sch.GetValue(),
- self.text_plan_name.GetValue())
- kcs_hull.pan_store()
- kcs_hull.pan_skip()
- kcs_ui.message_noconfirm('笑遥佛HOOK:' + self.text_plan_name.GetValue() + '修改完成')
- except:
- kcs_ui.message_confirm('笑遥佛HOOK:' + self.text_plan_name.GetValue() + '修改失败')
- kcs_hull.pan_skip()
- kcs_draft.dwg_repaint()
- kcs_ui.app_window_refresh() #刷新屏幕
-
- def select_model(self):
- result = 1
- while result:
- kcs_draft.highlight_off(0)
- coord = KcsPoint2D.Point2D()
- model = KcsModel.Model()
- try:
- res = kcs_ui.point2D_req('请选择模型', coord)
- if res[0] == kcs_util.ok():
- kcs_draft.highlight_off(0)
- handle = kcs_draft.component_identify(coord)
- model = kcs_draft.model_properties_get(handle, model)
- group_no = kcs_hullpan.group_get(model.Name, model.PartId) # SCH组
- old_sch = kcs_hullpan.stmt_get(model.Name, group_no)
- self.text_plan_name.SetValue(model.Name)
- self.text_patr_typ.SetValue(model.PartType)
- self.text_patr_id.SetValue(str(group_no))
- self.text_old_sch.SetValue(old_sch)
- self.xyf_grid_list(old_sch)
-
- #显示型材的两个端点位置
- try:
- if model.PartType in ["stiffener","flange","pillar"]:
- if model.Type == "plane panel":
- tra_list = xyf.get_date("HULL.PAN('" + model.Name + "').TRA")[0]
- temp_list = xyf.get_date("HULL.PAN('%s').%s(%d).END(1).POI" % (model.Name, model.PartType, abs(model.PartId) ))[0]
- END1 = KcsPoint3D.Point3D(temp_list[0],temp_list[1],0)
- old_matrix = [1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0,1.0]
- END1 = xyf.get_tra_cood(tra_list, END1, old_matrix)
-
- temp_list = xyf.get_date("HULL.PAN('%s').%s(%d).END(2).POI" % (model.Name, model.PartType, abs(model.PartId) ))[0]
- END2 = KcsPoint3D.Point3D(temp_list[0],temp_list[1],0)
- old_matrix = [1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0,1.0]
- END2 = xyf.get_tra_cood(tra_list, END2, old_matrix)
- elif model.Type == "curved panel":
- temp_list = xyf.get_date("HULL.CPAN('%s').%s(%d).END(1).XYZ" % (model.Name, model.PartType, abs(PartId) % 1000 ))[0]
- END1 = KcsPoint3D.Point3D(temp_list[0],temp_list[1],0)
- temp_list = xyf.get_date("HULL.CPAN('%s').%s(%d).END(2).XYZ" % (model.Name, model.PartType, abs(PartId) % 1000 ))[0]
- END2 = KcsPoint3D.Point3D(temp_list[0],temp_list[1],0)
- if model.ReflCode == 1:
- END1.Y = END1.Y * -1.0
- END2.Y = END2.Y * -1.0
-
- vhandle = kcs_draft.view_identify(coord)
- END1_2d = KcsPoint2D.Point2D()
- kcs_draft.point_transform(vhandle, END1, END1_2d)
-
- END2_2d = KcsPoint2D.Point2D()
- kcs_draft.point_transform(vhandle, END2, END2_2d)
-
- text = xyf.text_pro("端点1", "微软雅黑", END1_2d, 3, 0, 0.8, "Red", "Solid")
- t_handle = kcs_draft.text_new(text)
- kcs_draft.element_highlight(t_handle)
- kcs_draft.element_delete(t_handle)
- text = xyf.text_pro("端点2", "微软雅黑", END2_2d, 3, 0, 0.8, "Red", "Solid")
- t_handle = kcs_draft.text_new(text)
- kcs_draft.element_highlight(t_handle)
- kcs_draft.element_delete(t_handle)
-
- except:
- pass
-
-
- #高亮同一个SCH的Part
- Shandle = kcs_draft.subview_identify(coord)
- Chandles = xyf.get_sub_handles(Shandle)
- for a in Chandles:
- try:
- model = kcs_draft.model_properties_get(a, model)
- if group_no == kcs_hullpan.group_get(model.Name, model.PartId):
- kcs_draft.element_highlight(a)
- except:
- pass
- kcs_draft.dwg_repaint()
- kcs_ui.app_window_refresh() #刷新屏幕
-
- result = 0
- else:
- result = 0
- except:
- kcs_draft.highlight_off(0)
- kcs_ui.message_confirm('请选择模型')
-
- def xyf_grid_list(self, old_sch):
- z_d = {'STI': '型材', 'PRO': '型材规格', 'SID': '方向', 'QUA': '材质',
- 'ARP': '左装配', 'ARS': '右装配', 'AR': '装配', 'REV': '反向',
- 'CON': '连接型式', 'CUT': '切口', 'BEV': '坡口', 'POS': '位置号',
- 'SHR': '伸缩量', 'PO2': '位置号', 'PLA': '板材', 'MAT': '厚度',
- 'MSI': '板厚方向', 'AS1': '流向1', 'AS2': '流向2', 'AS3': '流向3',
- 'AS4': '流向4', 'COL': '颜色', 'NOT': '角隅', 'BRA': '肘板', 'HOL': '孔',
- 'EXC': '余量', 'BOU': '边界', 'FLA': '面板'}
- old_sch = string.replace(old_sch, " ", " ")
- old_sch = string.replace(old_sch, ", ", " ")
- old_sch = string.replace(old_sch, ";", "")
- if self.GR.GetNumberRows() > 1:
- self.GR.DeleteRows(0, self.GR.GetNumberRows())
- old_sch_list = string.split(old_sch, ' ')
- n = 0
- for old_sch_list_str in old_sch_list:
- self.GR.AppendRows()
- # kcs_ui.message_confirm(old_sch_list_str)
- try:
- b = string.split(old_sch_list_str, '=')
- if z_d.has_key(b[0]):
- self.GR.SetCellValue(n, 0, z_d[b[0]])
- else:
- self.GR.SetCellValue(n, 0, b[0])
- self.GR.SetCellValue(n, 1, b[0])
- if b[0] == 'SID' or b[0] == 'MSI':
- editor = apply(wxGridCellChoiceEditor, (['PS', 'SB', 'TOP', 'BOT', 'FOR', 'AFT'], False))
- self.GR.SetCellEditor(n, 2, editor)
- if b[0] == 'QUA':
- editor = apply(wxGridCellChoiceEditor,
- (['A', 'AH32', 'AH36', 'B', 'D', 'DH32', 'DH36', 'E', 'EH32', 'EH36'], False))
- self.GR.SetCellEditor(n, 2, editor)
-
- if b[0] == 'MAT' or b[0] == 'POS' or b[0] == 'CON':
- editor = apply(wxGridCellNumberEditor, ())
- self.GR.SetCellEditor(n, 2, editor)
- self.GR.SetCellValue(n, 2, b[1])
-
- if b[0] in ["AR","ARS","ARP"]:
- editor = apply(wxGridCellChoiceEditor,(TreeLis, False))
- self.GR.SetCellEditor(n, 2, editor)
- if TreeDic.has_key(b[1][1:-1]):
- self.GR.SetCellValue(n, 2, TreeDic[b[1][1:-1]])
-
- except:
- pass
- n = n + 1
- # self.GR.AutoSizeColumns(True)
- self.GR.AppendRows()
- self.GR.AppendRows()
- self.xyf_new_sch()
-
- def xyf_new_sch(self):
- temp_str = ''
- for fr_no in range(self.GR.GetNumberRows()):
- if self.GR.GetCellValue(fr_no, 1) <> '':
- if self.GR.GetCellValue(fr_no, 2) == '':
- temp_str = temp_str + self.GR.GetCellValue(fr_no, 1) + ", "
- else:
- if self.GR.GetCellValue(fr_no, 1) in ["AR","ARS","ARP"]:
- try:
- temp_str = temp_str + self.GR.GetCellValue(fr_no, 1) + "='" + TreeDic1[self.GR.GetCellValue(fr_no,2)] + "', "
- except:
- temp_str = temp_str + self.GR.GetCellValue(fr_no, 1) + "=" + self.GR.GetCellValue(fr_no,2) + ", "
- else:
- temp_str = temp_str + self.GR.GetCellValue(fr_no, 1) + "=" + self.GR.GetCellValue(fr_no,2) + ", "
- temp_str = temp_str[:-2] + ';'
- self.text_new_sch.Clear()
- self.text_new_sch.AppendText(temp_str)
- class MyApp(wxApp):
- __module__ = __name__
- def __init__(self):
- wxApp.__init__(self, redirect=True)
- def OnInit(self):
- frame = MyFrame(NULL, -1, '模型编辑器')
- frame.Show(true)
- self.SetTopWindow(frame)
- return true
- def run(*args):
- kcs_ui.message_confirm(args)
- if time.time() < time.mktime((2025, 10, 15, 2, 1, 9, 2, 366, 0)):
- app = MyApp()
- app.MainLoop()
- if __name__ == '__main__':
- run()
复制代码 |
|