×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Reusing conditional statements?

Reusing conditional statements?

Reusing conditional statements?

(OP)
This is structural in nature but could apply to any subject:

I have set up a set of if statements that will output a rebar diameter based on rebar size. That's no problem.

bar_diameter := |0.375 in if bar_size = 3
                |0.500 in if bar_size = 4
   (etc.)

However, I have several different bar sizes within a structure. I am trying to define different diameters depending on the location (i.e. bar_diameter_compression, bar_diameter_tension) without having to redefine my conditional statement above to suit each location (i.e. bar_size_compression, bar_size_tension) since a bar size has a specific diameter regardless of location.

Any way of using this one definition above to suit every location and keep it local to whichever bar I am working with? Is there a better way of defining this (something like a case statement)? Sorry about being so wordy.

RE: Reusing conditional statements?


I wish you'd been more prolix! As I understand it you want to define the conditional statement once, and then have local values for the returned diameter.

I am not conversant with the structure shown, but why not set up a matrix of bar diameters, with say the rows being the size and the columns being the flag that defines the local condition (say column 0 for tension, 1 for compression etc etc)
.

Then define a function to refer to the matrix elements.

I'm not sure if this will work by picking up the local value of flag, you may have to include that in the function call, so you would have to

1)define your matrix

2) write your function

bar_diameter(f,bs):=matrix[bs,f]

or just return the matrix result directly, which is not as clear

3)Then call it with

newbardia:=bar_diameter(flag,barsize)


Is that clear?


Cheers

Greg Locock

RE: Reusing conditional statements?

I use a matrix method as follows:

bar_dia := {0.00 0.00 0.375 0.500 0.625 0.750 0.875 1.00 etc.}

a.s := {0.00 0.00 0.11 0.20 0.31 0.44 0.60 0.79, etc.}

Note the first to 0's..  this means that the position is the rebar size.

so a.s[7 gives me the area of steel for a #7 bar and bar_dia[7 gives me the diameter.

Imagineer

RE: Reusing conditional statements?

but that doesn't give him different bar diameters for a given size depending on the local condition.

Cheers

Greg Locock

RE: Reusing conditional statements?

(OP)
Thanks for all the input. My last response did not go through.

I agree with the idea of building a matrix. I made 3 matrices (bar, diam, area) since they are different units, which can be used for the entire sheet. I made a pull-down menu of all bar sizes and by selecting a size, it stored the index of the selected bar. When I select bar_size_tens := 6 (from the menu), the program returns the index, bar_size_tens = 4 (bar #'s start at 3).

Finally,  bar_diameter_tens := diam[bar_size_tens. Then I recreate the menu for different locations (i.e.  bar_size_comp := same pull-down menu).

RE: Reusing conditional statements?

Greg,
  Huh? There is only one diameter for a given bar_size.  Did I misunderstand your post?

Imagineer

RE: Reusing conditional statements?

No, he wanted a bar diameter depending on the (quote) I am trying to define different diameters depending on the location (i.e. bar_diameter_compression, bar_diameter_tension)


So he wants a 2d array

Cheers

Greg Locock

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Resources

Low-Volume Rapid Injection Molding With 3D Printed Molds
Learn methods and guidelines for using stereolithography (SLA) 3D printed molds in the injection molding process to lower costs and lead time. Discover how this hybrid manufacturing process enables on-demand mold fabrication to quickly produce small batches of thermoplastic parts. Download Now
Design for Additive Manufacturing (DfAM)
Examine how the principles of DfAM upend many of the long-standing rules around manufacturability - allowing engineers and designers to place a part’s function at the center of their design considerations. Download Now
Taking Control of Engineering Documents
This ebook covers tips for creating and managing workflows, security best practices and protection of intellectual property, Cloud vs. on-premise software solutions, CAD file management, compliance, and more. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close