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.

API_Coord to API_Transmat

kristkun
Participant

Hi

Anyone has an idea how can i place/create a hotlink element based on 2D API_Coord (x and y positions)?
I did some testing and for an Object Element, the position is referenced to the Project Origin (If my understanding is correct)
Red = Project Origin
Green = User Origin
Where Obj pos.x = ~0.0 and pos.y = ~0.0

kristkun_0-1711655567876.jpeg

But when I created a hotlink element with x=0, y=0, z=0 coordinates it was placed here

kristkun_1-1711655619720.jpeg

Im using this code from the example references to convert 3d coordinates to API_Transmat

 

static API_Tranmat CreateTransformation(const API_Coord3D& origin, const double rotAngle)
{
	API_Tranmat transformation = {};

	const double	co = cos(rotAngle);
	const double	si = sin(rotAngle);
	// we need an orthogonal transformation
	// origin
	transformation.tmx[3] = origin.x;
	transformation.tmx[7] = origin.y;
	transformation.tmx[11] = origin.z;
	// X axis
	transformation.tmx[0] = co;
	transformation.tmx[4] = si;
	transformation.tmx[8] = 0.0;
	// Y axis
	transformation.tmx[1] = -si;
	transformation.tmx[5] = co;
	transformation.tmx[9] = 0.0;
	// we need a valid Z axis as well
	transformation.tmx[2] = 0.0;
	transformation.tmx[6] = 0.0;
	transformation.tmx[10] = 1.0;

	return transformation;
}

 

0 REPLIES 0
Learn and get certified!