Пример #1
0
def Grid():
    """Create a grid on a new view"""
    res=kcs_ui.string_req('请输入格子的长,宽、列数,行数','30,10,8,5')
    if res[0]==kcs_util.ok():
        w,h,m,n=[float(i) for i in res[1].split(',')]
        pt=Point2D()
        res=kcs_ui.point2D_req('请选择Grid左上角位置,回车设为原点',pt)
        if res[0]==kcs_util.ok():
            csm=CurrentSubpictureManager()
            hd=kcs_draft.view_new('')
            csm.Set(hd)
            for i in range(n+1):    #horizontal line
                p1=Point2D(pt.X,pt.Y-h*i)
                p2=Point2D(pt.X+w*m,pt.Y-h*i)
                kcs_draft.line_new(Rline2D(p1,p2))
            for j in range(m+1):    #vertical line
                p1=Point2D(pt.X+j*w,pt.Y)
                p2=Point2D(pt.X+j*w,pt.Y-h*n)
                kcs_draft.line_new(Rline2D(p1,p2))
            csm.Back()
        elif res[0]==kcs_util.operation_complete():
            pt=Point2D(0,0)
            csm=CurrentSubpictureManager()
            hd=kcs_draft.view_new('')
            csm.Set(hd)
            for i in range(n+1):    #horizontal line
                p1=Point2D(pt.X,pt.Y-h*i)
                p2=Point2D(pt.X+w*m,pt.Y-h*i)
                kcs_draft.line_new(Rline2D(p1,p2))
            for j in range(m+1):    #vertical line
                p1=Point2D(pt.X+j*w,pt.Y)
                p2=Point2D(pt.X+j*w,pt.Y-h*n)
                kcs_draft.line_new(Rline2D(p1,p2))
            csm.Back()
Пример #2
0
def run():
    """
Do not place the fake vitesse file at python path.
Place it at 'external libraries' of eclipse is recommended
"""
    names = [i.__name__ for i in modList]
    res, action = kcs_ui.string_select(
        'fake vitesse generator',
        'Please select the module you want to generate fake vitesse py.',
        'Press option to generate for all modules.', names)
    if res == kcs_util.ok():
        mod = modList[action - 1]
        des = kcs_ui.string_req('Where do you want to place the file?',
                                r'C:\temp')
        if des[0] == kcs_util.ok():
            #         des = os.path.join(os.path.join(os.getcwd(), "FakeVitesse"))
            fname = des[1] + "\\" + mod.__name__ + ".py"
            GenPy(mod, fname)
    elif res == kcs_util.options():
        des = kcs_ui.string_req('Where do you want to place the file?',
                                r'C:\temp')
        if des[0] == kcs_util.ok():
            for mod in modList:
                fname = des[1] + "\\" + mod.__name__ + ".py"
                GenPy(mod, fname)
Пример #3
0
def run():
    """
Do not place the fake vitesse file at python path.
Place it at 'external libraries' of eclipse is recommended
"""
    names = [i.__name__ for i in modList]
    res, action = kcs_ui.string_select(
        "fake vitesse generator",
        "Please select the module you want to generate fake vitesse py.",
        "Press option to generate for all modules.",
        names,
    )
    if res == kcs_util.ok():
        mod = modList[action - 1]
        des = kcs_ui.string_req("Where do you want to place the file?", r"C:\temp")
        if des[0] == kcs_util.ok():
            #         des = os.path.join(os.path.join(os.getcwd(), "FakeVitesse"))
            fname = des[1] + "\\" + mod.__name__ + ".py"
            GenPy(mod, fname)
    elif res == kcs_util.options():
        des = kcs_ui.string_req("Where do you want to place the file?", r"C:\temp")
        if des[0] == kcs_util.ok():
            for mod in modList:
                fname = des[1] + "\\" + mod.__name__ + ".py"
                GenPy(mod, fname)
Пример #4
0
def run():
    pt = Point2D()
    res = kcs_ui.point2D_req('请选择中心点', pt)
    if res[0] == kcs_util.ok():
        res2 = kcs_ui.string_req('请输入菱形的尺寸', '300,100')
        if res2[0] == kcs_util.ok():
            li = [float(s) for s in res2[1].split(',')]
            if len(li) == 2:
                a, b = li
            else:
                raise 'wrong input'
            ktBasic.Diamond(res[1], a, b)
