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.

Dimensions.

Anonymous
Not applicable
Can somebody please supply me with some sample code that displays how to add a dimension to the drawing. The sample projects don't show you how to do this and the finer points of the memo are elluding me.

If the sample could say create 2 lines then create a dimension between the 2 end points of the line it will be enough and i'll be on my way!!

Thanks in advance.
1 REPLY 1
Anonymous
Not applicable
I think the following code may be useful

bool InsertDimension(double dist, int numCoords, API_Coord *coords, API_Coord *ref)
{
API_Element element;
API_ElementMemo memo;
OSErr err;
Char hState;

memset(&element, 0, sizeof(API_Element));
memset(&memo, 0, sizeof(API_ElementMemo));
memo.dimElems = (API_DimElem **) BMAllocateHandle(sizeod(API_DimElem)* numCoords, ALLOCATE_CLEAR, nil);
element.header.typeID = API_DimensionID;
element.header.layer = 1;
element.header.floorInd = 0;
element.header.defStaticDim = false;
element.header.detailedHoleDim = false;
element.header.compCoreOnly = false;
element.header.nominalHoleDim = false;
element.header.ed_origin = APIDimOrigin_ProjectZero;
element.header.ed_dimForm = 1;
element.header.ed_arrowAng = 1;
element.header.dimAppear = APIApp_Normal;
element.header.defWitnessForm = API_Wtn_Small;
element.header.defWitnessVal = 0.0;
element.header.textWay = APIDir_Parallel;
element.header.textPos = APIPos_Above;
element.header.linPen = 1;
element.header.defNote.notePen = 2;
element.header.defNote.noteSize = 2.0;
element.header.defNote.noteAngle = PI / 2.0;
element.header.defNote.noteFont = FindFont(“Arial Narrow Western”);
element.header.markerData.markerPen = 1;
element.header.markerData.markerSize = 2.0;
element.header.markerData.markerType = APIMark_SlashLine45;
element.header.nDimElem = numCoords;
element.header.direction.x = 1.0;
element.header.direction.y = 0.0;
element.header.refC.x = ref->x;
element.header.refC.y = ref->y + dest;

hState = BMModifyHandleState((GSHandle) memo.dimElems, HANDLE_STATE_LOCK, 0);
for(int i = 0; i < numCoords; i++)
{
(*memo.dimElems).base.loc = coords;
(*memo.dimElems).fixedPos = true;
}

BMModifyHandleState((GSHandle) memo.dimElems. HANDLE_STATE_SET, hState);

err = ACAPI_Element_Create(&element, &memo);
if(err!=noErr)
{
ACAPI_DISPOSEElemMemoHdls(&memo);
return false;
}
ACAPI_DISPOSEElemMemoHdls(&memo);
dist += 0.35;
return true;
}
Learn and get certified!