コード例 #1
0
def FindText():
    res=kcs_ui.string_req('请输入需要查找的文字','')
    if res[0]==kcs_util.ok():
        hdList=FindString(res[1])
        if len(hdList) == 1:
            ZoomElement(hdList[0])
            res=kcs_ui.answer_req('Find','是否要替换文本?')
            if res[0]==kcs_util.yes():
                ReplaceOne(hdList[0])
        elif len(hdList) > 1:
            ZoomElement(hdList[0])
            index=1
            while True:
                if index>len(hdList):
                    kcs_ui.message_noconfirm("已经是最后一个")
                    return
                res=kcs_ui.answer_req(r'共找到%s个,当前第%s个'%(len(hdList),index),'是否要替换文本?')
                if res==kcs_util.yes():
                    ReplaceOne(hdList[index-1])
                    index+=1
                    continue
                elif res==kcs_util.no():
                    ZoomElement(hdList[index])
                    index+=1
                    continue
                else:
                    return
        elif len(hdList) == 0:
            kcs_ui.message_confirm("没有找到任何匹配的文字")
コード例 #2
0
def GetNewStmt(stmt, pos, number):
    index1 = stmt.index('CON=')
    s1 = stmt[0:index1] + pos + '1=' + str(number) + ', ' + stmt[index1:]   
    index2 = stmt.index('CON=', index1 + 1)
    s2 = stmt[0:index2] + pos + '2=' + str(number) + ', ' + stmt[index2:]
    kcs_ui.message_noconfirm(s1)
    kcs_ui.message_noconfirm(s2)
    return (s1, s2)
コード例 #3
0
def ZoomElement(element):
    try:
        rect = kcs_draft.element_extent_get(element)
        rect.SetCorner1(Point2D(rect.Corner1.X - 100, rect.Corner1.Y - 100))
        rect.SetCorner2(Point2D(rect.Corner2.X + 100, rect.Corner2.Y + 100))
        kcs_draft.dwg_zoom(rect)
    except:
        kcs_ui.message_noconfirm('Failed to zoom text')
コード例 #4
0
def DeleteNote():
    pt=Point2D()
    res=kcs_ui.point2D_req("请选择要删除的批注",pt)
    if res[0]==kcs_util.ok():
        try:
            hText=kcs_draft.text_identify(pt)
            comp=kcs_draft.element_parent_get(hText)
            compName=kcs_draft.subpicture_name_get(comp)
            if compName.startswith("NOTE_"):
                kcs_draft.element_delete(comp)
        except Exception,e:
            kcs_ui.message_noconfirm(e.message)
コード例 #5
0
def FindAndReplace():
    res, txt = kcs_ui.string_req("请输入需要查找的内容", "")
    if res == kcs_util.ok():
        hdList = FindString(txt)
        if len(hdList) == 1:
            ZoomElement(hdList[0])
            Replace(hdList)
        elif len(hdList) > 1:
            kcs_ui.message_noconfirm("找到" + str(len(hdList)) + "个匹配的文字,将显示第一个")
            ZoomElement(hdList[0])
            Replace(hdList)
        elif len(hdList) == 0:
            kcs_ui.message_confirm("没有找到任何匹配的文字")
コード例 #6
0
def FindString(content):
    """返回所有匹配的Text handle"""
    region = GetRegion()
    hds = []
    try:
        hds = kcs_draft.text_capture(region)
    except:
        kcs_ui.message_noconfirm("没有找到文字")
        return []
    txtList = []
    for hd in hds[1:]:
        txt = Text()
        kcs_draft.text_properties_get(hd, txt)
        if txt.GetString().upper() == content.upper():
            txtList.append(hd)
    return txtList
コード例 #7
0
ファイル: ktDraft.py プロジェクト: weizx208/iknot-tribon
def CleanDwg():
    oldSize = kcs_draft.dwg_size_get()  # in Kbyes
    name = kcs_draft.dwg_name_get()
    
    kcs_draft.dwg_pack()
    kcs_draft.dwg_purge()
    kcs_util.clean_workspace()
    
    newSize = kcs_draft.dwg_size_get()
    
    msg = """图纸:%s清理完毕
清理前大小:%s Kbytes
清理后大小:%s Kbytes
""" % (name, oldSize, newSize)
    
    kcs_ui.message_noconfirm(msg)
