; copyright (c) by: ; Stephan Bartl and this company: ; Georg Krämer GmbH & Co KG ; Neuhauserweg 14, 4061 Pasching ; You may run this code and use the functionality at your own risk. ; You may also use/incorporate the code itself (or parts thereof) in your own programming (at your own risk). ; If you choose to do so then please make sure that (if you copy) the copyright-information is copied as well. ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ~~~~~~~~~~ MAIN-FUNCTION: ~~~~~~~~~~ ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ (defun c:openDocsPalette () (vl-load-com) (dcl_Project_Import '("YWt6A2oIAAD0byrvBuLTKzMxLT9qQ7ssOD5PWuTOXW/d5WzeU4OmX2bdLj/zP+1YpDH06DwWP7y4" "23UjleGOfW3BHBwcIpewYZ5xTi8Kmbx7i6IXIfkJHeTmrrcFEbBDGZCiRZHApf+4IH3CaNnvPHip" "Lj1vlcIZTvNSdAKwHmsHEh77MmsLteNbybAHe73mXCnJZK/599UmncK4z7+HbIvg2PwbJKnWtWxp" "97oZeJlP9Uo55uRLFRWQJL1862sklChBtMfSGbp94+t/fiEE/r1fMFZh5z5qR/IdcjcQQbjTWC88" "Ynew3PaOR7cn7PRGCx+gzcpoRmzKG7f0XHUFHnOP5t7pYhwq6hZRJ0E38Mbj9zHPm5JEj+bZ07ZP" "MFg4FfK0dg9phLrXOqK1dT1Of2QlQTcLwB3UmG14QwsV58f83hlswZjgA6ahSTgRoN2lvUxPYWPI" "lXnjgH0ZmC5elp2hRqCcKXTBKIbbvImvrTAunEeHIXcBiNcfsEaRG0wYbV9RB7URhY4m4MugxwQQ" "3A16vAWiatFEVQfNK6175vikgdW8CQMGit6cx74Vp7jsyyGkyOKrHcuJPfs9f0GgjI3ISttS8fRX" "2zWtsqdRxLDwzvRT6MhH3IIJVYGxa4Eqnxl0QS/GrNAShbCzY/sppMtuhlPry9SGpXRRVIFxasDf" "jk9h8GG6xa0ZpgLlKbcrpvu1KjVpy+vrL6+SyKE4bZHHkpIJgS0bhd2Do0uP9iSBtePgm4GvJMQe" "Qq2AyIw5cEWWpPajAKCPzLbaYmBsYvnB05JWgjzLzyD7C6XUhPTNQbM9YpgryDlXAShNwlG/wg0P" "kjSihaSj8MrFORThDZaJkw0im8uejlMXPlmuma0x1sLctIEbm1HcjPTXi6ErfULbqCEMhtOaTZXO" "oxEwy53KnFFUQNecq3OGypyJS5qVU5shdm1Gjg==") ) (dcl_Form_Show openDocsPalette_OpenDocsPalette) (princ) ) ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ~~~~~~~~~~ SIDE-FUNCTIONS: ~~~~~~~~~~ ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ (defun openDocsPalette_ListBox_FindItemData (#control #intSearch / $index $intItemData) (setq $index 0) (setq $intItemData (dcl_ListBox_GetItemData #control $index)) (while (and (/= $intItemData #intSearch) (< $index (dcl_ListBox_GetCount #control))) (setq $index (1+ $index)) (setq $intItemData (dcl_ListBox_GetItemData #control $index)) ) (and (= $index (dcl_ListBox_GetCount #control)) (setq $index -1) ) $index ) (defun openDocsPalette_alistOfOpenDocs (/ $alistOfDocs $intAssocNr) (vl-load-com) (setq $intAssocNr 1) (vlax-for $vlaDoc (vla-get-documents (vlax-get-acad-object)) (setq $alistOfDocs (cons (list $intAssocNr $vlaDoc) $alistOfDocs)) (setq $intAssocNr (1+ $intAssocNr)) ) $alistOfDocs ) (defun openDocsPalette_refreshListBox (/ $lstrOpenDwgNames $i) (while (< 0 (dcl_ListBox_GetCount openDocsPalette_OpenDocsPalette_ListBox1)) (dcl_ListBox_DeleteItem openDocsPalette_OpenDocsPalette_ListBox1 0) ) (vl-bb-set '*openDocsPalette-alistOfOpenDocs* (openDocsPalette_alistOfOpenDocs)) (setq $lstrOpenDwgNames (mapcar '(lambda (x) (vla-get-Name (cadr x))) (vl-bb-ref '*openDocsPalette-alistOfOpenDocs*))) (dcl_ListBox_AddList openDocsPalette_OpenDocsPalette_ListBox1 (cons (strcat "COUNT OF OPEN DWGS --> " (itoa (length $lstrOpenDwgNames)) " <--") $lstrOpenDwgNames)) (setq $i 0) (while (< $i (length (vl-bb-ref '*openDocsPalette-alistOfOpenDocs*))) (dcl_ListBox_SetItemData openDocsPalette_OpenDocsPalette_ListBox1 (1+ $i) (car (nth $i (vl-bb-ref '*openDocsPalette-alistOfOpenDocs*)))) (setq $i (1+ $i)) ) (openDocsPalette_highlightCurrentDoc) ) (defun openDocsPalette_highlightCurrentDoc (/ $vlaActiveDoc $intSearch $intItemToSelect) (setq $vlaActiveDoc (vla-get-activedocument (vlax-get-acad-object))) (setq $intSearch (cdr (assoc $vlaActiveDoc (mapcar '(lambda (x) (cons (cadr x) (car x))) (vl-bb-ref '*openDocsPalette-alistOfOpenDocs*))))) (and (<= 0 (setq $intItemToSelect (openDocsPalette_ListBox_FindItemData openDocsPalette_OpenDocsPalette_ListBox1 $intSearch))) (/= $intItemToSelect (dcl_ListBox_GetCurSel openDocsPalette_OpenDocsPalette_ListBox1)) (dcl_ListBox_SetCurSel openDocsPalette_OpenDocsPalette_ListBox1 $intItemToSelect) ) ) (defun openDocsPalette_defineReactors (/) (foreach $vla_reactor (cdar (vlr-reactors :VLR-dwg-Reactor)) (and (= 'STR (type (vlr-data $vla_reactor))) (wcmatch (vlr-data $vla_reactor) "`*openDocsPalette-dwg-reactor`*,`*openDocsPalette-command-reactor`*") (vlr-remove $vla_reactor) ) ) ; make dwg-reactor: (setq *openDocsPalette-dwg-reactor* (VLR-dwg-Reactor "*openDocsPalette-dwg-reactor*" '((:vlr-beginClose . *openDocsPalette_OnBeginClose*) ) ) ) ; make command-reactor: (setq *openDocsPalette-command-reactor* (VLR-command-Reactor "*openDocsPalette-command-reactor*" '((:vlr-commandEnded . *openDocsPalette_OnCommandEnded*) ) ) ) ) ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ~~~~~~~~~~ CALLBACK-FUNCTIONS: ~~~~~~~~~~ ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ (defun *openDocsPalette_OnBeginClose* (#reactor_object #list / $vlaActiveDoc $intSearch $intItemToDelete) (cond (openDocsPalette_OpenDocsPalette_ListBox1 (setq $vlaActiveDoc (vla-get-activedocument (vlax-get-acad-object))) (setq $intSearch (cdr (assoc $vlaActiveDoc (mapcar '(lambda (x) (cons (cadr x) (car x))) (vl-bb-ref '*openDocsPalette-alistOfOpenDocs*))))) (and (<= 0 (setq $intItemToDelete (openDocsPalette_ListBox_FindItemData openDocsPalette_OpenDocsPalette_ListBox1 $intSearch))) (dcl_ListBox_DeleteItem openDocsPalette_OpenDocsPalette_ListBox1 $intItemToDelete) (dcl_ListBox_DeleteItem openDocsPalette_OpenDocsPalette_ListBox1 0) (dcl_ListBox_InsertString openDocsPalette_OpenDocsPalette_ListBox1 0 (strcat "COUNT OF OPEN DWGS --> " (itoa (dcl_ListBox_GetCount openDocsPalette_OpenDocsPalette_ListBox1)) " <--")) ) ) ) ) (defun *openDocsPalette_OnCommandEnded* (#reactor_object #list / $strCurSel) (cond ((and openDocsPalette_OpenDocsPalette_ListBox1 (wcmatch (car #list) "QSAVE,SAVE,SAVEAS")) (and (setq $strCurSel (dcl_ListBox_GetItemText openDocsPalette_OpenDocsPalette_ListBox1 (dcl_ListBox_GetCurSel openDocsPalette_OpenDocsPalette_ListBox1))) (/= $strCurSel (vla-get-Name (vla-get-activedocument (vlax-get-acad-object)))) (openDocsPalette_refreshListBox) ) ) ) ) (defun c:openDocsPalette_OpenDocsPalette_OnInitialize (/) (openDocsPalette_refreshListBox) (princ) ) (defun c:openDocsPalette_OpenDocsPalette_OnDocActivated (/) (openDocsPalette_highlightCurrentDoc) (princ) ) (defun c:openDocsPalette_OpenDocsPalette_ListBox1_OnSelChanged (#ItemIndexOrCount[asLong] #Value[asString] / $lstrDocNames $intDocToActivate $vlaDocToActivate) (cond ((< 0 #ItemIndexOrCount[asLong]) ; first item is the count of open drawings (and (setq $vlaDocToActivate (cadr (assoc (dcl_ListBox_GetItemData openDocsPalette_OpenDocsPalette_ListBox1 #ItemIndexOrCount[asLong]) (vl-bb-ref '*openDocsPalette-alistOfOpenDocs*)))) (vl-catch-all-apply 'vla-activate (list $vlaDocToActivate)) ) ) ) (princ) ) ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ~~~~~~~~~~ IMMEDIATE EVALUATION: ~~~~~~~~~~ ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; Ensure the appropriate OpenDCL ARX file is loaded: (vl-load-com) (command "OPENDCL") (openDocsPalette_defineReactors) ; If the ListBox already exists then refresh on load (which is when the dwg is opened because this lsp needs to be in the acaddoc.lsp): (cond (openDocsPalette_OpenDocsPalette_ListBox1 (openDocsPalette_refreshListBox) ) ) (princ "\n\"openDocsPalette.lsp\" loaded.\nStart with \"OpenDocsPalette\".") (princ)