Jump to content

Apply Layer State Overrides to all view ports in layouts whose name starts with K


Recommended Posts

Posted (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 by ibach
Posted (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 by ibach
Posted (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.:unsure:

 

NOOOO! ALLVIEWPORTLIST is not good... i need ssget...

(setq ALLVIEWPORTLIST (ssget "_X" (list '(0 . "VIEWPORT") (cons 410 (getvar 'ctab)))))

....

Edited by ibach

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...