ibach Posted January 18, 2013 Posted January 18, 2013 (edited) How to write Lsp which would assign saved layer state to view ports in a drawing using some sort of filter. (lets say to all view ports in a layouts whose name begins with/contains a string of characters, or to all the view ports in particular layer...) Link to other thread: layer states save-update problem to which such lisp could be the problem override. Edited January 22, 2013 by ibach Quote
ibach Posted January 21, 2013 Author Posted January 21, 2013 (edited) As I cannot code in lisp I will try to draft the concept of the code, any help for each part of this lsp is welcome. I'll try to put it together... DOSLib (defun C:CHLSTATEB (/ LAYOUTS PATTERN LAYERLIST ALLVIEWPORTLIST LISTALLST LAYERSTORE) (setq LAYOUTS(mapcar 'strcase(cons "MODEL" (layoutlist)))) (if(and(setq PATTERN(strcase(getstring "Layoutname (with wildcards):"))) (/= PATTERN "") ) (progn ;;;Create LAYOUTS list using wildcards (setq LAYOUTS(vl-remove-if-not '(lambda(X)(wcmatch X PATTERN))LAYOUTS)) (princ (strcat "\n" (itoa(length LAYOUTS))" layouts found.")) (terpri) (princ LAYOUTS) (princ) (terpri) ;;;Create LAYERLIST list using onscreen list box (setq LAYERLIST (dos_layerlistbox "Select layers to use:" "(Off and frozen layers available)" 256) ;;enable multiple selection ) (terpri) (princ LAYERLIST) (princ) (terpri) ;;;Create ALLVIEWPORTLIST all viewports (setq ALLVIEWPORTLIST (vports)) (terpri) (princ ALLVIEWPORTLIST) (princ) ;;;Select Layerstate to restore (setq LISTALLST (layerstate-getnames includehidden includexref)) (terpri) (princ LISTALLST) (princ) (terpri) (setq LAYERSTORE (dos_listbox "Layerstates" "Select Layerstate to Restore" LISTALLST)) ) ) ) ;;;So, I made selection, now what? (foreach item (layoutlist) (if (wcmatch item LAYOUTS) (progn (setvar "CTAB" item) ;;;Do the layerstate_restore if viewports are on the selected layers ;;;using: layerstate-restore layerstatename viewport [restoreflags]) ;;;problem: viewport must not be nil to use flag 4 which is what i need here... ;;;is there a way to specify all or any? ) ) ) Edited January 23, 2013 by ibach Quote
ibach Posted January 23, 2013 Author Posted January 23, 2013 (edited) Or, have I made selection... No, I made user input, now I have to filter it out and do the actual layerstate-restore i need to use ssdel on ALLVIEWPORTLIST eliminating vievports not on selected layers and not on selected layouts and create VIEVPORTSTOCHANGE set Than do layerstaterestore on the new set. NOOOO! ALLVIEWPORTLIST is not good... i need ssget... (setq ALLVIEWPORTLIST (ssget "_X" (list '(0 . "VIEWPORT") (cons 410 (getvar 'ctab))))) .... Edited January 23, 2013 by ibach Quote
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.