コード例 #8
0
def ShowNote():
    hNoteList=[] #获得note列表
    try:
        subView=ktDraft.GetKtSubView(SUB_VIEW_NAME)
        comp=kcs_draft.element_child_first_get(subView)
        compName=kcs_draft.subpicture_name_get(comp)
        if compName.startswith("NOTE_"):
            hNoteList.append(comp)
        while True:
            try:
                comp=kcs_draft.element_sibling_next_get(comp)
                compName=kcs_draft.subpicture_name_get(comp)
                if compName.startswith("NOTE_"):
                    hNoteList.append(comp)
            except:
                break
    except Exception,e:
        kcs_ui.message_noconfirm(e.message)
        return
コード例 #9
0
ファイル: GenFakeKcs.py プロジェクト: weizx208/iknot-tribon
def GenPy(mod, fname):
    """generate py file from given module.
    mod:module object.
    fname:file full path.
    """
    f = open(fname, 'w')
    title = """#
# This file is generated automatically
# Author:IAN
# http://www.iknot.org
"""
    f.write(title)
    for i in mod.__dict__.keys():
        s = "def " + i + "():" + "\n"
        f.write(s)
        s = "    return"
        f.write(s + "\n")
    f.close()
    kcs_ui.message_noconfirm('py file saved to:%s' % (fname))
コード例 #10
0
ファイル: GenFakeKcs.py プロジェクト: knottech/iknot-tribon
def GenPy(mod, fname):
    """generate py file from given module.
    mod:module object.
    fname:file full path.
    """
    f = open(fname, "w")
    title = """#
# This file is generated automatically
# Author:IAN
# http://www.iknot.org
"""
    f.write(title)
    for i in mod.__dict__.keys():
        s = "def " + i + "():" + "\n"
        f.write(s)
        s = "    return"
        f.write(s + "\n")
    f.close()
    kcs_ui.message_noconfirm("py file saved to:%s" % (fname))
コード例 #11
0
ファイル: ktDraft.py プロジェクト: weizx208/iknot-tribon
def GetKtComponent(compName, subView): #obsolete, do not use it.
    """返回指定名称的component,若没有则新建一个"""
    # subView=GetTitSubView(subViewName)
    name = kcs_draft.subpicture_name_get(subView)
    try:
        comp = kcs_draft.element_child_first_get(subView)
        name = kcs_draft.subpicture_name_get(comp)
        if name == compName:
            return comp
        while True:
            comp = kcs_draft.element_sibling_next_get(comp)
            name = kcs_draft.subpicture_name_get(comp)
            kcs_ui.message_noconfirm(name)
            if name == compName:
                return comp
    except:
        old = kcs_draft.subpicture_current_get()
        kcs_draft.subpicture_current_set(subView)
        comp = kcs_draft.component_new(compName)
        if len(old) == 3:
            kcs_draft.subpicture_current_set(old[2])
        return comp
コード例 #12
0
def DisplayAll():
    try:
        subView=ktDraft.GetKtSubView(SUB_VIEW_NAME)
        kcs_draft.element_visibility_set(subView,1)
    except Exception,e:
        kcs_ui.message_noconfirm(e.message)
コード例 #13
0
        #找到文字
        try:
            ee=kcs_draft.element_child_first_get(hNote)
            txt=Text()
            if kcs_draft.element_is_text(ee):
                txt=kcs_draft.text_properties_get(ee,txt)
                sList.AddString(noteName+" : "+txt.GetString())
                continue
            while True:
                ee=kcs_draft.element_sibling_next_get(ee)
                if kcs_draft.element_is_text(ee):
                    txt=kcs_draft.text_properties_get(ee.txt)
                    sList.AddString(noteName+" : "+txt.GetString())
                    break
        except Exception,e:
            kcs_ui.message_noconfirm(e.message)
    sList.StrList=sList.StrList[1:]
    res=kcs_ui.string_select("批注","批注列表","请选择批注",sList) #显示批注列表
    if res[0]==kcs_util.ok():
        index=res[1]
        hNote=hNoteList[index-1]
        rect=kcs_draft.element_extent_get(hNote) #缩放
        factor=50
        rect.SetCorner1(Point2D(rect.Corner1.X-factor,rect.Corner1.Y-factor))
        rect.SetCorner2(Point2D(rect.Corner2.X+factor,rect.Corner2.Y+factor))
        kcs_draft.dwg_zoom(rect)
                    
    
def GetID(hSubView):
    """获得批注编号"""
    index=1
コード例 #14
0
def Msg(message):
    kcs_ui.message_noconfirm(message)