License Delivery maintenance is expected to occur on Saturday, November 30, between 8 AM and 11 AM CET. This may cause a short 3-hours outage in which license-related tasks: license key upload, download, update, SSA validation, access to the license pool and Graphisoft ID authentication may not function properly. We apologize for any inconvenience.
Archicad C++ API
About Archicad add-on development using the C++ API.

API : HotlinkNode Element and database

Anonymous
Not applicable
Hello,

i'm trying since last month to write a plugin which load an external Hotlinked Module and place it on the project.

I'm near the end , i'v loaded the module, assigned it to an element but i don't succeed to place it on the project.

Here is my little fonction :
API_HotlinkNode myAPI_HotlinkNode;
	GSErrCode err;
	IO::Location  location("c:\\test.MOD");
	API_Guid myAPI_HotlinkNodeGuid;
	API_Element element;
	API_ElementMemo memo;

/***************************************************************************************************/
/******************************REMPLISSAGE DE LA STRUCTURE******************************************/
/***************************************************************************************************/
	BNZeroMemory (&myAPI_HotlinkNode, sizeof (API_HotlinkNode));

	//Charge le module en mode unique (define single story mode)
	myAPI_HotlinkNode.storyRangeType = APIHotlink_SingleStory;
	//Precise les que les extensions possibles sont :.pln, .mod, .plp or .2dl file. (define file type)
	myAPI_HotlinkNode.type = APIHotlink_Module;
	//Définie le fichier à charger (define file to load)
	myAPI_HotlinkNode.sourceLocation = &location;
	//definie l'étage comme étant l'étage -2
	myAPI_HotlinkNode.refFloorInd = -2;

	CHANSI2Unicode ("Module 1", GS::CStringLen, myAPI_HotlinkNode.name,API_UniLongNameLen, CC_Default, NULL);      

/***************************************************************************************************/
/******************************FIN REMPLISSAGE DE LA STRUCTURE**************************************/
/***************************************************************************************************/

/********************CREATION DU GUID*************************************/
	err = ACAPI_Database (APIDb_CreateHotlinkNodeID,&myAPI_HotlinkNode,NULL,NULL);
	if (err != NoError) {
			afficheMessage("HotlinkNode parameter is NULL or sourceLocation is NULL or invalid",err);
			return err;
		}
/*************************************************************************/
	myAPI_HotlinkNodeGuid = myAPI_HotlinkNode.guid;


/********************MISE A JOUR DU CACHE*********************************/
	err = ACAPI_Database (APIDb_UpdateHotlinkCacheID,&myAPI_HotlinkNodeGuid,NULL,NULL);
	
	if (err != NoError) {
			switch(err)
			{
			case APIERR_BADPARS:
								afficheMessage("hotlinkNodeGuid parameter is NULL",err);
								break;
			case APIERR_BADID:
								afficheMessage("hotlinkNodeGuid is invalid",err);
								break;
			default:
					afficheMessage("APIDb_UpdateHotlinkCacheID",err);
					break;
				
			}
			return err;
		}
/*************************************************************************/
/******************PLACE LE MODULE LIE DANS LA DATABASE*******************/

