+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Senior Member
    Using
    AutoCAD 2010
    Join Date
    Dec 2010
    Location
    Brussels
    Posts
    112

    Default generate visibility states

    Registered forum members do not see this ad.

    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)

  2. #2
    Senior Member
    Computer Details
    Stefan BMR's Computer Details
    Operating System:
    Win10
    Discipline
    Structural
    Using
    AutoCAD 2019
    Join Date
    Sep 2011
    Location
    Baia Mare, Romania
    Posts
    393

    Default

    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.
    Code:
    ;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.

  3. #3
    Senior Member
    Using
    AutoCAD 2010
    Join Date
    Dec 2010
    Location
    Brussels
    Posts
    112

    Default

    Registered forum members do not see this ad.

    Thanks. Looks exactly like what I need.

Similar Threads

  1. Using visibility states
    By Jman in forum Blocks, Images, Models & Materials
    Replies: 0
    Last Post: 17th Nov 2017, 06:57 pm
  2. Visibility and flip states
    By sammyteacake in forum AutoCAD Beginners' Area
    Replies: 5
    Last Post: 28th Mar 2012, 04:22 pm
  3. Visibility States
    By eyde in forum AutoCAD Drawing Management & Output
    Replies: 0
    Last Post: 7th Nov 2011, 10:08 pm
  4. visibility states
    By mnewton in forum AutoCAD Drawing Management & Output
    Replies: 3
    Last Post: 11th May 2011, 06:59 pm
  5. Visibility States
    By chelsea1307 in forum AutoCAD Drawing Management & Output
    Replies: 1
    Last Post: 2nd Jun 2010, 09:52 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts