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

Thread: Test for Existing Vis State

  1. #1
    Design Visualization Moderator stusic's Avatar
    Join Date
    2004-10
    Location
    Denver, Colorado
    Posts
    1,515
    Login to Give a bone
    0

    Default Test for Existing Vis State

    Can someone help me create a test to see if a vis state exists in a particular block? I'm not even sure where to begin on this one. I think I get how to do it, but I'm not sure how to put it together. I know I'll need to use the getdynamicblockproperties function, get the visibility property ("Visibility1"), get a list of allowedvalues, then match my variable against this list, returning true/false. Most of the examples I've seen use variants, which I'm not familiar with, and are put together in such a way I don't get. sadpandaface

  2. #2
    Design Visualization Moderator stusic's Avatar
    Join Date
    2004-10
    Location
    Denver, Colorado
    Posts
    1,515
    Login to Give a bone
    0

    Default Re: Test for Existing Vis State

    I think I found what I needed from (where else) Lee Mac's subroutines. Just got to form it into a test.

  3. #3
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Test for Existing Vis State

    You'll need to test if the desired Visibility State is contained within the DynamicBlockReferenceProperty Object's AllowedValues.

    Cheers
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  4. #4
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu HI
    Posts
    1,109
    Login to Give a bone
    0

    Default Re: Test for Existing Vis State

    My First Thought is to get the allowed values of all dynamic properties on a block

    Syntax

    Code:
    (DynamicPropertyAllowedValues (car (entsel "\nSelect Block: ")) "*")
    Code:
    (defun DynamicPropertyAllowedValues (objBlock strWCName / lstAllowedValues lstReturn strProperty strWCName)
     (if (= (type objBlock) 'ENAME)
      (setq objBlock (vlax-ename->vla-object objBlock))
     )
     (foreach objProperty (vlax-invoke objBlock "getdynamicblockproperties")
      (if (wcmatch (setq strProperty (vla-get-propertyname objProperty)) strWCName)
       (if (setq lstAllowedValues (vlax-get objProperty "AllowedValues"))
        (setq lstReturn (cons (cons strProperty lstAllowedValues) lstReturn))
       )
      )
     )
     lstReturn
    )
    AutomateCAD

  5. #5
    Design Visualization Moderator stusic's Avatar
    Join Date
    2004-10
    Location
    Denver, Colorado
    Posts
    1,515
    Login to Give a bone
    0

    Default Re: Test for Existing Vis State

    Naturally, Your code is much more robust than mine. With error-trapping and such. I don't error trap because I'm the kind of guy that lives life on the edge. And I never really got around to figuring out how...

    I found Lee's sub and didn't want to reinvent the wheel (not really, I just couldn't quite figure out what was going on), so I used it and came up with this:

    Code:
    ;; "mod" is the visibility state I want, "osdynprop" is a list of vis states Lee's subroutine returns
    
    (and	(setq osdynprop (LM:getdynpropallowedvalues tmp "Visibility1"))
    	(/= (member mod osdynprop) nil))
    This will only work for a minute though. I'll need to do this again, but use a wcmatch against the list...

  6. #6
    Design Visualization Moderator stusic's Avatar
    Join Date
    2004-10
    Location
    Denver, Colorado
    Posts
    1,515
    Login to Give a bone
    0

    Default Re: Test for Existing Vis State

    Quote Originally Posted by peter View Post

    Code:
    ...
      (if (wcmatch (setq strProperty (vla-get-propertyname objProperty)) strWCName)
    ...
    I see you happen to use the wcmatch...

  7. #7
    Active Member
    Join Date
    2013-07
    Posts
    66
    Login to Give a bone
    0

    Default Re: Test for Existing Vis State

    Code:
    (member mod (car osdynprop))
    Try that already?

  8. #8
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu HI
    Posts
    1,109
    Login to Give a bone
    0

    Default Re: Test for Existing Vis State

    Although I learn from others code, I always prefer to write it from scratch.

    The function returns a list of sublists that match the two fields and can handle reals and integer allowed values too.


    Code:
    (dynamicpropertyisallowed objBlock "Vis*" "MyAllowedValue*")
    Code:
    (defun DynamicPropertyIsAllowed (objBlock strWCPropertyName WCAllowedValue / 
                                     blnReturn lstSublist strProperty objProperty lstReturn)
     (foreach objProperty (vlax-invoke objBlock "getdynamicblockproperties")
      (if (wcmatch (strcase (setq strProperty (vla-get-propertyname objProperty))) (strcase strWCPropertyName))
       (if (setq lstAllowedValues (vlax-get objProperty "AllowedValues"))
        (progn
         (setq lstSublist nil)
         (foreach AllowedValue lstAllowedValues
          (if (or (and (= (type AllowedValue) 'REAL)
                       (equal AllowedValue WCAllowedValue 0.0001)
                  )
                  (and (= (type AllowedValue) 'INT)
                       (= AllowedValue WCAllowedValue)     
                  )
                  (and (= (type AllowedValue) 'STR)
                       (wcmatch (strcase AllowedValue) (strcase WCAllowedValue))
                  ) 
              )
           (setq lstSublist (cons AllowedValue lstSublist))
          )
         )
         (if lstSublist
          (setq lstReturn (cons (cons strProperty (reverse lstSublist)) lstReturn))
         )     
        )
       )
      )
     )
     lstReturn
    )
    AutomateCAD

  9. #9
    Design Visualization Moderator stusic's Avatar
    Join Date
    2004-10
    Location
    Denver, Colorado
    Posts
    1,515
    Login to Give a bone
    0

    Default Re: Test for Existing Vis State

    Mad skillz. I'm getting to the point where I can look at some code and figure out what's going on, but how you create it is still beyond me.

  10. #10
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Test for Existing Vis State

    Quote Originally Posted by stusic View Post
    ... how you create it is still beyond me.
    '[Developer's] Guide to the Universe' essentials....

    A good vocabulary of keywords/functions ("Babel Fish"), knowing where to look when you cannot possibly remember it all ("Apropos," etc.), make sure you've fueled up your Improbability Drive (aka paid your internet invoice, so you can jump on Al Gore's Interwebs), and always, I mean always bring your towel (to wipe away your tears when you have to resort to using the online help)!

    ... Don't Panic.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 0
    Last Post: 2012-02-24, 05:48 PM
  2. Visibility State reporting in existing Block List routine
    By newfoundfreedom in forum AutoLISP
    Replies: 6
    Last Post: 2008-04-17, 02:34 PM
  3. Replies: 3
    Last Post: 2006-11-14, 07:38 PM
  4. Replies: 8
    Last Post: 2006-10-11, 07:36 PM
  5. Architectural - Dynamic Table & Chairs (Vis State Test Block)
    By Rico in forum Dynamic Blocks - Sharing
    Replies: 6
    Last Post: 2006-03-17, 02:40 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
  •