Archicad 30 C++ API
Loading...
Searching...
No Matches
Unit and image conversion

Functions providing conversion between different measurement units and different image types. More...

Classes

struct  API_UnitConversionData
 Input and output struct for ACAPI_Conversion_GetConvertedUnitValue. More...
 
struct  API_PictureHandle
 Structure for picture conversion. More...
 
struct  API_MimePicture
 Structure for picture conversion using MIME identifier. More...
 

Enumerations

enum  API_UnitConversionPrefID {
  APIUnitConv_WorkModel , APIUnitConv_WorkLayout , APIUnitConv_WorkAngle , APIUnitConv_DimLinear ,
  APIUnitConv_DimAngle , APIUnitConv_DimRadial , APIUnitConv_DimLevel , APIUnitConv_DimElevation ,
  APIUnitConv_DimDoorWindow , APIUnitConv_DimParapet , APIUnitConv_DimArea , APIUnitConv_CalcLength ,
  APIUnitConv_CalcArea , APIUnitConv_CalcVolume , APIUnitConv_CalcAngle
}
 Describes the supported Project Preferences to use with ACAPI_Conversion_GetConvertedUnitValue. More...
 

Functions

GSErrCode ACAPI_Conversion_GetConvertedUnitValue (API_UnitConversionData *api_unitConvData)
 Returns the value of a physical property (length/area/volume/angle) in the unit of the given Project Preference.
 
GSErrCode ACAPI_Conversion_ConvertPicture (API_PictureHandle *oldPict, API_PictureHandle *newPict)
 Converts a picture to another image format.
 
GSErrCode ACAPI_Conversion_ConvertMimePicture (API_MimePicture *mimePicture)
 Converts a picture to another image format using MIME types.
 
GS::Guid & APIGuid2GSGuid (API_Guid &guid)
 Converting from API_Guid to a GS::Guid.
 
const GS::Guid & APIGuid2GSGuid (const API_Guid &guid)
 Converting from API_Guid to GS::Guid.
 
API_Guid & GSGuid2APIGuid (GS::Guid &guid)
 Converting from GS::Guid to API_Guid.
 
const API_Guid & GSGuid2APIGuid (const GS::Guid &guid)
 Converting from GS::Guid to API_Guid.
 
API_Guid APIGuidFromString (const char *str)
 Converting from a string to an API_Guid.
 
GS::UniString APIGuidToString (const API_Guid &guid)
 Converting the API_Guid to a GS::UniString.
 

Detailed Description

Functions providing conversion between different measurement units and different image types.

Enumeration Type Documentation

◆ API_UnitConversionPrefID

Describes the supported Project Preferences to use with ACAPI_Conversion_GetConvertedUnitValue.

Enumerator
APIUnitConv_WorkModel 

Project Preferences / Working Units / Model Unit

APIUnitConv_WorkLayout 

Project Preferences / Working Units / Layout Unit

APIUnitConv_WorkAngle 

Project Preferences / Working Units / Angle Unit

APIUnitConv_DimLinear 

Project Preferences / Dimensions / Linear Dimensions

APIUnitConv_DimAngle 

Project Preferences / Dimensions / Angular Dimensions

APIUnitConv_DimRadial 

Project Preferences / Dimensions / Radial Dimensions

APIUnitConv_DimLevel 

Project Preferences / Dimensions / Level Dimensions

APIUnitConv_DimElevation 

Project Preferences / Dimensions / Elevation Dimensions

APIUnitConv_DimDoorWindow 

Project Preferences / Dimensions / Door, Window and Skylight Dimensions

APIUnitConv_DimParapet 

Project Preferences / Dimensions / Sill Height Dimensions

APIUnitConv_DimArea 

Project Preferences / Dimensions / Area Calculations

APIUnitConv_CalcLength 

Project Preferences / Calculation Units & Rules / Length Unit

APIUnitConv_CalcArea 

Project Preferences / Calculation Units & Rules / Area Unit

APIUnitConv_CalcVolume 

Project Preferences / Calculation Units & Rules / Volume Unit

APIUnitConv_CalcAngle 

Project Preferences / Calculation Units & Rules / Angle Unit

Function Documentation

◆ ACAPI_Conversion_ConvertMimePicture()

GSErrCode ACAPI_Conversion_ConvertMimePicture ( API_MimePicture * mimePicture)

Converts a picture to another image format using MIME types.

Parameters
mimePicture[in/out] Parameters of the source and destination picture.
Returns
  • NoError - The function completed successfully.
  • APIERR_BADPARS - The input parameters are not given correctly (see API_MimePicture).
  • APIERR_MEMFULL - Not enough memory to create the new pictHdl.
