Junction Diagram Automation Suite 1.2.0
An AutoCAD 2024 plugin for the manipulation and generation of junction box wiring diagrams
Loading...
Searching...
No Matches
helpers.cpp File Reference

Helper functions related to database operations. More...

#include "helpers.h"

Functions

AcDbObjectId acadInsertBlock (const wchar_t *blockName, const AcGePoint3d &origin)
 Insert a block into the database at a specified origin point.
Acad::ErrorStatus acadSetDynBlockProperty (const AcDbObjectId &blockRefId, const wchar_t *propName, const AcDbEvalVariant &newValue)
 Set a dynamic block property to a new value.
Acad::ErrorStatus acadGetDynBlockProperty (const AcDbObjectId &blockRefId, const wchar_t *propName, AcDbEvalVariant &outValue)
 Retrieve the value of a dynamic block property.
Acad::ErrorStatus acadSetBlockAttribute (const AcDbObjectId &blockRefId, const wchar_t *tagName, const wchar_t *newValue)
 Set a block attribute to a new value.
Acad::ErrorStatus acadGetBlockAttribute (const AcDbObjectId &blockRefId, const wchar_t *tagName, std::wstring &outValue)
 Retrieve the text value of a block attribute.
Acad::ErrorStatus acadSetObjectProperty (const AcDbObjectId &objId, AcDb::DxfCode groupCode, const wchar_t *value)
 Set a general object property to a new value.
Acad::ErrorStatus acadSetObjectPosition (const AcDbObjectId &objId, const AcGePoint3d &position)
 Set the position of a supported entity.
Acad::ErrorStatus acadGetObjectPosition (const AcDbObjectId &objId, AcGePoint3d &outPosition)
 Get the position of a supported entity.
Acad::ErrorStatus acadSetObjectScale (const AcDbObjectId &objId, const AcGeScale3d &scale)
 Set the scale of a supported entity.
Acad::ErrorStatus acadGetObjectScale (const AcDbObjectId &objId, AcGeScale3d &outScale)
 Get the scale of a supported entity.
Acad::ErrorStatus acadGetBlockName (const AcDbObjectId &objId, std::wstring &name)
 Get block name that an object references.

Detailed Description

Helper functions related to database operations.

This module is part of the Junction Diagram Automation Suite. Unauthorized copying, distribution, or modification is prohibited.

Version
1.2.0
Author
Ethan Barnes ebarn.nosp@m.es@g.nosp@m.astec.nosp@m.heng.nosp@m..com
Date
2025-06-19

Function Documentation

◆ acadGetBlockAttribute()

Acad::ErrorStatus acadGetBlockAttribute ( const AcDbObjectId & blockRefId,
const wchar_t * tagName,
std::wstring & outValue )

Retrieve the text value of a block attribute.

Searches the given block reference for an attribute whose tag matches tagName (case‑insensitive). If found, the attribute’s text string is returned in outValue.

Parameters
blockRefIdThe object ID of the block reference to inspect.
tagNameThe attribute tag to search for (case‑insensitive).
outValueReceives the attribute’s text string on success.
Returns
Acad::ErrorStatus
  • Acad::eOk – attribute found, value returned.
  • Acad::eKeyNotFound – attribute with that tag not present.
  • Other Acad errors – object open failure, iterator error, etc.

◆ acadGetBlockName()

Acad::ErrorStatus acadGetBlockName ( const AcDbObjectId & objId,
std::wstring & name )

Get block name that an object references.

This function takes an objectId, checks to see if its a reference to a block, and returns the name of that block reference.

Parameters
objIdThe object ID of the entity whose block name we want.ABC
nameA wide string reference where the name will be stored. Empty if the object is not a block reference.
Returns
Acad::ErrorState indicating success or failure of the operation.

◆ acadGetDynBlockProperty()

Acad::ErrorStatus acadGetDynBlockProperty ( const AcDbObjectId & blockRefId,
const wchar_t * propName,
AcDbEvalVariant & outValue )

Retrieve the value of a dynamic block property.

This function reads the current value of a specified property from a dynamic block reference.

Parameters
blockRefIdThe object ID of the block reference whose property is being read.
propNameThe name of the property to retrieve. Must exist in the dynamic block definition.
outValueOutput parameter that receives the current value of the property, encapsulated as an AcDbEvalVariant.
Returns
Acad::ErrorStatus indicating success or failure of the operation. Returns Acad::eKeyNotFound if the property does not exist.

