BIM Coordinator Program (INT) April 22, 2024

Find the next step in your career as a Graphisoft Certified BIM Coordinator!

Archicad C++ API
About Archicad add-on development using the C++ API.

Change/modify dimension

ReignBough
Enthusiast
I've created a simple code that will read all the API_DimElem from memo then combine consecutive equidistant dimensions (dimVal). Then use ACAPI_Element_Change() to update the element but it returns API_BADPARS.
/***** code for creating newDimElems here *****/

// change/update element
dimCnt = newDimElems.GetSize();
memo.dimElems = (API_DimElem**)BMAllocateHandle(sizeof(API_DimElem) * dimCnt, ALLOCATE_CLEAR, 0);
for (UInt32 i = 0; i < dimCnt; ++i)
	(*memo.dimElems) = newDimElems;
API_Element mask;
ACAPI_ELEMENT_MASK_CLEAR(mask);
ACAPI_ELEMENT_MASK_SET(mask, API_DimensionType, nDimElem);
elem.dimension.nDimElem = dimCnt;
err = ACAPI_Element_Change(&elem, &mask, &memo, APIMemoMask_All, true);
Any idea where I go wrong?
~ReignBough~
ARCHICAD 26 INT (from AC18)
Windows 11 Pro, AMD Ryzen 7, 3.20GHz, 32.0GB RAM, 64-bit OS
1 REPLY 1
ReignBough
Enthusiast
UPDATE

Instead of creating dimensions then changing it, I just process the coordinates before creating the dimension. (As before, combining equal consecutive "computed" dimVal.)
Raw dimensions <-- dimension is not yet created
base.loc3D (0.00000000, 0.00000000, 0.00000000) pos3D (18.45889129, 30.99275442, 0.00000000) API_NoteContent_Measured 0.00000
base.loc3D (0.00000000, 0.00000000, 0.00000000) pos3D (20.12751369, 30.99275442, 12.00000000) API_NoteContent_Measured 0.00000
base.loc3D (0.00000000, 0.00000000, 0.00000000) pos3D (20.40751369, 30.99275442, 12.00000000) API_NoteContent_Measured 0.00000 --\ distance
base.loc3D (0.00000000, 0.00000000, 0.00000000) pos3D (20.68751369, 30.99275442, 12.00000000) API_NoteContent_Measured 0.00000   | from
base.loc3D (0.00000000, 0.00000000, 0.00000000) pos3D (20.96751369, 30.99275442, 12.00000000) API_NoteContent_Measured 0.00000   | previous
base.loc3D (0.00000000, 0.00000000, 0.00000000) pos3D (21.24751369, 30.99275442, 12.00000000) API_NoteContent_Measured 0.00000   | dimElem
base.loc3D (0.00000000, 0.00000000, 0.00000000) pos3D (21.52751369, 30.99275442, 12.00000000) API_NoteContent_Measured 0.00000   | is equal
base.loc3D (0.00000000, 0.00000000, 0.00000000) pos3D (21.80751369, 30.99275442, 12.00000000) API_NoteContent_Measured 0.00000   | to 280
base.loc3D (0.00000000, 0.00000000, 0.00000000) pos3D (22.08751369, 30.99275442, 12.00000000) API_NoteContent_Measured 0.00000   | (equidistant)
base.loc3D (0.00000000, 0.00000000, 0.00000000) pos3D (22.36751369, 30.99275442, 12.00000000) API_NoteContent_Measured 0.00000 --/
base.loc3D (0.00000000, 0.00000000, 0.00000000) pos3D (22.52751402, 29.79275442, 12.00000000) API_NoteContent_Measured 0.00000
base.loc3D (0.00000000, 0.00000000, 0.00000000) pos3D (23.72751369, 30.99275442, 12.00000000) API_NoteContent_Measured 0.00000

Filtered dimensions (newDimElems) <-- dimension is not yet created, this is the above after being processed
base.loc3D (0.00000000, 0.00000000, 0.00000000) pos3D (18.45889129, 30.99275442, 0.00000000) API_NoteContent_Measured 0.00000
base.loc3D (0.00000000, 0.00000000, 0.00000000) pos3D (20.12751369, 30.99275442, 12.00000000) API_NoteContent_Measured 0.00000
base.loc3D (0.00000000, 0.00000000, 0.00000000) pos3D (22.36751369, 30.99275442, 12.00000000) API_NoteContent_Custom <MeasuredValue> 8 EQ PARTS
base.loc3D (0.00000000, 0.00000000, 0.00000000) pos3D (22.52751402, 29.79275442, 12.00000000) API_NoteContent_Measured 0.00000
base.loc3D (0.00000000, 0.00000000, 0.00000000) pos3D (23.72751369, 30.99275442, 12.00000000) API_NoteContent_Measured 0.00000

Created dimensions
base.loc3D (23.72751369, 30.99275442, 0.00000000) pos3D (0.00000000, 0.00000000, 0.00000000) API_NoteContent_Measured 0.00000
base.loc3D (22.52751402, 29.79275442, 0.00000000) pos3D (0.00000000, 0.00000000, 0.00000000) API_NoteContent_Measured 1.20000
base.loc3D (22.36751369, 30.99275442, 0.00000000) pos3D (0.00000000, 0.00000000, 0.00000000) API_NoteContent_Custom 160 8 EQ PARTS
base.loc3D (20.12751369, 30.99275442, 0.00000000) pos3D (0.00000000, 0.00000000, 0.00000000) API_NoteContent_Measured 2.24000
base.loc3D (18.45889129, 30.99275442, 0.00000000) pos3D (0.00000000, 0.00000000, 0.00000000) API_NoteContent_Measured 1.66862

But the the generated dimension is not as expected.
~ReignBough~
ARCHICAD 26 INT (from AC18)
Windows 11 Pro, AMD Ryzen 7, 3.20GHz, 32.0GB RAM, 64-bit OS
Learn and get certified!