mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Implements business to geometry mapping for alignment cant.
Also fixes problems that were created by this work in other files
This commit is contained in:
@@ -45,6 +45,9 @@ def add_zero_length_segment(file: ifcopenshell.file, entity: entity_instance) ->
|
||||
f"Expected entity type to be one of {[_ for _ in expected_types]}, instead received '{entity.is_a()}"
|
||||
)
|
||||
|
||||
if ifcopenshell.api.alignment.has_zero_length_segment(entity):
|
||||
return # do nothing if the entity already has a zero length segment
|
||||
|
||||
if entity.is_a("IfcCompositeCurve"):
|
||||
last_segment = entity.Segments[-1]
|
||||
settings = ifcopenshell.geom.settings()
|
||||
@@ -67,7 +70,7 @@ def add_zero_length_segment(file: ifcopenshell.file, entity: entity_instance) ->
|
||||
curve_segment = file.createIfcCurveSegment(
|
||||
Transition="DISCONTINUOUS",
|
||||
Placement=file.createIfcAxis2Placement2D(
|
||||
Location=file.createIfcCartesianPoint(Coordinates=((x, y))),
|
||||
Location=file.createIfcCartesianPoint(((x, y))),
|
||||
RefDirection=file.createIfcDirection((dx, dy)),
|
||||
),
|
||||
SegmentStart=file.createIfcLengthMeasure(0.0),
|
||||
@@ -80,22 +83,72 @@ def add_zero_length_segment(file: ifcopenshell.file, entity: entity_instance) ->
|
||||
if 0 < len(rel.RelatedObjects):
|
||||
last_segment = rel.RelatedObjects[-1]
|
||||
if last_segment.is_a("IfcAlignmentSegment"):
|
||||
design_parameters = file.createIfcAlignmentHorizontalSegment(
|
||||
StartPoint=file.createIfcCartesianPoint(
|
||||
(0.0, 0.0)
|
||||
), # this is a little problematic. need to know the end point and tangent
|
||||
StartDirection=0.0, # of the previous segment, which requires geometry mapping
|
||||
SegmentLength=0.0,
|
||||
PredefinedType="LINE",
|
||||
)
|
||||
segment = file.createIfcAlignmentSegment(
|
||||
GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters
|
||||
)
|
||||
ifcopenshell.api.nest.assign_object(
|
||||
file,
|
||||
related_objects=[
|
||||
segment,
|
||||
],
|
||||
relating_object=entity,
|
||||
)
|
||||
break
|
||||
if entity.is_a("IfcAlignmentHorizontal"):
|
||||
design_parameters = file.createIfcAlignmentHorizontalSegment(
|
||||
StartPoint=file.createIfcCartesianPoint(
|
||||
(0.0, 0.0)
|
||||
), # this is a little problematic. need to know the end point and tangent
|
||||
StartDirection=0.0, # of the previous segment, which requires geometry mapping
|
||||
SegmentLength=0.0,
|
||||
PredefinedType="LINE",
|
||||
)
|
||||
segment = file.createIfcAlignmentSegment(
|
||||
GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters
|
||||
)
|
||||
ifcopenshell.api.nest.assign_object(
|
||||
file,
|
||||
related_objects=[
|
||||
segment,
|
||||
],
|
||||
relating_object=entity,
|
||||
)
|
||||
break
|
||||
elif entity.is_a("IfcAlignmentVertical"):
|
||||
design_parameters = file.createIfcAlignmentVerticalSegment(
|
||||
StartDistAlong=last_segment.DesignParameters.StartDistAlong
|
||||
+ last_segment.DesignParameters.HorizontalLength,
|
||||
HorizontalLength=0.0,
|
||||
StartHeight=0.0,
|
||||
StartGradient=last_segment.DesignParameters.EndGradient,
|
||||
EndGradient=last_segment.DesignParameters.EndGradient,
|
||||
PredefinedType="CONSTANTGRADIENT",
|
||||
)
|
||||
segment = file.createIfcAlignmentSegment(
|
||||
GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters
|
||||
)
|
||||
ifcopenshell.api.nest.assign_object(
|
||||
file,
|
||||
related_objects=[
|
||||
segment,
|
||||
],
|
||||
relating_object=entity,
|
||||
)
|
||||
break
|
||||
elif entity.is_a("IfcAlignmentCant"):
|
||||
design_parameters = file.createIfcAlignmentCantSegment(
|
||||
StartDistAlong=last_segment.DesignParameters.StartDistAlong
|
||||
+ last_segment.DesignParameters.HorizontalLength,
|
||||
HorizontalLength=0.0,
|
||||
StartCantLeft=(
|
||||
last_segment.DesignParameters.EndCantLeft
|
||||
if last_segment.DesignParameters.EndCantLeft != None
|
||||
else last_segment.DesignParameters.StartCantLeft
|
||||
),
|
||||
StartCantRight=(
|
||||
last_segment.DesignParameters.EndCantRight
|
||||
if last_segment.DesignParameters.EndCantRight != None
|
||||
else last_segment.DesignParameters.StartCantRight
|
||||
),
|
||||
PredefinedType="CONSTANTCANT",
|
||||
)
|
||||
segment = file.createIfcAlignmentSegment(
|
||||
GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters
|
||||
)
|
||||
ifcopenshell.api.nest.assign_object(
|
||||
file,
|
||||
related_objects=[
|
||||
segment,
|
||||
],
|
||||
relating_object=entity,
|
||||
)
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user