Simple IF/THEN Statement

Simple IF/THEN Statement

Anonymous
Not applicable
6,009 Views
14 Replies
Message 1 of 15

Simple IF/THEN Statement

Anonymous
Not applicable

I'm trying to match a field value with a specific wire size from the NEC. Here's what I'm trying to do.

 

IF (Breaker Size Field) = 10, THEN (10)

IF (Breaker Size Field) = 15, THEN (10)

IF (Breaker Size Field) = 20, THEN (10)

IF (Breaker Size Field) = 25, THEN (10)

IF (Breaker Size Field) = 30, THEN (10)

IF (Breaker Size Field) = 35, THEN (8)

IF (Breaker Size Field) = 40, THEN (8)

IF (Breaker Size Field) = 45, THEN (8)

IF (Breaker Size Field) = 50, THEN (8)

IF (Breaker Size Field) = 60, THEN (6)

 

I'll keep it going, but I think you get the point.

0 Likes
Accepted solutions (1)
6,010 Views
14 Replies
Replies (14)
Message 2 of 15

dmfrazier
Advisor
Advisor

I don't think it's possible to enter such a "free-form" formula.

A "Formula" in a Field must refer to values in a table.

I think there is only support for the types of functions that appear on the buttons: Average, Count, Sum, and Cell.  (If there is anything else, I have not found any information about it.)

However, you might be able to perform some of your "if/then" stuff in a cell (or cells) of a table, then display it somewhere else using the Field.

If you know Excel well enough to create it there, you can then copy/paste from Excel into AutoCAD (as a table).

 

How is the "breaker size" established?

0 Likes
Message 3 of 15

cadffm
Consultant
Consultant
To what source is your existing field "Breaker Size Field" linked?

The IF function in formular fields are unknown for me in plain AdeskProducts,
but if we know what the source is and perhaps where you need the Result of your formular field,
we find another solution. (Dynamic Block parameter or DIESEL field when the source information ca get by Dieselfunction getvar.
(Because in Diesel fields its not possible to nest other fields)

Attach a simple sample file

Sebastian

0 Likes
Message 4 of 15

Anonymous
Not applicable

Our CAD Designers aren't electricians or engineers, but are obviously capable of doing some basic math. So we have them figure out the breaker size by hand so that they have that context when it comes to interconnecting their PV system. When it comes to wire sizes, we base those on that breaker size. The breaker sizes go from 10-50 in intervals of 5, then intervals of 10 to 100 etc. If they determine the value of the breaker size, I was hoping I could take that field entry & apply it to an IF/THEN equation. Breaker sizes 10, 15, 20, 25, 30 are #10AWG wire (value only needs to be 10, i can manually have the insulation placed in my template np). 

 

Does my question make sense? From my research, it sounds impossible. If it's not possible, it's no big deal. We KIND of have it working with an excel file now, but I hate the slower speeds of the software collaboration.

0 Likes
Message 5 of 15

dmfrazier
Advisor
Advisor

"If they determine the value of the breaker size, I was hoping I could take that field entry & apply it to an IF/THEN equation. Breaker sizes 10, 15, 20, 25, 30 are #10AWG wire (value only needs to be 10, i can manually have the insulation placed in my template np)."

 

It's still not clear to me what you actually want to produce in an AutoCAD drawing.

 

Will this information exist as a block of mtext, a table, or will there be a block or symbol of some sort that will display the wire size?   

0 Likes
Message 6 of 15

Anonymous
Not applicable

The solution I have found for my purposes is to create a dynamic block with a table listing the wire sizes.

The block itself is a drop-down of visibility states that you choose your breaker size from, then the Feeder Schedule table includes wire size fields that update when the visibility is changed.

Extra tip: type "RE" and press enter to update all fields.

Hopefully this helps!

0 Likes
Message 7 of 15

Sea-Haven
Mentor
Mentor

Your if's or cond can use a "AND" to imply a range of values. Makes much shorter.

 

(= (and (>= x 10)(<= x 50))(do something))

0 Likes
Message 8 of 15

john.uhden
Mentor
Mentor

The others have given sound advice, but I am looking at this a little differently... using a list:

(setq Sizes '((10 10)(15 10)(20 10)(25 10)(30 10)(35 8)(40 8)(45 8)(50 8)(60 6))) ;; etc.
;;I know nothing about electricity, so I probably have this backwards,
;;but if the first value is the breaker, and the second value is the wire, then
(setq wire (cadr (assoc breaker sizes)))
;;If I am backwards, then
(setq breaker (cadr (assoc wire sizes)))
;;The list of sizes can be as long as you want, and if contained in your code, it needs to be created only once.

John F. Uhden

Message 9 of 15

hak_vz
Advisor
Advisor
Accepted solution

@john.uhdenI wanted to post my solution to this subject, but it is actually what you proposed. It's all about what LISP acronym  stands for - list processing i.e associative list.

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 10 of 15

Kent1Cooper
Consultant
Consultant

In AutoLisp terms, (cond) is probably a cleaner way to go.  It doesn't require setting an appropriate value for each possible breaker size [as with the list-of-pairs suggestion], but can work with the ranges of sizes:

(setq WireSize

  (cond

    ((<= BreakerSize 30) 10);; i.e. anything up to 30 gets 10

    ((<= BreakerSize 50) 8);; if greater than 30, anything up to 50 gets 8

    (6);; [none-of-the-above] if greater than 50, gets 6

  ); cond

); setq

 

That's just within the sizes in your sample list, but the concept can be extended to however many ranges of breaker sizes associated with however many wire sizes you need.

Kent Cooper, AIA
0 Likes
Message 11 of 15

john.uhden
Mentor
Mentor

@hak_vz 

Exactly.

My apologies, but I guess I'm proud to have beaten you to the punch.

I hope to see you get a raise soon.

John F. Uhden

0 Likes
Message 12 of 15

john.uhden
Mentor
Mentor

Of course, that could be written

(<= 10 x 50)

Yeah, I know.  I'm just being a wise @$$.

John F. Uhden

0 Likes
Message 13 of 15

hak_vz
Advisor
Advisor

@john.uhdenThank you. I'll be back on my feet soon.

Somehow my post was selected as a solution what it is not.

 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 14 of 15

john.uhden
Mentor
Mentor

@hak_vz 

You deserve the credit because of your explanation.

@Kent1Cooper 's response was equally as good.

John F. Uhden

0 Likes
Message 15 of 15

hak_vz
Advisor
Advisor

Yes @Kent1Cooper  also gave good example.

 

I have lately started to use associative lists. In javascript and similar object oriented languages we have objects. In List this are associative lists.

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes