Beispiel #1
0
def GetSubpictures(father=None,pattern='.*'):
    """Return handles and names of all the subpictures satisfy the regular pattern
    subpicture means view,subview or component.
    father: parent handle of subpicture.
    return views if father is None.
    return: [(handle,name),(handle,name)...]
    """
    ees = []
    try:
        if father==None:
            ee = kcs_draft.element_child_first_get()
        else:
            ee = kcs_draft.element_child_first_get(father)
        name=kcs_draft.subpicture_name_get(ee)
        ees.append((ee,name))
        while True:
            try:
                ee = kcs_draft.element_sibling_next_get(ee)
                name=kcs_draft.subpicture_name_get(ee)
                ees.append((ee,name))
            except:
                break
    except:
        return []
    return [ee for ee in ees if re.match(pattern,ee[1])!=None]
Beispiel #2
0
def GetRegion():  # 获得当前图纸最大范围
    # 获得所有View
    viewList = []
    try:
        view = kcs_draft.element_child_first_get()
        viewList.append(view)
        while True:
            try:
                view = kcs_draft.element_sibling_next_get(view)
                viewList.append(view)
            except:
                break
    except:  # 没有找到任何视图
        return None
    rect = kcs_draft.element_extent_get(viewList[0])
    for view in viewList[1:]:
        rect2 = kcs_draft.element_extent_get(view)
        rect.SetCorner1(Point2D(min(rect.Corner1.X, rect2.Corner1.X), min(rect.Corner1.Y, rect2.Corner1.Y)))
        rect.SetCorner2(Point2D(max(rect.Corner2.X, rect2.Corner2.X), max(rect.Corner2.Y, rect2.Corner2.Y)))
    
    region = CaptureRegion2D()
    region.SetRectangle(rect)
    region.Inside = 1
    region.Cut = 0
    return region
Beispiel #3
0
def GetSubElements(superElement):
    """Return handles of all the sub elements satisfy the regular pattern
    """
    ees = []
    try:
        ee = kcs_draft.element_child_first_get(superElement)
        ees.append(ee)
        while True:
            try:
                ee = kcs_draft.element_sibling_next_get(ee)
                ees.append(ee)
            except:
                break
    except:
        return []
    return ees
Beispiel #4
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
Beispiel #5
0
def GetKtSubView(subViewName): #obsolete, do not use it.
    view=GetKtView()
    print view
    """返回指定名称的subview,若没有则新建一个"""
    try:
        subView = kcs_draft.element_child_first_get(view)
        name = kcs_draft.subpicture_name_get(subView)
        if name == subViewName:
            return subView
        while True:
            subView = kcs_draft.element_sibling_next_get(subView)
            name = kcs_draft.subpicture_name_get(subView)
            if name == subViewName:
                return subView
    except:
        csm=CurrentSubpictureManager()
        csm.Set(view)
        subView = kcs_draft.subview_new(subViewName)
        csm.Back()
        return subView
Beispiel #6
0
def GetID(hSubView):
    """获得批注编号"""
    index=1
    try:
        comp=kcs_draft.element_child_first_get(hSubView)
        name=kcs_draft.subpicture_name_get(comp)
        if name.startswith("NOTE_"):
            n=int(name[5:])
            index=max(index,n)
        while True:
            try:
                comp=kcs_draft.element_sibling_next_get(comp)
                name=kcs_draft.subpicture_name_get(comp)
                if name.startswith("NOTE_"):
                    n=int(name[5:])
                    index=max(index,n)
            except:
                break
    except:
        return index
    return index+1
Beispiel #7
0
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
Beispiel #8
0
         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
 sList=Stringlist("ok") #获得批注内容列表
 for hNote in hNoteList: 
     noteName=kcs_draft.subpicture_name_get(hNote)
     #找到文字
     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) #显示批注列表