twk Posted August 25, 2020 Share Posted August 25, 2020 Greetings all, Anyone got the vs.SetLBHierDispColumn function to work? I can't seem to get it to display the listbrowser in a hierarchy. Just checking to see if possible/or if i'm doing something wrong before I file a bug report. Cheers Tui Quote Link to comment
Gelde-Aart Posted August 31, 2020 Share Posted August 31, 2020 Hi Tui, Below an example script (I had to port and clean it from Vectorworks 2013): kLB001 = 4 kPB_Expand = 5 kPB_Collapse = 6 import vs def dialogHandler(item, data): if item == 12255: nCol = vs.InsertLBColumn(dialID,kLB001,0,'Item',150) bResult = vs.SetLBControlType(dialID,kLB001,0,1) bResult = vs.SetLBItemDisplayType(dialID,kLB001,0,3) #Some Lines to fill the listbrowser nItem = vs.InsertLBItem(dialID,kLB001,0,'2D-Axis') nItem = vs.InsertLBItem(dialID,kLB001,1,'2D-Cap') nItem = vs.InsertLBItem(dialID,kLB001,2,'2D-Housing-Back') nItem = vs.InsertLBItem(dialID,kLB001,3,'2D-Housing-Frame') nItem = vs.InsertLBItem(dialID,kLB001,4,'2D-Housing-Glass') nItem = vs.InsertLBItem(dialID,kLB001,5,'2D-Leaf-Back') nItem = vs.InsertLBItem(dialID,kLB001,6,'2D-Leaf-Frame') nItem = vs.InsertLBItem(dialID,kLB001,7,'2D-Leaf-Glass') nItem = vs.InsertLBItem(dialID,kLB001,8,'3D-Axis') nItem = vs.InsertLBItem(dialID,kLB001,9,'3D-Cap') nItem = vs.InsertLBItem(dialID,kLB001,10,'3D-Housing-Frame') nItem = vs.InsertLBItem(dialID,kLB001,11,'3D-Housing-Glass') nItem = vs.InsertLBItem(dialID,kLB001,12,'3D-Leaf-Frame') nItem = vs.InsertLBItem(dialID,kLB001,13,'3D-Leaf-Glass') vs.EnableLBSorting(dialID,kLB001,False) vs.SetLBHierDispColumn(dialID,kLB001,0) vs.EnableLBHierDisplay(dialID,kLB001,True) global numLBItems #has to be a global, otherwise it won't work... numLBItems = vs.GetNumLBItems(dialID,kLB001) elif item == kLB001: LBrecursive = True bResult = vs.GetLBEventInfo(dialID,kLB001,LBeventType,LBrowIndex,LBcolumIndex) if vs.HierLBItemIsClosed(dialID,kLB001,LBrowIndex): numbRedisplItems = vs.HierLBItemOpened(dialID,kLB001,LBrowIndex,False) else: vs.HierLBItemClosed(dialID,kLB001,LBrowIndex,False) elif item == kPB_Expand: for i in range(numLBItems): if vs.HierLBItemIsClosed(dialID,kLB001,i): numbRedisplItems = vs.HierLBItemOpened(dialID,kLB001,i,True) elif item == kPB_Collapse: for i in range(numLBItems): if vs.HierLBItemIsClosed(dialID,kLB001,i) == False: vs.HierLBItemClosed(dialID,kLB001,i,True) def rundialog(): global dialID dialID = vs.CreateResizableLayout('Test Listbrowser',True,'OK','Cancel',False,False) vs.CreateLB(dialID,kLB001,60,20) vs.CreatePushButton(dialID,kPB_Expand,'Expand') vs.CreatePushButton(dialID,kPB_Collapse,'Collapse') vs.SetFirstLayoutItem(dialID,kLB001) vs.SetRightItem(dialID,kLB001,kPB_Expand,0,0) vs.SetBelowItem(dialID,kPB_Expand,kPB_Collapse,0,0) if vs.RunLayoutDialog(dialID,dialogHandler) == 1: pass rundialog() Cheers, Gelde-Aart 1 Quote Link to comment
twk Posted August 31, 2020 Author Share Posted August 31, 2020 (edited) Thank you very much @Gelde-Aart. As usual the Vectorworks Dev Wiki gives minimal assistance on usage. I got it to work without explicitly stating the LBControlType. I was missing the SetLBItemDisplayType call. Also my sequencing was a bit off. You need to call SetLBItemDisplayType before any other Enablings for the Listbrowser. Live and learn, live and learn.. edit Also you need to call "SetLBHierDispColumn" before "EnableLBHierDisplay" for some reason. 🤷♀️ Thanks again Edited August 31, 2020 by twk 2 Quote Link to comment
twk Posted August 31, 2020 Author Share Posted August 31, 2020 fixed/tweaked your code: (minor errors in GetLBEventInfo call) import vs kLB001 = 4 kPB_Expand = 5 kPB_Collapse = 6 import vs def dialogHandler(item, data): if item == 12255: nCol = vs.InsertLBColumn(dialID, kLB001, 0, 'Item', 150) bResult = vs.SetLBControlType(dialID, kLB001, 0, 1) bResult = vs.SetLBItemDisplayType(dialID, kLB001, 0, 3) # Some Lines to fill the listbrowser nItem = vs.InsertLBItem(dialID, kLB001, 0, '2D-Axis') nItem = vs.InsertLBItem(dialID, kLB001, 1, '2D-Cap') nItem = vs.InsertLBItem(dialID, kLB001, 2, '2D-Housing-Back') nItem = vs.InsertLBItem(dialID, kLB001, 3, '2D-Housing-Frame') nItem = vs.InsertLBItem(dialID, kLB001, 4, '2D-Housing-Glass') nItem = vs.InsertLBItem(dialID, kLB001, 5, '2D-Leaf-Back') nItem = vs.InsertLBItem(dialID, kLB001, 6, '2D-Leaf-Frame') nItem = vs.InsertLBItem(dialID, kLB001, 7, '2D-Leaf-Glass') nItem = vs.InsertLBItem(dialID, kLB001, 8, '3D-Axis') nItem = vs.InsertLBItem(dialID, kLB001, 9, '3D-Cap') nItem = vs.InsertLBItem(dialID, kLB001, 10, '3D-Housing-Frame') nItem = vs.InsertLBItem(dialID, kLB001, 11, '3D-Housing-Glass') nItem = vs.InsertLBItem(dialID, kLB001, 12, '3D-Leaf-Frame') nItem = vs.InsertLBItem(dialID, kLB001, 13, '3D-Leaf-Glass') vs.EnableLBSorting(dialID, kLB001, False) vs.SetLBHierDispColumn(dialID, kLB001, 0) vs.EnableLBHierDisplay(dialID, kLB001, True) global numLBItems # has to be a global, otherwise it won't work... numLBItems = vs.GetNumLBItems(dialID, kLB001) elif item == kLB001: LBrecursive = True bResult, LBeventType, LBrowIndex, LBcolumIndex = vs.GetLBEventInfo(dialID, kLB001) if vs.HierLBItemIsClosed(dialID, kLB001, LBrowIndex): numbRedisplItems = vs.HierLBItemOpened(dialID, kLB001, LBrowIndex, False) else: vs.HierLBItemClosed(dialID, kLB001, LBrowIndex, False) elif item == kPB_Expand: for i in range(numLBItems): if vs.HierLBItemIsClosed(dialID, kLB001, i): numbRedisplItems = vs.HierLBItemOpened(dialID, kLB001, i, True) elif item == kPB_Collapse: for i in range(numLBItems): if vs.HierLBItemIsClosed(dialID, kLB001, i) == False: vs.HierLBItemClosed(dialID, kLB001, i, True) def rundialog(): global dialID dialID = vs.CreateResizableLayout('Test Listbrowser', True, 'OK', 'Cancel', False, False) vs.CreateLB(dialID, kLB001, 60, 20) vs.CreatePushButton(dialID, kPB_Expand, 'Expand') vs.CreatePushButton(dialID, kPB_Collapse, 'Collapse') vs.SetFirstLayoutItem(dialID, kLB001) vs.SetRightItem(dialID, kLB001, kPB_Expand, 0, 0) vs.SetBelowItem(dialID, kPB_Expand, kPB_Collapse, 0, 0) if vs.RunLayoutDialog(dialID, dialogHandler) == 1: pass rundialog() Quote Link to comment
Gelde-Aart Posted August 31, 2020 Share Posted August 31, 2020 🙂 was a quick and dirty porting at my side... 1 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.