Пример #5
0
def run():
    pt=Point2D()
    res=kcs_ui.point2D_req('请选择中心点',pt)
    if res[0]==kcs_util.ok():
        res2=kcs_ui.string_req('请输入菱形的尺寸','300,100')
        if res2[0]==kcs_util.ok():
            li=[float(s) for s in res2[1].split(',')]
            if len(li)==2:
                a,b=li
            else:
                raise 'wrong input'
            ktBasic.Diamond(res[1], a, b)
Пример #6
0
def ChangeColumnText():
    pt=Point2D()
    res=kcs_ui.point2D_req('Please select the column',pt)
    if res[0]==kcs_util.ok():
        hdView=kcs_draft.view_identify(res[1])
        comp=kcs_draft.component_identify(res[1])
        #get column index from comp name
        name=kcs_draft.subpicture_name_get(comp)
        colIndex=int(name[2:].split('X')[0])
        table=Table(hdView)
        res=kcs_ui.string_req('Please enter the string','iknot')
        if res[0]==kcs_util.ok():
            table.ChangeColumnText(colIndex, res[1])
Пример #7
0
def MoveColumn():
    pt=Point2D()
    res=kcs_ui.point2D_req('Please select the column',pt)
    if res[0]==kcs_util.ok():
        hdView=kcs_draft.view_identify(res[1])
        comp=kcs_draft.component_identify(res[1])
        
        #get column index from comp name
        name=kcs_draft.subpicture_name_get(comp)
        colIndex=int(name[2:].split('X')[0])
        table=Table(hdView)
        res=kcs_ui.int_req('Please enter the offset',100)
        if res[0]==kcs_util.ok():
            table.MoveColumn(colIndex, res[1])
Пример #8
0
def run():
    pt=Point2D()
    res=kcs_ui.point2D_req('请选择中心点',pt)
    if res[0]==kcs_util.ok():
        res2=kcs_ui.string_req('请输入外接圆半径、数量和旋转角度(默认为0)','100,6,0')
        if res2[0]==kcs_util.ok():
            li=[float(s) for s in res2[1].split(',')]
            radius,number,angle=0.0,0.0,0.0
            if len(li)==2:
                radius,number=li
            elif len(li)==3:
                radius,number,angle=li
            else:
                raise 'wrong input'
            ktBasic.Polygon(res[1], radius, number, angle)
Пример #9
0
def SelectTexts():
    cor1 = Point2D()
    cor2 = Point2D()
    res = kcs_ui.point2D_req("请选择区域左上角", cor1)
    if res[0] == kcs_util.ok():
        res = kcs_ui.point2D_req("请选择区域右下角", cor2)
        if res[0] == kcs_util.ok():
            rect = Rectangle2D(cor1, cor2)
            region = CaptureRegion2D()
            region.SetRectangle(rect)
            region.Inside = 1
            region.Cut = 1
            hds = kcs_draft.text_capture(region)
            return hds
    return
Пример #10
0
def run():
    pt = Point2D()
    res = kcs_ui.point2D_req('请选择中心点', pt)
    if res[0] == kcs_util.ok():
        res2 = kcs_ui.string_req('请输入外接圆半径、数量和旋转角度(默认为0)', '100,6,0')
        if res2[0] == kcs_util.ok():
            li = [float(s) for s in res2[1].split(',')]
            radius, number, angle = 0.0, 0.0, 0.0
            if len(li) == 2:
                radius, number = li
            elif len(li) == 3:
                radius, number, angle = li
            else:
                raise 'wrong input'
            ktBasic.Polygon(res[1], radius, number, angle)
Пример #11
0
def GetPosition():
    actions = ('X', 'Y', 'Z')
    (res, index) = kcs_ui.choice_select('select', \
                                     'Please select line position', actions)
    if res == kcs_util.ok():
        (res, d) = kcs_ui.real_req('Please enter the number')
        if res == kcs_util.ok():
            if index == 1:
                return ('X', d)
            elif index == 2:
                return ('Y', d)
            elif index == 3:
                return ('Z', d)
    else:
        return 0
Пример #12
0
def CreateEmptyTable():
    """
    Create an m x n table without text.
    
    """
    res=kcs_ui.string_req('please enter the column number,row number and the width of each cell',
                          '5,3,30')
    if res[0]==kcs_util.ok():
        li=res[1].split(',')
        m,n,width=int(li[0]),int(li[1]),float(li[2])
        pt=Point2D()
        res=kcs_ui.point2D_req('Please pick the left-top corner of table.',pt)
        if res[0]==kcs_util.ok():
            t=Table()
            t.Init(m, n, width, res[1])
            t.Draw()
