Visibility Parameter Current Value in a Dynamic Block

Visibility Parameter Current Value in a Dynamic Block

cfindlay5AYZC
Participant Participant
99 Views
5 Replies
Message 1 of 6

Visibility Parameter Current Value in a Dynamic Block

cfindlay5AYZC
Participant
Participant

I've seen a number of very complicated lisp routine for manipulating dynamic block parameters .... but i'm looking for something absolutely basic. Read the value of current visibility state.

 

It just needs to get the name of the visibility parameter and read the current value of any block i click on ... or do nothing. It doesn't seem like it should be dozens of lines of code by a programmer with a lee-mac sized brain ... It seems like it should be a few lines of code.

 

The routine don't need to cycle through every block in the drawing, don't check to see if the block is dynamic, don't check to see if it has visibility parameters,  don't change, link, or switch to other states, don't tell me any other settings or parameters, don't need to create any lists or sets for sorting or organizing or manipulating values. Because all that extra code is just going to overload my tiny mind.

 

Anybody have an ideas

 

Thanks 

 

Colin

0 Likes
100 Views
5 Replies
Replies (5)
Message 2 of 6

paullimapa
Mentor
Mentor

After selecting the Dynamic Block, any reason for not using Properties window under Custom section the Visibility states drop down list to select the value desired?

For example dynamic block "_AVSF-UTL PAGEFLAG" contains 2 Visibility States:

"FROM PAGE" and "TO PAGE" which can be selected from the Properties window:

paullimapa_0-1759382353464.png

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 3 of 6

Sea-Haven
Mentor
Mentor

Yes start with Lee-mac Dynamic block lisp. It has a visibility method. I have used it in 2 versions, return current visibility and the other return all the visibility states. The attached may help.

 

 

 

0 Likes
Message 4 of 6

ВeekeeCZ
Consultant
Consultant

(getpropertyvalue (car (entsel)) (strcat "AcDbDynBlockProperty" "Visibility"))

0 Likes
Message 5 of 6

komondormrex
Mentor
Mentor

1+

(defun c:get_value_dyn_property_by_name (/ dyn_property_name insert_object dyn_property_found)
  (setq dyn_property_name (strcase (getstring "\nEnter name of visibility property: "))
      insert_object (vlax-ename->vla-object (car (entsel (strcat "\nPick insert with visibility property \"" dyn_property_name "\": "))))
  )
  (if (vl-some '(lambda (dyn_property) (= dyn_property_name (strcase (vla-get-propertyname (setq dyn_property_found dyn_property)))))
          (vlax-invoke insert_object 'getdynamicblockproperties)
    )
    (vlax-get dyn_property_found 'value)
    (princ "No such property in this block reference")
  )
  (princ)
)
0 Likes
Message 6 of 6

Moshe-A
Mentor
Mentor

@cfindlay5AYZC  hi,

 

Here's (MA:get_curr_vstate) function that accept one argument, A Dynamic Block Reference Object and return the current value of visibility state or nil if no visibility (or any set current) exist.

i hope your 'tiny mind' can deal with (vl-some) & (lambda) 😀

 

The c:gcvs command bellow is just my way to test it. i'm very much likes how the Great mr Lee Mac codes. i also accustomed to check \ validate every thing i operate on.

 

enjoy

Moshe

 

; return current visibility state
(defun MA:get_curr_vstate (AcDbDynBlkRef)
 (vl-some
   (function
     (lambda (DynPropObj / val)
       (if (and
             (= (vlax-get DynPropObj 'UnitsType) 0)
             (member (setq val (vlax-get DynPropObj 'Value)) (vl-remove "Invalid Size" (vlax-get DynPropObj 'AllowedValues)))
           )
        val
       )
     ); lambda
   ); function
   (vlax-invoke AcDbDynBlkRef 'GetDynamicBlockProperties)
 ); vl-some 
); MA:get_curr_vstate


(defun c:gcvs (/ pick ename AcDbBlkRef)

 (if (and
       (setq pick (entsel))
       (setq ename (car pick))
       (setq AcDbBlkRef (vlax-ename->vla-object ename))
       (eq (vla-get-isDynamicBlock AcDbBlkRef) :vlax-true)
     )
  (progn
   (setq vstate (MA:get_curr_vstate AcDbBlkRef))
   (vlax-release-object AcDbBlkRef)

   (terpri)
   (princ vstate)
  ); progn
 ); if

 (princ)
); c:gcvs

 

 

 

0 Likes