Archicad 28 C++ API
Loading...
Searching...
No Matches
ACAPI::MEP::v1::FlexibleSegment Class Referencefinal

In contrast to rigid segments flexible duct is not a connection of multiple elements (straight segments and bends), instead a type of ducting pipe that could easily be bent in different angles. Since Archicad 28 there is a flexible pipe as well for liquids. FlexibleSegment either has a spline geometry defined by control points, or a polyline geometry, which is defined by alternating straight line parts and spline parts. Line parts are defined by their starting and ending coordinates, while spline parts are defined by control points. These alterning segments must start where the previous one ends. Polyline FlexibleSegemnts are only supported in the Piping domain. In the Ventilation domain FlexibleSegments can only be splines. More...

#include <MEPFlexibleSegment.hpp>

Inheritance diagram for ACAPI::MEP::v1::FlexibleSegment:
ACAPI::MEP::v1::ModifiableElementBase ACAPI::MEP::v1::ElementBase ACAPI::v1::ElementBase ACAPI::v1::Object

Public Member Functions

FlexibleSegmentDefault PickUpDefault () const
 Picks up the Default from the FlexibleSegment.
 
double GetWidth () const
 
double GetHeight () const
 
Result< std::vector< API_Coord3D > > GetControlPoints () const
 
Result< FlexibleSegmentPolylineGetPolyline () const
 
Domain GetDomain () const
 Returns the domain of the FlexibleSegment.
 
template<typename ModifierFunc >
Result< void > Modify (const ModifierFunc &modifierFunc, const GS::UniString &undoString)
 Executes the passed modifier scope in an Undoable command.
 
Result< void > Inject (const FlexibleSegmentDefault &flexibleSegmentDefault)
 Injects the Default settings into the FlexibleSegment.
 
Result< void > SetControlPoints (const std::vector< API_Coord3D > &controlPoints)
 Sets the FlexibleSegment's geometry to a spline.
 
Result< void > SetPolyline (const FlexibleSegmentPolyline &polyline)
 Sets the FlexibleSegment's geometry to a polyline.
 
Result< void > SetWidth (double width)
 Sets the width of the FlexibleSegment.
 
Result< void > SetHeight (double height)
 Sets the height of the FlexibleSegment.
 
- Public Member Functions inherited from ACAPI::MEP::v1::ModifiableElementBase
template<typename ModifierFunc >
Result< void > Modify (const ModifierFunc &modifierFunc, const GS::UniString &undoString)
 Executes the passed modifier scope in an Undoable command.
 
void SetAnchorPoint (const API_Coord3D &anchorPoint)
 Sets the anchor point of the ModifiableElement.
 
void SetOrientation (const MEP::Orientation &orientation)
 Sets the orientation of the ModifiableElement.
 
void SetObjectId (const API_Guid &libraryPartId)
 Sets the referenced library part of the ModifiableElement.
 
- Public Member Functions inherited from ACAPI::MEP::v1::ElementBase
bool Exists () const
 
std::vector< UniqueIDGetPortIDs () const
 
std::vector< UniqueIDGetDirectConnectedMEPElementIds () const
 
API_Coord3D GetAnchorPoint () const
 
Orientation GetOrientation () const
 
API_Guid GetObjectId () const
 
- Public Member Functions inherited from ACAPI::v1::ElementBase
UniqueID GetElemId () const
 Get unique identifier of the ElementBase object.
 
Result< void > IsEditable () const
 Checks whether the element is editable.
 
- Public Member Functions inherited from ACAPI::v1::Object
 Object (std::shared_ptr< Impl::ObjectImpl > impl)
 Constructs a new object.
 
const API_TokenGetToken () const
 Get the token for this object.
 

Static Public Member Functions

static Result< FlexibleSegmentGet (const UniqueID &uniqueId)
 Returns a FlexibleSegment.
 

Additional Inherited Members

- Protected Member Functions inherited from ACAPI::MEP::v1::ModifiableElementBase
 ModifiableElementBase (std::shared_ptr< Impl::IElementBaseImpl > impl)
 Constructs a ModifiableElementBase with the IElementBaseImpl.
 
 Modifier (ModifiableElementBase &parent)
 Constructs a Modifier with the parent ModifiableElementBase.
 
void FinalizeModification () override
 Finalizes the modifications.
 