Пример #13
0
def Point3DCoord():
    "show the coordinate of selected point"
    pt = Point2D()
    res = kcs_ui.point2D_req("请选择要查询的点", pt)

    if res[0] == kcs_util.ok():
        res = kcs_util.tra_coord_ship(pt.X, pt.Y, "")
        if res[0] == 0:
            pt3d = Point3D(res[1], res[2], res[3])
            res, fr, fr_offset = kcs_util.coord_to_pos(1, pt3d.X)
            res, lp_y, lp_y_offset = kcs_util.coord_to_pos(2, pt3d.Y)
            res, lp_z, lp_z_offset = kcs_util.coord_to_pos(3, pt3d.Z)
            fr_offset=round(fr_offset,2)
            lp_y_offset=round(lp_y_offset,2)
            lp_z_offset=round(lp_z_offset,2)
            x=round(pt3d.X,2)
            y=round(pt3d.Y,2)
            z=round(pt3d.Z,2)

            Msg("--"*25)
            Msg("二维点:" + str(pt))
            Msg("三维坐标信息:")
            Msg("X: %s,FR%s %s" % (string.ljust(str(x), width), str(fr), _fmt(fr_offset)))
            Msg("Y: %s,LP%s %s" % (string.ljust(str(y), width), str(lp_y), _fmt(lp_y_offset)))
            Msg("Z: %s,LP%s %s" % (string.ljust(str(z), width), str(lp_z), _fmt(lp_z_offset)))
            Msg("--"*25)
Пример #14
0
def run():
    stat=KcsStat_point2D_req.Stat_point2D_req()
    ct=CursorType()
    
    CursorTypes = {'CrossHair' : 1, 'RubberBand' : 2, 'RubberRectangle' : 3, 'RubberCircle' : 4, 'DragCursor' : 5}
    
    actions=CursorTypes.keys()
    
    bs=ButtonState()
    bs.EnableLock(1)
    bs.SetCheckedLock('V')
    
    pt=Point2D(2,3)
    while True:
        res=kcs_ui.choice_select('title','header',actions)
        if res[0]==kcs_util.ok():
            #msg("%s:%s"%(res[1],CursorTypes.keys()[res[1]-1]))
            if res[1]==1:
                ct.SetCrossHair()
            elif res[1]==2:
                ct.SetRubberBand(pt)
            elif res[1]==3:
                ct.SetRubberRectangle(pt)
            elif res[1]==4:
                ct.SetRubberCircle(pt)
            elif res[1]==5:
                pass
            stat.SetCursorType(ct)
            stat.SetDefMode('ModeMidPoint')
            stat.SetHelpPoint(Point2D(0,0))
            msg(ct)
            res,pt2=kcs_ui.point2D_req('msg',pt,stat,bs)
            msg(pt2)
        else:
            break
Пример #15
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("没有找到任何匹配的文字")
Пример #16
0
def run():
    res, action = kcs_ui.choice_select(
        'User response', 'Choices', ['Print all', 'Response of point2D_req'])
    if res == util.ok():
        if action == 1:
            PrintAll()
        elif action == 2:
            PrintUserResponse()
Пример #17
0
def CreateTable(li):
    """create table from a python list"""
    pt=Point2D()
    res=kcs_ui.point2D_req('Please pick the left-top corner of table.',pt)
    if res[0]==kcs_util.ok():
        t=Table()
        t.ReadList(li)
        t.Draw()
Пример #18
0
def run():
    res,action=kcs_ui.choice_select('User response','Choices',
        ['Print all','Response of point2D_req'])
    if res==util.ok():
        if action==1:
            PrintAll()
        elif action==2:
            PrintUserResponse()
Пример #19
0
def SelectText():
    "select a text from drawing"
    pt=Point2D()
    res=kcs_ui.point2D_req('请选择文字',pt)
    if res[0]==kcs_util.ok():
        try:
            hdText=kcs_draft.text_identify(res[1])
            return hdText
        except:
            return None
Пример #20
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)
Пример #21
0
def PrintAll():
    msg("ok():%s" % util.ok())
    msg("cancel():%s" % util.cancel())
    msg("quit():%s" % util.quit())
    msg("options():%s" % util.options())
    msg("operation_complete():%s" % util.operation_complete())
    msg("yes():%s" % util.yes())
    msg("no():%s" % util.no())
    msg("all():%s" % util.all())
    msg("undo():%s" % util.undo())
    msg("reject():%s" % util.reject())
    msg("exit_function():%s" % util.exit_function())