err = ACAPI_OpenUndoableSession ("Place le module");
if (err == NoError) 
{
	BNZeroMemory (&element, sizeof (API_Element));		
	element.header.typeID = API_HotlinkID ;
	element.header.index = 1;
	err = ACAPI_Element_GetDefaults (&element, &memo);
	if (err == NoError) 
	{
		element.hotlink.type = APIHotlink_Module;
		element.hotlink.hotlinkNodeGuid = myAPI_HotlinkNodeGuid;
		err = ACAPI_Element_Create(&element, &memo);
		if (err != NoError)
		{
			switch(err)
			{
				case APIERR_BADPARS:
									afficheMessage("The passed parameter is NULL; element",err);
									break;
				case APIERR_BADID:
									afficheMessage("The element type is invalid, or the element type is not supported by the server application",err);
									break;
				case APIERR_BADDATABASE:
									afficheMessage("The current database is not proper for the operation",err);
									break;
				case APIERR_REFUSEDPAR:
									afficheMessage("The element->header.typeID parameter was incorrect. It might happen if you want to create something in a window not capable to display it, for example a wall in a section window. ",err);
									break;
				case APIERR_NOTMINE:
									afficheMessage("The element was attempted to be created on a layer owned by someone else. Most likely to occur when working on documents in teamwork mode. ",err);
									break;
				case APIERR_LOCKEDLAY:
									afficheMessage("The element attempted to be created was on a locked layer",err);
									break;
				case APIERR_HIDDENLAY:
									afficheMessage("The element attempted to be created was on a hidden layer.",err);
									break;
				case APIERR_INVALFLOOR:
									afficheMessage("The element->header.floorInd parameter is out of range.",err);
									break;
				case APIERR_REFUSEDCMD:
									afficheMessage("The passed identifier is not subject to the operation.",err);
									break;
				default:
						afficheMessage("ACAPI_Element_Create",err);
						break;
			}
			return err;
		}
		err = ACAPI_Database (APIDb_RedrawCurrentDatabaseID,NULL,NULL,NULL);
		if (err != NoError)
			afficheMessage("APIDb_RedrawCurrentDatabaseID",err);
		ACAPI_DisposeElemMemoHdls (&memo);
	}
	else
		afficheMessage("ACAPI_Element_GetDefaults",err);
	
	ACAPI_CloseUndoableSession();
}
else
	afficheMessage("ACAPI_OpenUndoableSession",err);

if someone would know the thing i forgot to do, thank you in advance for your help.
8 REPLIES 8
Ralph Wessel
Mentor
atila-diffusion wrote:
Hello,
i'm trying since last month to write a plugin which load an external Hotlinked Module and place it on the project.
I'm near the end , i'v loaded the module, assigned it to an element but i don't succeed to place it on the project.
Is an error returned at any point in this function? If so, where, and which error code?
Ralph Wessel BArch
Software Engineer Speckle Systems
Anonymous
Not applicable
Hello,

not any error is returned, that's why I really don't know what is missing.
Ralph Wessel
Mentor
atila-diffusion wrote:
not any error is returned, that's why I really don't know what is missing.
Check the easy things first - have you checked the storey (floor) and layer applied? And what does the transformation matrix contain?
Ralph Wessel BArch
Software Engineer Speckle Systems
Anonymous
Not applicable
I allready checked the floor, but i do not filled the transformation matrix, I thought it was not needed.

Do I have to fill it like this :
element.hotlink.transformation.tmx[3] = 10;
			element.hotlink.transformation.tmx[7] = 4;
			double	co = cos (0.52359877556);
			double	si = sin (0.52359877556);
			element.hotlink.transformation.tmx[0] = element.hotlink.transformation.tmx[5] = co;
			element.hotlink.transformation.tmx[1] = -si;
			element.hotlink.transformation.tmx[4] = si;
about the layer is it this :
element.header.layer = 1;
Anonymous
Not applicable
THANK YOU VERY MUCH .

It works thanks to you, had to fill the layer.

I thank you very much.
Anonymous
Not applicable
Do you know if we have to ask for a validation to graphisoft before to sell a plugin, or to do something else?
Ralph Wessel
Mentor
atila-diffusion wrote:
Do you know if we have to ask for a validation to graphisoft before to sell a plugin, or to do something else?
Yes, you need a developer ID from Graphisoft to enable the add-on to work with the commercial version of ArchiCAD. Take a look at the information here: http://www.graphisoft.com/support/developer/policy/index.html
Ralph Wessel BArch
Software Engineer Speckle Systems
Anonymous
Not applicable
Ok thank you I already asked for an ID. i'm waiting for it.

Thank you for all