Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Mentor
mid-awe
Posts: 1,232
Registered: ‎12-08-2004
Message 1 of 20 (695 Views)
Accepted Solution

Invisible Attribute Constant Dynamic Block Visibility State?

695 Views, 19 Replies
01-24-2013 07:07 AM

Hi all,

 

I have a dynamic block with several visibility states, and each visibility state has one invisible-constant attribute. I can't seem to wrap my head around dynamic blocks well enough to get the value from the active visibility state invisible constant attribute. I know how to get the visibility state like this:

(setq ss (ssget "_x" (list '(0 . "INSERT") '(2 . "`*U*,<DynBlockName>") (cons 410 (getvar 'ctab)))))

 but what next?

 

Thank you.


mid-awe wrote:

That does seem simple, but it could take several days to change all of the dynamic blocks to that format. To be honest I'm  strapped for time now and if it's possible to get the value of the invisible/contstant attribute for each Visibility state it would help out a lot. Also, I only need the value from the active visibility state. 

 

I will use this in conjunction with my block counting code so that as the blocks are counted the values of the visibility state along with the botanical names can be stored into the dictionary to build the legend.

 

I'm back at my desk this morning so I'm attaching the correct version of the block I attached earlier. (just in the case that it may help.)

 

Thank you again this is a big help. :smileyhappy:


This test code is for Palms_DYN block, we can easily modify this to work on you other dblocks

 

(Defun c:PalmVal (/ BlockColl _InviVal _DP count
ss i e blkn ivs
val data datalist CurrentVis&Vlaue
)
;;; pBe ;;;
(vl-load-com)
(setq BlockColl (Vla-get-blocks
(vla-get-ActiveDocument (vlax-get-acad-object))
)
)
(defun _InviVal (bl bn / val)
(vlax-for itm (vla-item bl bn)
(if (eq (vla-get-objectname itm) "AcDbAttributeDefinition")
(setq val (cons (vla-get-textstring itm) val))
)
)
(reverse val)
)
(defun _DP (en) (vlax-invoke en 'GetDynamicBlockProperties))
(defun count (lst / i cnt nlst)
(while (setq i (car lst))
(setq lst (cdr lst)
cnt (length lst)
)
(setq lst (vl-remove i lst)
nlst (cons (list i (1+ (- cnt (length lst)))) nlst)
)
)
nlst
)
(if (setq ss (ssget "_X"
(list '(0 . "INSERT")
'(2 . "`*U*,Palms_DYN")
(cons 410 (getvar 'ctab))
)
)
)
(progn (repeat (setq i (sslength ss))
(setq e (vlax-ename->vla-object (ssname ss (Setq i (1- i))))
blkn (vla-get-effectivename e)
)
(if (eq blkn "Palms_DYN")
(progn
(if (not (assoc blkn DataList))
(setq vis (vlax-get (car (_DP e)) 'AllowedValues)
val (_InviVal BlockColl blkn)
DataList (cons (list blkn
(mapcar '(lambda (x y)
(cons x y)
)
vis
val
)
)
DataList
)
)
)
(setq data (cons
(assoc (vlax-get (car (_DP e)) 'Value)
(cadr (assoc blkn DataList))
)
data
)
)
)
)
)
(foreach itm (count data)
(print itm)
)
)
)
(princ)
)

 

command: Palmval

 

(("Pindo" . "Butia capitata") 1)
(("Pygmy" . "Phoenix robelinii") 2)
(("Queen" . "Syagrus romanzoffiana") 2)
(("Mexican Fan" . "Washintonia robusta") 1)
(("Mediterranean Fan" . "Chamaerops humilis") 1)
(("Bismark" . "Bismarckia nobilis") 4)
(("Sabal" . "Sabal Palmetto") 1)
(("Windmill" . "trachycarpus fortunei") 2)
(("Date" . "Phoenix dactylifera") 1)

 

HTH

 

Mentor
mid-awe
Posts: 1,232
Registered: ‎12-08-2004
Message 2 of 20 (671 Views)

Re: Invisible Attribute Constant Dynamic Block Visibility State?

01-25-2013 06:55 AM in reply to: mid-awe

Seeing that there has been no suggestions I'm wondering if I'm going about this the wrong way. Is there a better way to get information about the drawing in the visibility state of the dynamic block?

 

I am inserting a dynamic block with several plants each in a seperate visibility state. I need the botanical name of the visible plant. I have placed that information in the invisible attribute but if there is a better way where I can get that information when I need it, then I am open to any suggestion.

 

Thank you.

*Expert Elite*
pbejse
Posts: 2,511
Registered: ‎11-24-2009
Message 3 of 20 (668 Views)

Re: Invisible Attribute Constant Dynamic Block Visibility State?

01-25-2013 07:00 AM in reply to: mid-awe

mid-awe wrote:

Seeing that there has been no suggestions I'm wondering if I'm going about this the wrong way. Is there a better way to get information about the drawing in the visibility state of the dynamic block?

 

I am inserting a dynamic block with several plants each in a seperate visibility state. I need the botanical name of the visible plant. I have placed that information in the invisible attribute but if there is a better way where I can get that information when I need it, then I am open to any suggestion.

 

Thank you.


Interesting , I'll have a look-see tomrrw mid-awe

 

Hang in there.

 

:smileyhappy:

Mentor
mid-awe
Posts: 1,232
Registered: ‎12-08-2004
Message 4 of 20 (655 Views)

Re: Invisible Attribute Constant Dynamic Block Visibility State?

01-25-2013 09:23 AM in reply to: pbejse

Thank you pbejse, I'm standing still. Completely stumped after I dxf dumped the dblock and found no clues, but alas, I haven't worked with dynamic blocks much in the past. I'm eager to hear what you find. Thank you again. :smileyhappy:

*Expert Elite*
pbejse
Posts: 2,511
Registered: ‎11-24-2009
Message 5 of 20 (642 Views)

Re: Invisible Attribute Constant Dynamic Block Visibility State?

01-25-2013 10:58 PM in reply to: mid-awe

mid-awe wrote:

Thank you pbejse, I'm standing still. Completely stumped after I dxf dumped the dblock and found no clues, but alas, I haven't worked with dynamic blocks much in the past. I'm eager to hear what you find. Thank you again. :smileyhappy:


mid-awe,

 

It can be done with invisible attributes. but i need a sample of your DB to write a custom made code to work on your blocks.

 

Or you can use dictionary , like the ones you had before.

 

Your choice

 

:smileyhappy:

 

Mentor
mid-awe
Posts: 1,232
Registered: ‎12-08-2004
Message 6 of 20 (629 Views)

Re: Invisible Attribute Constant Dynamic Block Visibility State?

01-27-2013 07:03 AM in reply to: pbejse

That sounds encouraging :smileyhappy:

I've attached a sample of my DB

 

Thank you very much.

*Expert Elite*
pbejse
Posts: 2,511
Registered: ‎11-24-2009
Message 7 of 20 (617 Views)

Re: Invisible Attribute Constant Dynamic Block Visibility State?

01-27-2013 08:07 PM in reply to: mid-awe

mid-awe wrote:

That sounds encouraging :smileyhappy:

I've attached a sample of my DB

 

Thank you very much.


That is not a Dynamic block, anyhoo, The thread title says Invisible Constant, hence the value is always the same for depending on the  Visibility state.

 

Block name FruitBasket

Visibilty state: Mango

Constant/Invisible Attribute value :Ripe

 

Visibilty state: Banana

Constant/Invisible Attribute value :Green

......

 

is that how you want it?

 

 

Mentor
mid-awe
Posts: 1,232
Registered: ‎12-08-2004
Message 8 of 20 (614 Views)

Re: Invisible Attribute Constant Dynamic Block Visibility State?

01-27-2013 08:20 PM in reply to: pbejse

pbejse wrote:

That is not a Dynamic block

 


Oh, I don't have a recent version of ACAD here on the weekends. I just sent a backup copy of the block I assumed it was correct. :smileyembarrassed:
Yeah, you seem to have the idea of what I going for.
*Expert Elite*
pbejse
Posts: 2,511
Registered: ‎11-24-2009
Message 9 of 20 (605 Views)

Re: Invisible Attribute Constant Dynamic Block Visibility State?

01-27-2013 09:42 PM in reply to: mid-awe

mid-awe wrote:

pbejse wrote:

That is not a Dynamic block

 


Oh, I don't have a recent version of ACAD here on the weekends. I just sent a backup copy of the block I assumed it was correct. :smileyembarrassed:
Yeah, you seem to have the idea of what I going for.

In that case you dont need to create an invisible/contstant attribute for every Visibility states, one is enough and it has all the data for every Visibiltiy name

 

Attribute string:

"(\"BANANA\" \"LONG\") (\"MANGO\" \"RIPE\") (\"EGG\" \"HARD BOILED\")"

 

(setq data
(read (strcat "(" (vla-get-textstring (extracted attribute) ")"))
)

 

Now depending on the visibility name: 

ex. current block visibility : MANGO

 

(assoc "MANGO" data)

("MANGO" "RIPE");<-- RIPE being the data 

 

simple eh?

 

HTH

 

Mentor
mid-awe
Posts: 1,232
Registered: ‎12-08-2004
Message 10 of 20 (590 Views)

Re: Invisible Attribute Constant Dynamic Block Visibility State?

01-28-2013 06:52 AM in reply to: pbejse

That does seem simple, but it could take several days to change all of the dynamic blocks to that format. To be honest I'm  strapped for time now and if it's possible to get the value of the invisible/contstant attribute for each Visibility state it would help out a lot. Also, I only need the value from the active visibility state. 

 

I will use this in conjunction with my block counting code so that as the blocks are counted the values of the visibility state along with the botanical names can be stored into the dictionary to build the legend.

 

I'm back at my desk this morning so I'm attaching the correct version of the block I attached earlier. (just in the case that it may help.)

 

Thank you again this is a big help. :smileyhappy:

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.