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
JunctionBuilder.cpp File Reference

Definitons for building junction boxes. More...

#include "JunctionBuilder.h"

Classes

struct  DialogResult
 Aggregates the data collected from the user via the dialog box. More...

Enumerations

enum  BoxSize { SMALL , MEDIUM , LARGE , CUSTOM }
 Predefined enclosure footprints supported by the tool. More...

Functions

void _drawJunctionBox (std::string filename, std::string selectedTag, BoxSize selectedSize, AcGePoint3d origin)
 Draw a junction box from a file.
bool _shouldSplit (BoxSize boxSize, std::vector< Cable > &cables, int currentCableIndex, int currentTerminalIndex, int currentTableIndex)
 Given a cable list and a current position in that list, should the next cable be drawn on the next table.
std::vector< Cable_xlsxGetCables (HWND hDlg, const std::string &filename, const std::string &junctionTag)
 Parse the provided Cable Schedule workbook and create a list of Cable objects for the specified junction tag.
void _xlsxGetJunctionTags (HWND hDlg, const std::string &filename, std::vector< std::string > &tags)
 Collect all unique junction tags found in the Cable Schedule sheet of the workbook.
int _xlsxGetJunctionFootprint (HWND hDlg, std::string filename, std::string junctionTag, BoxSize boxSize)
 Calculate the total number of terminals required by all cables that terminate in the given junction tag.
void _updateSizeRadioButtons (HWND hDlg, const std::vector< HWND > &sizeButtons, const std::vector< int > &spareCounts)
void _rebuildDialogBox (const std::vector< std::string > &junctionTags, std::vector< HWND > &tagRadioButtons, std::vector< HWND > &sizeRadioButtons, const std::vector< int > &spareCounts, HWND hDlg)
 Rebuild (or build) the dialog‑box controls for junction‑tag and box‑ size selection.
INT_PTR CALLBACK _DialogProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 Dialog‑box procedure that handles all messages for the Junction Box Builder dialog.
void buildJunctionBox ()
 Build a junction box based on the provided specifications.
void flipCable ()
 Flip a cable or a set of cables.
void reIndexCable ()
 Change the terminal index of a cable or set of cables.

Detailed Description

Definitons for building junction boxes.

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

Enumeration Type Documentation

◆ BoxSize

enum BoxSize

Predefined enclosure footprints supported by the tool.

Enumerator
SMALL 

12" × 12" × 6" enclosure

MEDIUM 

16" × 16" × 6" enclosure

LARGE 

24" × 24" × 8" enclosure

CUSTOM 

Custom enclosure. User will place the cables.

Function Documentation

◆ _DialogProc()

INT_PTR CALLBACK _DialogProc ( HWND hDlg,
UINT message,
WPARAM wParam,
LPARAM lParam )

Dialog‑box procedure that handles all messages for the Junction Box Builder dialog.

Parameters
hDlgDialog window handle.
messageWindows message identifier.
wParamAdditional message information.
lParamAdditional message information (custom for WM_INITDIALOG).
Returns
TRUE if the message was processed, FALSE otherwise (per Windows API requirements for dialog procedures).

◆ _drawJunctionBox()

void _drawJunctionBox ( std::string filename,
std::string selectedTag,
BoxSize selectedSize,
AcGePoint3d origin )

Draw a junction box from a file.

Parameters
filenameAbsolute path to the Excel (.xlsx) file.
selectedTagTag (e.g. "IJB-810") identifying the junction whose cables should be extracted.
selectedSizeSize of the box to be drawn.
originPoint where the box should be drawn. (Usually 0 0 0)

◆ _rebuildDialogBox()

void _rebuildDialogBox ( const std::vector< std::string > & junctionTags,
std::vector< HWND > & tagRadioButtons,
std::vector< HWND > & sizeRadioButtons,
const std::vector< int > & spareCounts,
HWND hDlg )

Rebuild (or build) the dialog‑box controls for junction‑tag and box‑ size selection.