Remarks
This function converts a picture from one standard image format to another. The image formats are specified with MIME (Multipurpose Internet Mail Extensions) types. MIME types of the most commonly used image formats:
Image type MIME type
Windows Bitmap image/x-bmp
GIF image/gif
TIFF image/tiff
JPEG image/jpeg
Pict image/pict
SGI image/x-sgi
Photoshop Image image/x-photoshop
PNG image/png
MacPaint Image image/x-macpaint
Truevision TGA image/x-targa
QuickTime Image image/x-quicktime

You can pass a special output type "vnd/DIB" to create a device independent bitmap on Windows. Conversion from one pixel depth to another is not supported at the moment. You can use the ACAPI_Conversion_ConvertPicture goody function for converting images with API_PictureFormat identifiers rather than MIME types. Remember to dispose the returned outputHdl when it is no longer needed. See more options in the description of the API_MimePicture structure.

Example
Converting a TIFF figure placed on the floorplan into a PNG format image:
GSErrCode ConvertPicture (const API_Guid& pictureGuid)
{
API_Element element;
BNZeroMemory (&element, sizeof (API_Element));
element.header.guid = pictureGuid;
GSErrCode err = ACAPI_Element_Get (&element);
if (err == NoError && element.picture.storageFormat == APIPictForm_TIFF) {
BNZeroMemory (&memo, sizeof (API_ElementMemo));
err = ACAPI_Element_GetMemo (pictureGuid, &memo);
if (err == NoError) {
BNZeroMemory (&mime, sizeof (API_MimePicture));
mime.mimeIn = "image/tiff";
mime.inputHdl = memo.pictHdl;
mime.mimeOut = "image/png";
mime.inContainsMime = false;
if (err == NoError) {
/* mime.outputHdl contains the image in PNG format */
/* change the figure, save into an image file, or anything else... */
/* to avoid memory leak */
BMKillHandle (&mime.outputHdl);
}
}
}
return err;
}
See another sample for using MIME type image conversions in the DG_Test example project of the API DevKit.

◆ ACAPI_Conversion_ConvertPicture()

GSErrCode ACAPI_Conversion_ConvertPicture ( API_PictureHandle * oldPict,
API_PictureHandle * newPict )

Converts a picture to another image format.

Parameters
oldPict[in] Parameters of the source picture. The old format and data must be passed in the storageFormat and pictHdl fields, respectively.
newPict[in/out] Parameters of the destination picture. The new format of the picture must be passed in the storageFormat field. The pictHdl field will be returned according to the specified format.
Returns
  • NoError - The function completed successfully.
  • APIERR_BADPARS - Parameters are nullptr or storage formats are invalid.
  • APIERR_MEMFULL - Not enough memory to create the new pictHdl.
Remarks
This function converts a picture from one standard image format to another. Any picture format can be passed in both the input and output parameters. See also ACAPI_Conversion_ConvertMimePicture if you want to specify the image format using MIME types.

◆ ACAPI_Conversion_GetConvertedUnitValue()

GSErrCode ACAPI_Conversion_GetConvertedUnitValue ( API_UnitConversionData * api_unitConvData)

Returns the value of a physical property (length/area/volume/angle) in the unit of the given Project Preference.

Parameters
api_unitConvData[in/out] You can specify in it the value to convert, and the Project Preference with which to convert. The environment function returns the converted value, extra accuracy and unit string in the same struct.
Returns
  • NoError - The function has completed with success.
  • APIERR_BADPARS - api_unitConvData is nullptr, or api_unitConvData->unitConvPref is invalid.
Remarks
api_unitConvData->value has to be given in m/m²/m³/radian. The converted value will be returned in string format, as it would appear in Archicad.

◆ APIGuid2GSGuid() [1/2]

GS::Guid & APIGuid2GSGuid ( API_Guid & guid)
inline

Converting from API_Guid to a GS::Guid.

Parameters
guidThe API_Guid to convert.
Returns
Converted guid.

◆ APIGuid2GSGuid() [2/2]

const GS::Guid & APIGuid2GSGuid ( const API_Guid & guid)
inline

Converting from API_Guid to GS::Guid.

Parameters
guidThe API_Guid to convert.
Returns
Converted guid.

◆ APIGuidFromString()

API_Guid APIGuidFromString ( const char * str)
inline

Converting from a string to an API_Guid.

Parameters
strString representation of guid.
Returns
Converted guid.

◆ APIGuidToString()

GS::UniString APIGuidToString ( const API_Guid & guid)
inline

Converting the API_Guid to a GS::UniString.

Parameters
guidThe API_Guid to convert.
Returns
Guid represented in GS::UniString.

◆ GSGuid2APIGuid() [1/2]

const API_Guid & GSGuid2APIGuid ( const GS::Guid & guid)
inline

Converting from GS::Guid to API_Guid.

Parameters
guidThe GS::Guid to convert.
Returns
Converted guid.

◆ GSGuid2APIGuid() [2/2]

API_Guid & GSGuid2APIGuid ( GS::Guid & guid)
inline

Converting from GS::Guid to API_Guid.

Parameters
guidThe GS::Guid to convert.
Returns
Converted guid.