TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: whdjr on October 03, 2005, 01:04:11 PM

Title: vla-item with attributes
Post by: whdjr on October 03, 2005, 01:04:11 PM
I have a list of AttributeReferences (call it ListA) and reference AttributeReference (call it RefAtt).

How would I use 'vla-item' to return the AttributeReference from ListA that matched the same 'tagstring' with the RefAtt?

Or is there another function I should be using?
Title: Re: vla-item with attributes
Post by: MP on October 03, 2005, 01:15:33 PM
vla-item is used on collections, not lists.

IF, and that's a big IF, ListA is a true list of AttributeReference objects and RefAtt is an AttributeReference object then perhaps this ...

Code: [Select]
(setq result
    (
        (lambda ( / tagstring )
            (setq tagstring
                (strcase
                    (vla-get-tagstring
                        RefAtt
                    )
                )
            )
            (vl-remove-if-not
               '(lambda (attributeReference)
                    (eq tagstring
                        (strcase
                            (vla-get-tagstring
                                attributeReference
                            )
                        )
                    )
                )
                ListA
            )
        )
    )
)

Coded blind, so may need massaging.
Title: Re: vla-item with attributes
Post by: whdjr on October 03, 2005, 01:49:10 PM
Thanks MP,

I knew I could do it with vl-remove-if-not but thought I could do it better with vla-item.  I'll try to implement your code and see what I get.

Thanks, :-)
Title: Re: vla-item with attributes
Post by: CAB on October 04, 2005, 07:52:32 AM
You may find some useful code in this routine.
http://www.theswamp.org/forum/index.php?topic=6741.msg83413#msg83413