Emmanuel Delay Posted August 10, 2018 Share Posted August 10, 2018 Is there a way for LISP to generate visibility states? If yes... then maybe import the block definition, from dwg file (1 file = 1 block) I'm combining lots of blocks into fewer blocks, by category. (Google completely ignores the "generate" or "create" search term. I find lots of "set dynamic state" links) Quote Link to comment Share on other sites More sharing options...
Stefan BMR Posted August 10, 2018 Share Posted August 10, 2018 Not sure exactly how it is supposed to work, or what objects do you want to add to a specific visibility, so try this one, as an example. First, insert some static blocks into your drawing. Then run the lisp and select the blocks. The lisp will create a new block with Vis States, each one representing one of the selected blocks. Here it is, quick and dirty. ;Create Dynamic Block w/ visibility ;Stefan M. 10.08.2018 (defun c:test ( / msg ss nb i bn lst) (if (and (setq ss (ssget '((0 . "INSERT")))) (setq nb (getstring "\nSpecify new block name: ")) (setq msg "\nInvalid name") (snvalid nb) (setq msg "\nBlock already defined") (not (tblsearch "block" nb)) ) (progn (repeat (setq i (sslength ss)) (setq bn (cdr (assoc 2 (entget (ssname ss (setq i (1- i))))))) (if (not (member bn lst)) (setq lst (cons bn lst)) ) ) (command "_bedit" nb) (command "_bparameter" "_visibility" '(0.0 -10 0.0) "1") (foreach x lst (command "_bvstate" "_new" x "_hide") (entmakex (list '(0 . "INSERT") (cons 2 x) '(10 0.0 0.0 0.0))) ) (command "_bvstate" "_set" (car lst)) (command "_bvstate" "_delete" "VisibilityState0") (command "_bsave") (command "_bclose") (command "_insert" nb "_s" 1.0 "_r" 0.0) (while (> (getvar 'cmdactive) 0) (command pause) ) ) (if msg (alert msg)) ) (princ) ) PS. The lisp is working on my computer. However, it might need some checking routines. For example, I can imagine, if you use a non-english autocad, the default name of the first visibility state might not be "VisibilityState0", so my lisp could fail trying to delete it. Quote Link to comment Share on other sites More sharing options...
Emmanuel Delay Posted August 10, 2018 Author Share Posted August 10, 2018 Thanks. Looks exactly like what I need. Quote Link to comment Share on other sites More sharing options...
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.