Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: LISP to Change Visibility Parameter

  1. #1
    Member
    Join Date
    2008-11
    Posts
    16
    Login to Give a bone
    0

    Default LISP to Change Visibility Parameter

    I have 4 Blocks with 20-50 instances of each block in a drawing. All 6 have a dual state visibility setting A) Design Layout B) Technical Layout. I would like for a LISP to globally change the visibility state of all these blocks. It takes me forever to manually change all these blocks back and forth, I've also tried to place both types on different layer and just toggle the layers but it's twice the work.

    I'm LISP dumb, so any help would be greatly appreciated.

    Blocks Names are:

    BOXTAG - CEILING
    BOXTAG - FLOOR
    BOXTAG - WALL
    BOXTAG - WIRELESS

    Visibility States are:

    Design
    Technical

  2. #2
    I could stop if I wanted to msretenovic's Avatar
    Join Date
    2002-02
    Location
    Galloway, Oh
    Posts
    305
    Login to Give a bone
    0

    Smile Re: LISP to Change Visibility Parameter

    Quote Originally Posted by kwest View Post
    I have 4 Blocks with 20-50 instances of each block in a drawing. All 6 have a dual state visibility setting A) Design Layout B) Technical Layout. I would like for a LISP to globally change the visibility state of all these blocks. It takes me forever to manually change all these blocks back and forth, I've also tried to place both types on different layer and just toggle the layers but it's twice the work.

    I'm LISP dumb, so any help would be greatly appreciated.

    Blocks Names are:

    BOXTAG - CEILING
    BOXTAG - FLOOR
    BOXTAG - WALL
    BOXTAG - WIRELESS

    Visibility States are:

    Design
    Technical
    Here is something to try out. Please note this has not been fully tested and contains no error checking. If you have questions, please ask. I have placed comments, you can see them in red.
    Code:
    (defun c:MKSx-ToggleDesTech
      (
       /
       dyn
       idx
       lstBNames
       lstDyns
       ss
      )
      ;;get a selection set of all blocks in drawing
      ;;we need to filter for effective name of blocks after the selection is made
      (setq ss        (ssget "X" (list (cons 0 "INSERT")))
            ;;this is a list of all the block names to filter for
            lstBNames (list "BOXTAG - CEILING"
                            "BOXTAG - FLOOR"
                            "BOXTAG - WALL"
                            "BOXTAG - WIRELESS"
                      )
            idx       0
      )
      ;;if a selection set has been made, process it
      (if ss
        (progn
          (while (< idx (sslength ss))
            ;;convert each entity to an object (in turn)
            (setq obj (vlax-EName->vla-Object (ssname ss idx))
                  idx (1+ idx)
            )
            ;;if the effective name of the block is in the list above...
            (if (member (vla-Get-EffectiveName obj) lstBNames)
              ;;...process it for it dynamic properties
              (progn
                ;;get all the block dynamic properties
                (setq lstDyns (vlax-SafeArray->list (variant-Value (vla-GetDynamicBlockProperties obj))))
                ;;cycle through each property
                (foreach dyn lstDyns
                  ;;look for the visibility state
                  ;;NOTE: THIS IS IMPORTANT, the visibility state is the NAME of the visibility parameter
                  ;;it may need to be changed to match what the blocks use
                  (if (= "Visibility1" (vla-Get-PropertyName dyn))
                    ;;if the block has the Design visibility set...
                    (if (= "Design" (variant-Value (vlax-Get-Property dyn 'Value)))
                      ;;...set the Technical visibility
                      (vlax-Put-Property dyn 'Value "Technical")
                      ;;...otherwise, set the Design visibility
                      (vlax-Put-Property dyn 'Value "Design")
                    );;end if
                  );;end if
                );;foreach
              );;progn
            );;end if
          );;while
        );;progn
      );;end if
      (princ)
    )
    I have also highlighted in orange the name of the visibility state. I have placed the default name (Visibility1) in the code. However, if you have given it a different name, then you will need to modify the name in the code.

    HTH,

  3. #3
    Member
    Join Date
    2008-11
    Posts
    16
    Login to Give a bone
    0

    Default Re: LISP to Change Visibility Parameter

    Thank you very much for the code, and even more for commenting it. I will try it in the morning.

  4. #4
    The Silent Type RobertB's Avatar
    Join Date
    2000-01
    Location
    Seattle WA USA
    Posts
    5,859
    Login to Give a bone
    0

    Default Re: LISP to Change Visibility Parameter

    Sorry to take this off track, but...

    This seems to me to be the wrong "solution" to the real issue. Why is there even a need for toggling visiblilty states on each block reference to make it into a technical layout?

    It seems to me that layers should be used to control the visibility. One set of layers for the design layout and another set of layers for the technical layout. Then you only need visibility states on the blocks for the "important" stuff.

    You could switch between the "layouts" just by toggling layers without the QC overhead of making sure each block reference is correctly toggled.
    R. Robert Bell
    Design Technology Manager
    Stantec
    Opinions expressed are mine alone and do not reflect the views of Stantec.

  5. #5
    I could stop if I wanted to msretenovic's Avatar
    Join Date
    2002-02
    Location
    Galloway, Oh
    Posts
    305
    Login to Give a bone
    0

    Default Re: LISP to Change Visibility Parameter

    Quote Originally Posted by RobertB View Post
    Sorry to take this off track, but...

    This seems to me to be the wrong "solution" to the real issue. Why is there even a need for toggling visiblilty states on each block reference to make it into a technical layout?

    It seems to me that layers should be used to control the visibility. One set of layers for the design layout and another set of layers for the technical layout. Then you only need visibility states on the blocks for the "important" stuff.

    You could switch between the "layouts" just by toggling layers without the QC overhead of making sure each block reference is correctly toggled.
    After reading Robert's comments, I think he may be right. In thinking about it, this is actually how I have had many blocks set up. They would have a simpler view in a design, but more detailed when needed. This was controlled via layers.

    Now, if I can only get out of this tree out of my way so I can see the forest

  6. #6
    AUGI Addict
    Join Date
    2008-02
    Posts
    1,141
    Login to Give a bone
    0

    Default Re: LISP to Change Visibility Parameter

    I was just looking at it as a way to quickly choose a different Visibility state for a Dynamic block and set new state for all or selection of. That doesn't have anything to do with layers.

  7. #7
    I could stop if I wanted to msretenovic's Avatar
    Join Date
    2002-02
    Location
    Galloway, Oh
    Posts
    305
    Login to Give a bone
    0

    Wink Re: LISP to Change Visibility Parameter

    Quote Originally Posted by alanjt View Post
    I was just looking at it as a way to quickly choose a different Visibility state for a Dynamic block and set new state for all or selection of. That doesn't have anything to do with layers.
    I think you are correct, but Robert was talking about the OP's specific problem and the best way to solve it.

  8. #8
    AUGI Addict
    Join Date
    2008-02
    Posts
    1,141
    Login to Give a bone
    0

    Default Re: LISP to Change Visibility Parameter

    Quote Originally Posted by msretenovic View Post
    I think you are correct, but Robert was talking about the OP's specific problem and the best way to solve it.
    Good point. Nevermind me.

  9. #9
    Member
    Join Date
    2008-11
    Posts
    16
    Login to Give a bone
    0

    Default Re: LISP to Change Visibility Parameter

    I am using layers right now, I was hoping the dynamic block would be a bit simpler then layers in the long term. The problem I'm having is that when changes happen I have to update both layers. Normally not always a big deal but on the latest project I have over 600 blocks, and I got an update where 3/4 of them have to move. I was hoping this dynamic block idea would save hours of my life.

    Thanks to all that helped.

  10. #10
    Member
    Join Date
    2008-11
    Posts
    16
    Login to Give a bone
    0

    Default Re: LISP to Change Visibility Parameter

    Quote Originally Posted by RobertB View Post
    Sorry to take this off track, but...

    This seems to me to be the wrong "solution" to the real issue. Why is there even a need for toggling visiblilty states on each block reference to make it into a technical layout?

    It seems to me that layers should be used to control the visibility. One set of layers for the design layout and another set of layers for the technical layout. Then you only need visibility states on the blocks for the "important" stuff.

    You could switch between the "layouts" just by toggling layers without the QC overhead of making sure each block reference is correctly toggled.
    Thank you Robert,
    Your idea works perfectly, I can't believe that I forgot about using pre-defined layer do to this. I feel like such a fool.

    Thanks again for all of those you that helped out.

Page 1 of 2 12 LastLast

Similar Threads

  1. Add a new visibility parameter
    By Mac Demer in forum Dynamic Blocks - Technical
    Replies: 11
    Last Post: 2016-09-13, 12:48 AM
  2. Replies: 8
    Last Post: 2013-09-26, 07:37 PM
  3. Yes/No Visibility Parameter with Secondary Parameter Help
    By bpayne in forum Revit Architecture - General
    Replies: 3
    Last Post: 2011-06-15, 05:52 PM
  4. Change dynamic block visibility with command line or lisp
    By gjp in forum Dynamic Blocks - Technical
    Replies: 2
    Last Post: 2009-06-11, 07:23 PM
  5. Change Project Parameter to Shared Parameter?
    By kgodfrey in forum Revit Structure - General
    Replies: 0
    Last Post: 2008-11-12, 04:43 PM

Posting Permissions

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