◆ acadGetObjectPosition()

Acad::ErrorStatus acadGetObjectPosition ( const AcDbObjectId & objId,
AcGePoint3d & outPosition )

Get the position of a supported entity.

This function retrieves the position of a supported object type, such as a block reference, point, circle, or text. The result is stored in a 3D point.

Parameters
objIdThe object ID of the entity.
outPositionThe position of the entity, if supported.
Returns
Acad::ErrorStatus indicating success or failure of the operation. Returns Acad::eInvalidInput if the entity does not have a position.

◆ acadGetObjectScale()

Acad::ErrorStatus acadGetObjectScale ( const AcDbObjectId & objId,
AcGeScale3d & outScale )

Get the scale of a supported entity.

Retrieves the scale factors (X, Y, Z) of a block reference or other scalable entity.

Parameters
objIdThe object ID of the entity.
outScaleReceives the object's scale as an AcGeScale3d.
Returns
Acad::ErrorStatus indicating success or failure. Returns Acad::eInvalidInput if scale is not supported for this type.

◆ acadInsertBlock()

AcDbObjectId acadInsertBlock ( const wchar_t * blockName,
const AcGePoint3d & origin )

Insert a block into the database at a specified origin point.

This function inserts a block with the given name into the database at the provided origin point and returns the object ID of the inserted block.

Parameters
blockNameThe name of the block to be inserted. Must be a valid string representing an existing block definition.
originThe 3D point where the block should be placed in the database.
Returns
The AcDbObjectId of the newly inserted block, or an invalid ID if insertion fails.

◆ acadSetBlockAttribute()

Acad::ErrorStatus acadSetBlockAttribute ( const AcDbObjectId & blockRefId,
const wchar_t * tagName,
const wchar_t * newValue )

Set a block attribute to a new value.

This function updates the specified attribute of a block reference with a new value.

Parameters
blockRefIdThe object ID of the block reference whose attribute is being set.
tagNameThe name of the tag associated with the attribute. Must exist in the block definition.
newValueA wide string pointer to the new value for the specified attribute.
Returns
Acad::ErrorStatus indicating success or failure of the operation.

◆ acadSetDynBlockProperty()

Acad::ErrorStatus acadSetDynBlockProperty ( const AcDbObjectId & blockRefId,
const wchar_t * propName,
const AcDbEvalVariant & newValue )

Set a dynamic block property to a new value.

This function updates the specified property of a dynamic block reference with a new value.

Parameters
blockRefIdThe object ID of the block reference whose property is being set.
propNameThe name of the property to be updated. Must exist in the dynamic block definition.
newValueThe new value for the specified property, encapsulated as an AcDbEvalVariant.
Returns
Acad::ErrorStatus indicating success or failure of the operation.

◆ acadSetObjectPosition()

Acad::ErrorStatus acadSetObjectPosition ( const AcDbObjectId & objId,
const AcGePoint3d & position )

Set the position of a supported entity.

This function updates the position of a supported object type, such as a block reference, point, text, or circle. Entities not supporting a direct position cannot be modified using this function.

Parameters
objIdThe object ID of the entity to be updated.
positionThe new position to assign to the entity.
Returns
Acad::ErrorStatus indicating success or failure of the operation. Returns Acad::eInvalidInput if the entity does not support positioning.

◆ acadSetObjectProperty()

Acad::ErrorStatus acadSetObjectProperty ( const AcDbObjectId & objId,
AcDb::DxfCode groupCode,
const wchar_t * value )

Set a general object property to a new value.

This function updates the specified property of an object with a new value, identified by a DXF group code.

Parameters
objIdThe object ID of the entity whose property is being set.
groupCodeThe DXF group code representing the property type to be updated. For example, AcDb::kDxfLayerName for the layer name.
valueA wide string pointer to the new value for the specified property.
Returns
Acad::ErrorStatus indicating success or failure of the operation.

◆ acadSetObjectScale()

Acad::ErrorStatus acadSetObjectScale ( const AcDbObjectId & objId,
const AcGeScale3d & scale )

Set the scale of a supported entity.

Updates the X/Y/Z scale factors of a block reference or similar entity.

Parameters
objIdThe object ID of the entity to scale.
scaleThe new scale as an AcGeScale3d.
Returns
Acad::ErrorStatus indicating success or failure. Returns Acad::eInvalidInput if the entity does not support scaling.