Пример #22
0
def PrintAll():
    msg("ok():%s" % util.ok())
    msg("cancel():%s" % util.cancel())
    msg("quit():%s" % util.quit())
    msg("options():%s" % util.options())
    msg("operation_complete():%s" % util.operation_complete())
    msg("yes():%s" % util.yes())
    msg("no():%s" % util.no())
    msg("all():%s" % util.all())
    msg("undo():%s" % util.undo())
    msg("reject():%s" % util.reject())
    msg("exit_function():%s" % util.exit_function())
Пример #23
0
def Pick2DPoints(number=0,mode="ModeAuto"):
    """
    Pick points until reach the number.
    number=0 means unlimited number.
    """
    pts=[]
    index=0
    action=kcs_util.ok()
    while index<number or number==0:
        pt=Point2D()
        stp=Stat_point2D_req()
        stp.SetDefMode(mode)
        action,pt=kcs_ui.point2D_req('ÇëÑ¡ÔñµÚ%s¸öµã'%(index+1),pt,stp)
        if action==kcs_util.ok():
            pts.append(pt)
        elif action==kcs_util.operation_complete() and number==0:
            return pts
        elif action==kcs_util.cancel():
            print 'operation canceled'
            return None
        index+=1
    return pts
Пример #24
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("没有找到任何匹配的文字")
Пример #25
0
def Pick2DPoints(number=0, mode="ModeAuto"):
    """
    Pick points until reach the number.
    number=0 means unlimited number.
    """
    pts = []
    index = 0
    action = kcs_util.ok()
    while index < number or number == 0:
        pt = Point2D()
        stp = Stat_point2D_req()
        stp.SetDefMode(mode)
        action, pt = kcs_ui.point2D_req('ÇëÑ¡ÔñµÚ%s¸öµã' % (index + 1), pt,
                                        stp)
        if action == kcs_util.ok():
            pts.append(pt)
        elif action == kcs_util.operation_complete() and number == 0:
            return pts
        elif action == kcs_util.cancel():
            print 'operation canceled'
            return None
        index += 1
    return pts
Пример #26
0
def FormatSingle():
    pt = Point2D()
    res = kcs_ui.point2D_req("请选择文字获取文字属性", pt)
    if res[0] == kcs_util.ok():
        hd = kcs_draft.text_identify(pt)
        ori = Text()
        kcs_draft.text_properties_get(hd, ori)
#         old = kcs_draft.subpicture_current_get()  # 当前图层
        while True:
            "select single text"
            pt2=Point2D()
            res = kcs_ui.point2D_req("请选择要替换的文字", pt2)
            if res[0]==kcs_util.ok():
                hdText=kcs_draft.text_identify(pt2)
                father = kcs_draft.element_parent_get(hdText)  # 文字所在图层
                t = Text()
                kcs_draft.text_properties_get(hdText, t)
                ori.SetString(t.GetString())
                ori.SetPosition(t.GetPosition())
                kcs_draft.element_delete(hdText)  # 删除原文字
                kcs_draft.subpicture_current_set(father)  # 重设图层
                kcs_draft.text_new(ori)  # 写文字
            else:
                break
Пример #27
0
def ReplaceOne(hdText):
    "replace one text"
    txt=Text()
    kcs_draft.text_properties_get(hdText,txt)
    res=kcs_ui.string_req('请输入要替换的文本',txt.String)
    if res[0]==kcs_util.ok():
        old = kcs_draft.subpicture_current_get() #make the old subpicture
        father = kcs_draft.element_parent_get(hdText)  # 文字所在图层
        txt.SetString(res[1])
        kcs_draft.element_delete(hdText)  # 删除原文字
        kcs_draft.subpicture_current_set(father)  # 重设图层
        kcs_draft.text_new(txt)  # 写文字
        if len(old) == 3:
            kcs_draft.subpicture_current_set(old[2])
        else:
            kcs_draft.subpicture_current_set()
Пример #28
0
def CreateForm():
    "create a form with n pages."
    #check whether view exist.
    ViewName = 'KT_FORM'
    for view in ktDraft.GetViews():
        if view[1] == 'KT_FORM':
            print 'view already exist.'
            return
    hd = kcs_draft.view_new(ViewName)
    res = kcs_ui.int_req("How many pages do you want?", 1)
    if res[0] == kcs_util.ok():
        for i in range(res[1]):
            pg = Page()
            pg.Location = Point2D(i * 420, 0)
            pg.Index = i + 1
            kcs_draft.subpicture_current_set(hd)
            pg.Draw()
    kcs_draft.dwg_purge()