- Protected Member Functions inherited from ACAPI::MEP::v1::ElementBase
 ElementBase (std::shared_ptr< Impl::IElementBaseImpl > impl)
 Constructs an ElementBase with an element base implementation.
 
- Protected Member Functions inherited from ACAPI::v1::ElementBase
 ElementBase (std::shared_ptr< Impl::ObjectImpl > impl)
 Constructs a new ElementBase.
 
- Protected Member Functions inherited from ACAPI::v1::Object
 ~Object ()
 Default destructor.
 
- Protected Attributes inherited from ACAPI::v1::Object
std::shared_ptr< Impl::ObjectImplmImpl
 Impl object given by constructor.
 

Detailed Description

In contrast to rigid segments flexible duct is not a connection of multiple elements (straight segments and bends), instead a type of ducting pipe that could easily be bent in different angles. Since Archicad 28 there is a flexible pipe as well for liquids. FlexibleSegment either has a spline geometry defined by control points, or a polyline geometry, which is defined by alternating straight line parts and spline parts. Line parts are defined by their starting and ending coordinates, while spline parts are defined by control points. These alterning segments must start where the previous one ends. Polyline FlexibleSegemnts are only supported in the Piping domain. In the Ventilation domain FlexibleSegments can only be splines.

Since
Archicad 27
Example code snippet from Test / New MEP
Getters
if (flexibleSegment.IsErr ()) {
ACAPI_WriteReport (flexibleSegment.UnwrapErr ().text.c_str (), false);
return;
}
Reporter reporter;
reporter.SetTabCount (0);
reporter.Add ("Control points:");
reporter.SetTabCount (1);
ACAPI::Result<std::vector<API_Coord3D>> controlPoints = flexibleSegment->GetControlPoints ();
if (controlPoints.IsErr ()) {
ACAPI_WriteReport (controlPoints.UnwrapErr ().text.c_str (), false);
return;
}
for (const API_Coord3D& controlPoint : *controlPoints)
reporter.Add (ToString (controlPoint));
reporter.AddNewLine ();
static Result< FlexibleSegment > Get(const UniqueID &uniqueId)
Returns a FlexibleSegment.
Result is the standard return type of API functions.
Definition: Result.hpp:845
E UnwrapErr() const
Unwraps the error value contained in the Result. Trying to UnwrapErr the value while it contains an O...
Definition: Result.hpp:1140
bool IsErr() const
Definition: Result.hpp:945
void ACAPI_WriteReport(const GS::UniString &format, bool withDial,...)
Writes a report string into the Report Windowot into a custom alert window.
Real (Cartesian) 3D coordinates of a three-dimensional space.
Definition: APIdefs_Base.h:108
Modification
if (flexibleSegment.IsErr ()) {
ACAPI_WriteReport (flexibleSegment.UnwrapErr ().text.c_str (), false);
return flexibleSegment.UnwrapErr ().kind;
}
if (ACAPI::Result<std::vector<API_Coord3D>> controlPoints = flexibleSegment->GetControlPoints (); controlPoints.IsOk ()) {
for (API_Coord3D& controlPoint : *controlPoints)
controlPoint.x += 1.0;
ACAPI::Result<void> modifyResult = flexibleSegment->Modify ([&](FlexibleSegment::Modifier& modifier) {
modifier.SetControlPoints (*controlPoints);
}, "Modify the control points of Flexible Segment.");
} else if (ACAPI::Result<FlexibleSegmentPolyline> polyline = flexibleSegment->GetPolyline (); polyline.IsOk ()) {
for (std::variant<FlexibleSegmentPolylineLinePart, FlexibleSegmentPolylineSplinePart>& polylinePart : *polyline) {
std::visit (GS::Overloaded {
[] (FlexibleSegmentPolylineLinePart& line) {
line.begin.x *= 2.0;
line.begin.y *= 2.0;
line.begin.z *= 2.0;
line.end.x *= 2.0;
line.end.y *= 2.0;
line.end.z *= 2.0;
},
[] (FlexibleSegmentPolylineSplinePart& spline) {
for (API_Coord3D& controlPoint : spline.controlPoints) {
controlPoint.x *= 2.0;
controlPoint.y *= 2.0;
controlPoint.z *= 2.0;
}
}
}, polylinePart);
}
ACAPI::Result<void> modifyResult = flexibleSegment->Modify ([&](FlexibleSegment::Modifier& modifier) {
modifier.SetPolyline (*polyline);
}, "Modify the polyline of Flexible Segment.");
} else {
return Error;
}
return NoError;
bool IsOk() const
Definition: Result.hpp:940