The function is called after selecting a new XLSX file and whenever the spare‑terminal counts must be refreshed.

Parameters
junctionTagsList of available junction tags.
tagRadioButtonsVector that will receive handles to dynamically created tag buttons (output).
sizeRadioButtonsVector that will receive handles to size buttons (output).
spareCountsSpare‑terminal counts for each predefined box size.
hDlgDialog window handle.

◆ _shouldSplit()

bool _shouldSplit ( BoxSize boxSize,
std::vector< Cable > & cables,
int currentCableIndex,
int currentTerminalIndex,
int currentTableIndex )

Given a cable list and a current position in that list, should the next cable be drawn on the next table.

Parameters
boxSizeSize of the box.
cablesReference to a vector of Cable objects.
currentCableIndexThe index of the cable that is about to be added to the drawing.
currentTerminalIndexThe terminal that the next cable will reside on.
currentTableIndexThe current table being drawn to.
Returns
true if the cable being drawn should be placed on the next table, false otherwise.

◆ _updateSizeRadioButtons()

void _updateSizeRadioButtons ( HWND hDlg,
const std::vector< HWND > & sizeButtons,
const std::vector< int > & spareCounts )

brief Update the size‑selection radio buttons to show how many spare terminals each box size would have after the current selection.

Parameters
hDlgDialog‑box window handle.
sizeButtonsHandles of size radio buttons in dialog.
spareCountsSpare‑terminal counts (same order as sizeButtons).

◆ _xlsxGetCables()

std::vector< Cable > _xlsxGetCables ( HWND hDlg,
const std::string & filename,
const std::string & junctionTag )

Parse the provided Cable Schedule workbook and create a list of Cable objects for the specified junction tag.

Parameters
hDlgParent‑window handle used for any error message boxes.
filenameAbsolute path to the Excel (.xlsx) file.
junctionTagTag (e.g. "IJB-810") identifying the junction whose cables should be extracted.
Returns
Vector of fully‑populated Cable objects. If the file fails to open or is incompatible, an empty vector is returned.

◆ _xlsxGetJunctionFootprint()

int _xlsxGetJunctionFootprint ( HWND hDlg,
std::string filename,
std::string junctionTag,
BoxSize boxSize )

Calculate the total number of terminals required by all cables that terminate in the given junction tag.

Parameters
hDlgParent‑window handle for error dialogs.
filenamePath to the Excel workbook.
junctionTagJunction tag whose footprint is required.
boxSizeSize of the box to calculate the footprint on. (Required to account for table splitting)
Returns
Terminal count ("footprint").

◆ _xlsxGetJunctionTags()

void _xlsxGetJunctionTags ( HWND hDlg,
const std::string & filename,
std::vector< std::string > & tags )

Collect all unique junction tags found in the Cable Schedule sheet of the workbook.

Parameters
hDlgParent‑window handle for error dialogs.
filenamePath to the Excel workbook.
tagsReference that will be filled with unique tags (output).

◆ buildJunctionBox()

void buildJunctionBox ( )

Build a junction box based on the provided specifications.

This function is responsible for constructing a junction box by utilizing available data such as device and cable information. It involves generating the layout, placing components appropriately within the AutoCAD environment, and ensuring all connections are accurately represented.

The process may include reading from an Excel file to gather necessary input data, interacting with AutoCAD for drawing purposes, and managing various attributes related to devices and cables. It serves as a core functionality of the Junction Diagram Automation Suite.

◆ flipCable()

void flipCable ( )

Flip a cable or a set of cables.

This function asks the user to select a set of cable-related blocks, and then automatically flips the cables about the axis of the junction termination block

◆ reIndexCable()

void reIndexCable ( )

Change the terminal index of a cable or set of cables.

This function asks the user to select a set of cable-related blocks, and then asks for the terminal number of the top wire. It then automatically changes the attributes of each cable to match the respective terminal blocks they attach to, assuming proper spacing.