Пример #29
0
def Replace(hdList):
    res = kcs_ui.answer_req("文字替换", "是否要替换文字?")
    if res == kcs_util.yes():
        txt = Text()
        kcs_draft.text_properties_get(hdList[0], txt)
        res = kcs_ui.string_req("请输入要替换的文字", txt.GetString())
        if res[0] == kcs_util.ok():
            content = res[1]
            old = kcs_draft.subpicture_current_get()
            for hd in hdList:
                father = kcs_draft.element_parent_get(hd)  # 文字所在图层
                kcs_draft.text_properties_get(hd, txt)
                txt.SetString(content)
                kcs_draft.element_delete(hd)  # 删除原文字
                kcs_draft.subpicture_current_set(father)  # 重设图层
                kcs_draft.text_new(txt)  # 写文字
            if len(old) == 3:
                kcs_draft.subpicture_current_set(old[2])
            else:
                kcs_draft.subpicture_current_set()
Пример #30
0
def run():
    stat = KcsStat_point2D_req.Stat_point2D_req()
    ct = CursorType()

    CursorTypes = {
        'CrossHair': 1,
        'RubberBand': 2,
        'RubberRectangle': 3,
        'RubberCircle': 4,
        'DragCursor': 5
    }

    actions = CursorTypes.keys()

    bs = ButtonState()
    bs.EnableLock(1)
    bs.SetCheckedLock('V')

    pt = Point2D(2, 3)
    while True:
        res = kcs_ui.choice_select('title', 'header', actions)
        if res[0] == kcs_util.ok():
            #msg("%s:%s"%(res[1],CursorTypes.keys()[res[1]-1]))
            if res[1] == 1:
                ct.SetCrossHair()
            elif res[1] == 2:
                ct.SetRubberBand(pt)
            elif res[1] == 3:
                ct.SetRubberRectangle(pt)
            elif res[1] == 4:
                ct.SetRubberCircle(pt)
            elif res[1] == 5:
                pass
            stat.SetCursorType(ct)
            stat.SetDefMode('ModeMidPoint')
            stat.SetHelpPoint(Point2D(0, 0))
            msg(ct)
            res, pt2 = kcs_ui.point2D_req('msg', pt, stat, bs)
            msg(pt2)
        else:
            break
Пример #31
0
def FormatRegion():
    pt = Point2D()
    res = kcs_ui.point2D_req("请选择文字获取文字属性", pt)
    if res[0] == kcs_util.ok():
        hd = kcs_draft.text_identify(pt)
        ori = Text()
        kcs_draft.text_properties_get(hd, ori)
        objs = SelectTexts()
        old = kcs_draft.subpicture_current_get()  # 当前图层
        for obj in objs[1:]:  # 重写文字
            father = kcs_draft.element_parent_get(obj)  # 文字所在图层
            t = Text()
            kcs_draft.text_properties_get(obj, t)
            ori.SetString(t.GetString())
            ori.SetPosition(t.GetPosition())
            kcs_draft.element_delete(obj)  # 删除原文字
            kcs_draft.subpicture_current_set(father)  # 重设图层
            kcs_draft.text_new(ori)  # 写文字
        if len(old) == 3:
            kcs_draft.subpicture_current_set(old[2])
        else:
            kcs_draft.subpicture_current_set()
Пример #32
0
def main():
    dataExtra = aadAssDataExtraction.DataExtraction()

    temp_file = '%s\\%s.txt' % (
        os.environ['TEMP'], datetime.datetime.now().strftime('%y%m%d%H%M%S'))
    f = open(temp_file, 'w')
    f.writelines('%20s %20s %20s %20s %20s %20s\n' %
                 ('设备名', '重量', 'X', 'Y', 'Z', '模块'))
    res, input_name = kcs_ui.string_req('请输入设备名称', '')
    if res == kcs_util.ok():
        dex_str = "EQUIPMENT.ITEM('%s'*).NAME" % input_name
        dataExtra.ExtractData(dex_str)

        eqp_name_list = dataExtra.DataResult
        for eqp_name in eqp_name_list:

            dex_str = "EQUIPMENT.ITEM('%s').REFERENCE.POINT" % eqp_name
            dataExtra.ExtractData(dex_str)
            ref_point = dataExtra.DataResult[0]

            dex_str = "EQUIPMENT.ITEM('%s').COMP_NAME" % eqp_name
            dataExtra.ExtractData(dex_str)
            comp_name = dataExtra.DataResult[0]
            weight = 0

            dex_str = "COMPONENT('%s').GEN_PROPERTY.WEIGHT" % comp_name
            dataExtra.ExtractData(dex_str)
            weight = dataExtra.DataResult[0]

            dex_str = "EQUIPMENT.ITEM('%s').MODULE(*).NAME" % eqp_name
            dataExtra.ExtractData(dex_str)
            mod_name = dataExtra.DataResult[0]

            f.writelines('%20s %20s %20s %20s %20s %20s\n' %
                         (eqp_name, round(weight), round(ref_point[0]),
                          round(ref_point[1]), round(ref_point[2]), mod_name))
    f.close()
    os.startfile(temp_file)