Member Function Documentation

◆ Get()

static Result< FlexibleSegment > ACAPI::MEP::v1::FlexibleSegment::Get ( const UniqueID uniqueId)
static

Returns a FlexibleSegment.

Parameters
uniqueIdThe UniqueID of the requested FlexibleSegment.
Returns
If the uniqueId belongs to a FlexibleSegment, returns the object associated to it, otherwise Error.

◆ GetControlPoints()

Result< std::vector< API_Coord3D > > ACAPI::MEP::v1::FlexibleSegment::GetControlPoints ( ) const
Returns
Returns the control points of the FlexibleSegment if it is defined by a spline.

◆ GetDomain()

Domain ACAPI::MEP::v1::FlexibleSegment::GetDomain ( ) const

Returns the domain of the FlexibleSegment.

Returns
The returned domain could only be ventilation.

◆ GetHeight()

double ACAPI::MEP::v1::FlexibleSegment::GetHeight ( ) const
Returns
Returns the height of the FlexibleSegment.

◆ GetPolyline()

Result< FlexibleSegmentPolyline > ACAPI::MEP::v1::FlexibleSegment::GetPolyline ( ) const
Returns
Returns the polyline of the FlexibleSegment if it is defined by a polyline .

◆ GetWidth()

double ACAPI::MEP::v1::FlexibleSegment::GetWidth ( ) const
Returns
Returns the width of the FlexibleSegment.

◆ Inject()

Result< void > ACAPI::MEP::v1::FlexibleSegment::Inject ( const FlexibleSegmentDefault flexibleSegmentDefault)

Injects the Default settings into the FlexibleSegment.

Parameters
flexibleSegmentDefaultThe Default what will be injected.
Returns
Returns an error if the injection fails for some reason, otherwise nothing.

◆ Modify()

template<typename ModifierFunc >
Result< void > ACAPI::MEP::v1::FlexibleSegment::Modify ( const ModifierFunc &  modifierFunc,
const GS::UniString &  undoString 
)

Executes the passed modifier scope in an Undoable command.

Parameters
modifierFuncThe modifier scope (lambda, std::function or function pointer) the caller wants to execute.
undoStringThe text which appears in the undo queue of Archicad after executing the command.
Returns
Returns an error if the process of modification fails for some reason, otherwise nothing.

◆ PickUpDefault()

FlexibleSegmentDefault ACAPI::MEP::v1::FlexibleSegment::PickUpDefault ( ) const

Picks up the Default from the FlexibleSegment.

Returns
Returns a FlexibleSegmentDefault with the parameters of the object it was called for.

◆ SetControlPoints()

Result< void > ACAPI::MEP::v1::FlexibleSegment::SetControlPoints ( const std::vector< API_Coord3D > &  controlPoints)

Sets the FlexibleSegment's geometry to a spline.

Parameters
controlPointsThe control points of the spline to be set.
Returns
Returns an error if the points are invalid, for example:
  • Control points are empty.
  • Two adjacent points at the same location.

◆ SetHeight()

Result< void > ACAPI::MEP::v1::FlexibleSegment::SetHeight ( double  height)

Sets the height of the FlexibleSegment.

Parameters
heightThe value to be set.
Returns
Returns an error if the height is not positive, otherwise nothing.

◆ SetPolyline()

Result< void > ACAPI::MEP::v1::FlexibleSegment::SetPolyline ( const FlexibleSegmentPolyline polyline)

Sets the FlexibleSegment's geometry to a polyline.

Parameters
polylineThe polyline to be set.
Returns
Returns an error if the polyline is invalid, for example:
  • Polyline is empty.
  • Adjacent segments are of the same type.
  • Adjacent starting/ending points don't connect.
  • Setting polyline geometry on a Ventillation FlexibleSegment.

◆ SetWidth()

Result< void > ACAPI::MEP::v1::FlexibleSegment::SetWidth ( double  width)

Sets the width of the FlexibleSegment.

Parameters
widthThe value to be set.
Returns
Returns an error if the width is not positive, otherwise nothing.