bvdet 2,851
Recognized Expert Moderator Specialist
We are parametrically attaching a bent plate object to the side of a building column for support of a skewed beam. Given a relative rotation between the column and beam and which side of the column to attach to, the following code determines the X and Y direction flags to calculate the exact location and the rotation tuple of the bent plate object. Here's the old code (about 5 years old): - if _relrotation > 0.0 and _relrotation < 90.0:
-
_caseno = "Case 1"
-
_xflg = 1
-
_yflg = 1
-
elif _relrotation > 90.0 and _relrotation < 180.0:
-
_caseno = "Case 2"
-
if _hssflgweb == "Short Side":
-
_xflg = -1
-
_yflg = -1
-
else:
-
_xflg = -1
-
_yflg = 1
-
elif _relrotation > 180.0 and _relrotation < 270.0:
-
_caseno = "Case 3"
-
if _hssflgweb == "Short Side":
-
_xflg = -1
-
_yflg = 1
-
else:
-
_xflg = 1
-
_yflg = -1
-
elif _relrotation > 270.0 and _relrotation < 360.0:
-
_caseno = "Case 4"
-
if _hssflgweb == "Short Side":
-
_xflg = 1
-
_yflg = -1
-
else:
-
_xflg = -1
-
_yflg = -1
-
-
if case_no == "Case 1" or case_no == "Case 3":
-
rot_argument = [rel_rotation, 0.0, 0.0]
-
elif case_no == "Case 2" or case_no == "Case 4":
-
rot_argument = [180.0 - rel_rotation, 0.0, 180.0]
-
if hss_flg_web == "Long Side":
-
rot_argument[0] = 180.0 - rot_argument[0]
-
rot_argument[2] = rot_argument[2] + 180.0
-
I just updated the code: - caseDict = {"Case 1": {"Long Side": (1,1,(180.0-relRot, 0.0, 180.0)), \
-
"Short Side": (1,1,(relRot, 0.0, 0.0))}, \
-
"Case 2": {"Long Side": (-1,1,(relRot, 0.0, 0.0)), \
-
"Short Side": (-1,-1,(180.0-relRot, 0.0, 180.0))}, \
-
"Case 3": {"Long Side": (1,-1,(180.0-relRot, 0.0, 180.0)), \
-
"Short Side": (-1,1,(relRot, 0.0, 0.0))}, \
-
"Case 4": {"Long Side": (-1,-1,(relRot, 0.0, 0.0)), \
-
"Short Side": (1,-1,(180.0-relRot, 0.0, 180.0))}
-
}
-
-
if 0.0 < relRot <= 90.0:
-
caseno = "Case 1"
-
elif 90.0 < relRot <= 180.0:
-
caseno = "Case 2"
-
elif 180.0 < relRot <= 270.0:
-
caseno = "Case 3"
-
else:
-
caseno = "Case 4"
-
-
self.xflg, self.yflg, self.rot = caseDict[caseno][flgweb]
I still have an if, elif, else, but it's cleaner and easier to read.
2 1772 bartonc 6,596
Recognized Expert Expert
Very cool. Did you see my "function dispatch" using a dictionary in this thread? It's the same kind of language extension idea, borrowed from another language.
bvdet 2,851
Recognized Expert Moderator Specialist
Very cool. Did you see my "function dispatch" using a dictionary in this thread? It's the same kind of language extension idea, borrowed from another language.
Yes I did Barton. I like what you did there, and I save it for possible future use. Thanks.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Jack Carter |
last post by:
I have been delegated to produce a tool that has
python embedded in it. The desire is to have a
command line interface that inherits all the python
scripting functionality so people can use the tool
either with a flat commandline entry like you would
a debugger or with a script using scoping, loops and
conditional.
I am going from knowing nothing about python to
almost nothing so the learning curve is rather
|
by: Ling Lee |
last post by:
Hello.
I'm trying to write a small program that lets you put in a number as an
integer and then it tells you the textuel representation of the number.
Like if your input is 42, it will say four two.
I found out that I have to make a dictionary like this: List = { 1:"one",
2:"two" and so on )
|
by: rh0dium |
last post by:
Hi all,
I have a dict which looks like this..
dict={'130nm': {'umc': },
'180nm': {'chartered': , 'tsmc':
},
'250nm': {'umc': , 'tsmc':
}
}
|
by: Nico Grubert |
last post by:
Hi there,
I am looking for a way to sort a list containing dictionaries.
This is my example list:
I want to sort the list by dictionary's key 'from_datetime' so the
sorted list should be:
|
by: Brian L. Troutwine |
last post by:
I've got a problem that I can't seem to get my head around and hoped
somebody might help me out a bit:
I've got a dictionary, A, that is arbitarily large and may contains
ints, None and more dictionaries which themselves may contain ints,
None and more dictionaries. Each of the sub-dictionaries is also
arbitrarily large. When pretty printing A, in the context I'm using A
for, it's rather helpful to remove all key:value pairs where value...
| |
by: Charles Sullivan |
last post by:
I'm trying to maintain some older C code (FOSS) which has been
patched by various individuals over the years for portability to
multiple Unix-like operating systems, to wit: Linux, SunOS,
Solaris, Free/Open/NetBSD, Mac OS X, AT&T SysV r4, SCO Unix, AIX,
OSF, NextStep.
I want to add some conditionals like this:
#if defined(USECODE_A)
/*use this code */
|
by: juan-manuel.behrendt |
last post by:
Hello together,
I wrote a script for the engineering software abaqus/CAE. It worked
well until I implemented a selection in order to variate the variable
"lGwU" through an if elif, else statement. I am going to post the
first 82 lines of the script, since the error message points at line
80:
from abaqusConstants import *
from abaqus import *
|
by: asincero |
last post by:
Which is better: using an if/else construct to simulate a C switch or
use a dictionary? Example:
def foo():
if c == 1:
doCase1()
elif c == 2:
doCase2()
elif c == 3:
doCase3()
|
by: dudeja.rajat |
last post by:
Hi,
How to check if something is a list or a dictionary or just a string?
Eg:
for item in self.__libVerDict.itervalues():
self.cbAnalysisLibVersion(END, item)
where __libVerDict is a dictionary that holds values as strings or
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |