Author Topic: newbie question: COND limits?  (Read 4668 times)

0 Members and 1 Guest are viewing this topic.

CHulse

  • Bull Frog
  • Posts: 454
Re: newbie question: COND limits?
« Reply #15 on: November 10, 2010, 05:30:46 PM »
FYI, assoc doesn't require a dotted pair, it just searched the first item in each list.

Also, assoc is case-sensitive, so be sure capitalize the search item in the defined list and (strcase (vla-get-TagString <att>)) before trying to search with assoc.

Would COND not require those steps?
both ways still have to compare with tagstring.
I meant the case sensative question - is cond NOT case sensative?

It took me a minute to get what you were doing, but that makes sense. Thanks
Cary Hulse
Sr. Urban Forester
Wetland Studies and Solutions

Civil 3D 2018

Lee Mac

  • Seagull
  • Posts: 12390
  • London, England
Re: newbie question: COND limits?
« Reply #16 on: November 10, 2010, 05:55:01 PM »
I meant the case sensative question - is cond NOT case sensative?

Try it:

Code: [Select]
(eq "ab" "AB")
Then you tell me  :wink:

ronjonp

  • Needs a day job
  • Posts: 7148
Re: newbie question: COND limits?
« Reply #17 on: November 10, 2010, 06:04:08 PM »
FYI, assoc doesn't require a dotted pair, it just searched the first item in each list.

Also, assoc is case-sensitive, so be sure capitalize the search item in the defined list and (strcase (vla-get-TagString <att>)) before trying to search with assoc.

I don't think you need the strcase on the vla-get-TagString. I thought the tagstring was always uppercase?

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

CHulse

  • Bull Frog
  • Posts: 454
Re: newbie question: COND limits?
« Reply #18 on: November 10, 2010, 06:09:14 PM »
I meant the case sensative question - is cond NOT case sensative?

Try it:

Code: [Select]
(eq "ab" "AB")
Then you tell me  :wink:

HaHa, point taken...
Cary Hulse
Sr. Urban Forester
Wetland Studies and Solutions

Civil 3D 2018

CHulse

  • Bull Frog
  • Posts: 454
Re: newbie question: COND limits?
« Reply #19 on: November 12, 2010, 04:49:41 PM »
Ok, I couldn't get the ASSOC concept to work for me and I'm not sure what I was doing wrong...

Code: [Select]
(setq atlist '((ID tnum)(BOTANICAL species)(COMMON common)(CULTIVAR cultivar)(DBH dbh)(CONDITION condition)(UNIQUEID unique)(STEMS stem)))

(foreach att (vlax-invoke obj 'GetAttributes)
         (if (setq attval (cdr (assoc (strcase(vla-get-TagString att)) atlist)))
             (vla-put-TextString att attval)))


Any idea what I did wrong here?
Thanks
Cary Hulse
Sr. Urban Forester
Wetland Studies and Solutions

Civil 3D 2018

Lee Mac

  • Seagull
  • Posts: 12390
  • London, England
Re: newbie question: COND limits?
« Reply #20 on: November 12, 2010, 04:58:04 PM »
Two problems:

1) The use of the apostrophe: see if you can work out why after reading this:

http://www.cadtutor.net/forum/showpost.php?p=258390&postcount=20


2) The use of 'cdr' without use a dotted pair, read the help docs on 'cdr' and see if you can work out a fix.

 :-)

CHulse

  • Bull Frog
  • Posts: 454
Re: newbie question: COND limits?
« Reply #21 on: November 12, 2010, 05:22:45 PM »
Ok, so I should have used CADR in this situation then correct?

As for the ' use, I took that from the help file example for ASSOC:

Code: [Select]
Examples

Command: (setq al '((name box) (width 3) (size 4.7263) (depth 5)))


I assumed you would need to identify the alist as a "list"...  is that non needed?
Cary Hulse
Sr. Urban Forester
Wetland Studies and Solutions

Civil 3D 2018

Lee Mac

  • Seagull
  • Posts: 12390
  • London, England
Re: newbie question: COND limits?
« Reply #22 on: November 12, 2010, 05:28:53 PM »
Ok, so I should have used CADR in this situation then correct?

Correct for the list structure in your code, else you could use a dotted list with cdr  :-)

As for the ' use, I took that from the help file example for ASSOC...

Did you read my link regarding the apostrophe? The problem is in what elements are evaluated  :-)

CHulse

  • Bull Frog
  • Posts: 454
Re: newbie question: COND limits?
« Reply #23 on: November 12, 2010, 05:51:14 PM »
I did, but I'm not sure I get it...
Since I have variables in my list, does the ' mean the variables are not evaluated? The example is only values, not vars...?
Cary Hulse
Sr. Urban Forester
Wetland Studies and Solutions

Civil 3D 2018

Lee Mac

  • Seagull
  • Posts: 12390
  • London, England
Re: newbie question: COND limits?
« Reply #24 on: November 12, 2010, 05:59:57 PM »
Since I have variables in my list, does the ' mean the variables are not evaluated?

Exactly  :-)

Also, spotted one more thing - tagstrings


CHulse

  • Bull Frog
  • Posts: 454
Re: newbie question: COND limits?
« Reply #25 on: November 12, 2010, 06:25:24 PM »
What about the tagstrings?
Cary Hulse
Sr. Urban Forester
Wetland Studies and Solutions

Civil 3D 2018

Lee Mac

  • Seagull
  • Posts: 12390
  • London, England
Re: newbie question: COND limits?
« Reply #26 on: November 12, 2010, 07:00:02 PM »
What about the tagstrings?

Well, in your current code they aren't strings - hence my hint  :lol:

CHulse

  • Bull Frog
  • Posts: 454
Re: newbie question: COND limits?
« Reply #27 on: November 12, 2010, 07:09:29 PM »
Ooohh - I assume you mean they need to be "quoted"??
Cary Hulse
Sr. Urban Forester
Wetland Studies and Solutions

Civil 3D 2018

CHulse

  • Bull Frog
  • Posts: 454
Re: newbie question: COND limits?
« Reply #28 on: November 12, 2010, 07:10:13 PM »
Thanks for your help (again :))
It's late, bear with me here...
Cary Hulse
Sr. Urban Forester
Wetland Studies and Solutions

Civil 3D 2018

Lee Mac

  • Seagull
  • Posts: 12390
  • London, England
Re: newbie question: COND limits?
« Reply #29 on: November 12, 2010, 07:19:03 PM »
Ooohh - I assume you mean they need to be "quoted"??

Yes, exactly  :-)

Thanks for your help (again :))
It's late, bear with me here...

You're welcome, and don't worry - I thought it'd be better to provide hints than to just give the complete code  :-)  But maybe some of my hints aren't too clear :-(