mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-06 07:51:47 +00:00
ifc2ca - possibility to exclude zero length springs in point connections
This commit is contained in:
@@ -23,6 +23,7 @@ from pathlib import Path
|
|||||||
|
|
||||||
flatten = itertools.chain.from_iterable
|
flatten = itertools.chain.from_iterable
|
||||||
|
|
||||||
|
includeZeroLength1DSprings = True
|
||||||
|
|
||||||
class COMMANDFILE:
|
class COMMANDFILE:
|
||||||
def __init__(self, dataFilename, asterFilename):
|
def __init__(self, dataFilename, asterFilename):
|
||||||
@@ -116,18 +117,19 @@ class COMMANDFILE:
|
|||||||
if el["geometryType"] == "point"
|
if el["geometryType"] == "point"
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
spring1DGroupNames = tuple(
|
if includeZeroLength1DSprings:
|
||||||
flatten(
|
spring1DGroupNames = tuple(
|
||||||
[
|
flatten(
|
||||||
[
|
[
|
||||||
rel["springGroupName"]
|
[
|
||||||
for rel in el["connections"]
|
rel["springGroupName"]
|
||||||
if rel["springGroupName"]
|
for rel in el["connections"]
|
||||||
|
if rel["springGroupName"]
|
||||||
|
]
|
||||||
|
for el in elements
|
||||||
]
|
]
|
||||||
for el in elements
|
)
|
||||||
]
|
|
||||||
)
|
)
|
||||||
)
|
|
||||||
point1DGroupNames = tuple(
|
point1DGroupNames = tuple(
|
||||||
[
|
[
|
||||||
self.getGroupName(el["ifcName"]) + "_0D"
|
self.getGroupName(el["ifcName"]) + "_0D"
|
||||||
@@ -238,7 +240,14 @@ model = AFFE_MODELE(
|
|||||||
),"""
|
),"""
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
"groupNames": tuple(flatten([point0DGroupNames, spring1DGroupNames]))
|
"groupNames": tuple(
|
||||||
|
flatten(
|
||||||
|
[
|
||||||
|
point0DGroupNames,
|
||||||
|
spring1DGroupNames if includeZeroLength1DSprings else [],
|
||||||
|
]
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
f.write(template.format(**context))
|
f.write(template.format(**context))
|
||||||
@@ -466,9 +475,10 @@ element = AFFE_CARA_ELEM(
|
|||||||
|
|
||||||
f.write(template.format(**context))
|
f.write(template.format(**context))
|
||||||
|
|
||||||
for rel in conn["relatedElements"]:
|
if includeZeroLength1DSprings:
|
||||||
|
for rel in conn["relatedElements"]:
|
||||||
|
|
||||||
template = """
|
template = """
|
||||||
_F(
|
_F(
|
||||||
GROUP_MA = '{groupName}',
|
GROUP_MA = '{groupName}',
|
||||||
CARA = 'K_TR_D_L',
|
CARA = 'K_TR_D_L',
|
||||||
@@ -476,12 +486,12 @@ element = AFFE_CARA_ELEM(
|
|||||||
REPERE = 'LOCAL'
|
REPERE = 'LOCAL'
|
||||||
),"""
|
),"""
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
"groupName": rel["springGroupName"],
|
"groupName": rel["springGroupName"],
|
||||||
"stiffnesses": rel["stiffnesses"],
|
"stiffnesses": rel["stiffnesses"],
|
||||||
}
|
}
|
||||||
|
|
||||||
f.write(template.format(**context))
|
f.write(template.format(**context))
|
||||||
|
|
||||||
for conn in [conn for conn in connections if conn["geometryType"] == "line"]:
|
for conn in [conn for conn in connections if conn["geometryType"] == "line"]:
|
||||||
|
|
||||||
@@ -542,21 +552,24 @@ element = AFFE_CARA_ELEM(
|
|||||||
|
|
||||||
f.write(template.format(**context))
|
f.write(template.format(**context))
|
||||||
|
|
||||||
for rel in conn["relatedElements"]:
|
if includeZeroLength1DSprings:
|
||||||
|
for rel in conn["relatedElements"]:
|
||||||
|
|
||||||
template = """
|
template = """
|
||||||
_F(
|
_F(
|
||||||
GROUP_MA = '{groupName}',
|
GROUP_MA = '{groupName}',
|
||||||
CARA = 'VECT_X_Y',
|
CARA = 'VECT_X_Y',
|
||||||
VALE = {localAxesXY}
|
VALE = {localAxesXY}
|
||||||
),"""
|
),"""
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
"groupName": rel["springGroupName"],
|
"groupName": rel["springGroupName"],
|
||||||
"localAxesXY": tuple(rel["orientation"][0] + rel["orientation"][1]),
|
"localAxesXY": tuple(
|
||||||
}
|
rel["orientation"][0] + rel["orientation"][1]
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
f.write(template.format(**context))
|
f.write(template.format(**context))
|
||||||
|
|
||||||
for conn in [conn for conn in connections if conn["geometryType"] == "line"]:
|
for conn in [conn for conn in connections if conn["geometryType"] == "line"]:
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user