Пример #33
0
def run():
    actions=['View','Subview','Component','Element']
    res,act=kcs_ui.choice_select('View info','Select the type',actions)
    if res==kcs_util.ok():
        pt=Point2D()
        if act==1:
            ees=ktDraft.GetViews()
            printElements(ees)
        elif act==2:
            kcs_ui.point2D_req('Select',pt)
            hd=kcs_draft.view_identify(pt)
            ees=ktDraft.GetSubviews(hd)
            printElements(ees)
        elif act==3:
            kcs_ui.point2D_req('Select',pt)
            hd=kcs_draft.subview_identify(pt)
            ees=ktDraft.GetComponents(hd)
            printElements(ees)
        elif act==4:
            kcs_ui.point2D_req('Select',pt)
            hd=kcs_draft.component_identify(pt)
            ees=ktDraft.GetSubElements(hd)
            printElements(ees)
Пример #34
0
def AddNote():
    res=kcs_ui.string_req("请输入标注内容")
    if res[0]==kcs_util.ok():
        content=res[1]
        cor1=Point2D()
        cor2=Point2D()
        res=kcs_ui.point2D_req("请选择标注点",cor1)
        if res[0]==kcs_util.ok():
            res=kcs_ui.point2D_req("请选择标注文字位置",cor2)
            if res[0]==kcs_util.ok(): #开始标注
                #记录原来状态
                old=kcs_draft.subpicture_current_get()
                
                #创建component
                subView=ktDraft.GetKtSubView(SUB_VIEW_NAME)
                #检查是否在KNOT_VIEW下
                parent=kcs_draft.element_parent_get(subView)
                parentName=kcs_draft.subpicture_name_get(parent)
                if parentName!="KNOT_VIEW":
                    return
                kcs_draft.subpicture_current_set(subView)
                compName="NOTE_"+str(GetID(subView))
                comp=kcs_draft.component_new(compName)
                kcs_draft.subpicture_current_set(comp)
                
                #写文字
                txt=Text(content)
                txt.SetPosition(cor2)
                txt.SetColour(Colour("Red"))
                txt.SetFont("黑体")
                txt.SetHeight(5)
                hTxt=kcs_draft.text_new(txt)
                
                #画边框
                rect=Rectangle2D()
                rect=kcs_draft.element_extent_get(hTxt)
                offset=1
                rect.SetCorner1(Point2D(rect.Corner1.X-offset,rect.Corner1.Y-offset))
                rect.SetCorner2(Point2D(rect.Corner2.X+offset,rect.Corner2.Y+offset))
                hd=kcs_draft.rectangle_new(rect)
                kcs_draft.element_colour_set(hd,Colour("Red"))
                
                #画引线
                sta=cor1
                end=rect.GetCorner1()
                if end.X<sta.X:
                    end.SetX(end.X+rect.Corner2.X-rect.Corner1.X)
                if end.Y<sta.Y:
                    end.SetY(end.Y+rect.Corner2.Y-rect.Corner1.Y)
                line=Rline2D(sta,end)
                hd=kcs_draft.line_new(line)
                kcs_draft.element_colour_set(hd,Colour("Red"))
                
                #画圆圈
                circle=Circle2D(sta,2)
                hd=kcs_draft.circle_new(circle)
                kcs_draft.element_colour_set(hd,Colour("Red"))
                
                #恢复原来状态
                if len(old)==3:
                    kcs_draft.subpicture_current_set(old[2])
                else:
                    kcs_draft.subpicture_current_set()
Пример #35
0
            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
    try:
        comp=kcs_draft.element_child_first_get(hSubView)
        name=kcs_draft.subpicture_name_get(comp)