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 Module DATA Manager

Anonymous
Not applicable
Hello,

I need help to use API developper kit. I use Visual Studio (on Windows).

My goal :

I aim to write a plugin for archicad 12 which load an external Hotlinked Module and paste it on the scene, like if in Archicad we do : file -> External content -> Place hotlinked Module -> choose Hotlink (module file and select "open in single story mode") and place Module.


My researches :

I found the Module Data Manager module, I think that's what I need to use but I'm not sure.
they speak about an exemple but it's not in the exemple folder of API v12.
I found this exemple in the examples pack for archicad 7 but the API is very old and too many things have changed to build it.



So, if somebody could help me please i really need help because it's difficult to understand how to use this module.

Than you and sorry for my english, i do my best .
10 REPLIES 10
Ralph Wessel
Mentor
atila-diffusion wrote:
I aim to write a plugin for archicad 12 which load an external Hotlinked Module and paste it on the scene, [...] I found the Module Data Manager module, I think that's what I need to use but I'm not sure. they speak about an exemple but it's not in the exemple folder of API v12. I found this exemple in the examples pack for archicad 7 but the API is very old and too many things have changed to build it.
I think you have been looking at the ModulData Manager, which allows an add-on to store and retrieve data in the project file, e.g. user preferences. These functions don't have any direct relevance to the problem.

I haven't attempted to place hotlinks in a project, so I can't definitively say that it will work, but I recommend you look at the following subjects in the Devkit documentation:
  • - API_HotlinkTypeID
    - API_HotlinkStoryRangeID
    - API_HotlinkUserData
    - API_HotlinkNode
Ralph Wessel BArch
Anonymous
Not applicable
thank you,

you're right this subjects seems to be what I'm looking for.
So, I have to fill the API_HotlinkNode structure with the 3 others and other parameters.
But once the structure is filled, will the modul be pasted automatically to the scene?

Thank you very much for your help.
Ralph Wessel
Mentor
atila-diffusion wrote:
So, I have to fill the API_HotlinkNode structure with the 3 others and other parameters. But once the structure is filled, will the modul be pasted automatically to the scene?
Sorry, I don't know the answer that. These functions are new with AC12 and I haven't had any need for them yet. Experiment a bit and let us know what you find. Someone like Akos could probably tell you more.
Ralph Wessel BArch
Anonymous
Not applicable
Hello,

i continued to search for my issues and I found something which seems to be good :

- I fill this structure : API_HotlinkNode
(even if I do not succeed to fill many of parameters) :
BNZeroMemory (&myAPI_HotlinkNode, sizeof (myAPI_HotlinkNode));

	//fill API_HotlinkUserData structure
	myAPI_HotlinkNode.userData.dataVersion=1;
	myAPI_HotlinkNode.userData.platformSign= GS::Act_Platform_Sign;

	//define single story mode
	myAPI_HotlinkNode.storyRangeType = APIHotlink_SingleStory;
	//define file type
	myAPI_HotlinkNode.type = APIHotlink_Module;
	//define file to load
	myAPI_HotlinkNode.sourceLocation = &location;

	//define update date
	myUpdateDate.year = 2008;
	myUpdateDate.month = 12;
	myUpdateDate.dayOfWeek = 4;
	myUpdateDate.day = 4;
	myUpdateDate.hour = 10;
	myUpdateDate.minute = 0;
	myUpdateDate.second = 0;
	myUpdateDate.milliSecond = 0;
	
	err = TIGetGSTime(&myUpdateDate,&myAPI_HotlinkNode.updateTime,TI_UTC_TIME);
	
	if (err != NoError) {
			sprintf_s (msgStr,sizeof(msgStr), "TIGetGSTime: %d ",(int) err);
					ACAPI_WriteReport (msgStr, true);
			return err;
		}

	//other parameters
	myAPI_HotlinkNode.refFloorInd = ind;
-use this fonction :
ACAPI_Database (APIDb_CreateHotlinkNodeID,&myAPI_HotlinkNode,NULL,NULL);
and i use this one :
ACAPI_Database (APIDb_CreateHotlinkNodeID,&myAPI_HotlinkNode,NULL,NULL);
I think that's the good way, but the last one creates a "APIERR_GENERAL" error code, i think that's because I do not succeed to fill many parameters in the sturcture.

If someone know where is my error, that would be the biggest Christmas present oh this year
Ralph Wessel
Mentor
atila-diffusion wrote:
i continued to search for my issues and I found something which seems to be good :
- I fill this structure : API_HotlinkNode
(even if I do not succeed to fill many of parameters) :
and i use this one :
ACAPI_Database (APIDb_CreateHotlinkNodeID,&myAPI_HotlinkNode,NULL,NULL);
I think that's the good way, but the last one creates a "APIERR_GENERAL" error code, i think that's because I do not succeed to fill many parameters in the sturcture.
Have you tried enclosing your code between ACAPI_OpenUndoableSession and ACAPI_CloseUndoableSession? Some functions return that error if you haven't started an Undo session.
Ralph Wessel BArch
Anonymous
Not applicable
Hello,

yes, i already enclosed my code between these functions.
I think this error comes from the fact i did not fill these three parameters in the structure:

GS::uchar_t name [API_UniLongNameLen];
GS::uchar_t refFloorName [API_UniLongNameLen];
GSType ownerId;

because I don't understand what are GS::uchar_t and GSType, so these parameters are important.

I tried this :
res = CHANSI2Unicode ("Module1", GS::CStringLen, myAPI_HotlinkNode.name,API_UniLongNameLen, CC_Default, NULL);       
	res = CHANSI2Unicode ("1", GS::CStringLen, myAPI_HotlinkNode.refFloorName,API_UniLongNameLen, CC_Default, NULL);   

	myAPI_HotlinkNode.ownerId = 1295081318;
But i'm not sure at all.
Ralph Wessel
Mentor
atila-diffusion wrote:
yes, i already enclosed my code between these functions. I think this error comes from the fact i did not fill these three parameters in the structure: etc
I haven't made any use of these functions yet, and the documentation is a bit thin. I think the best option is to PM Akos Somorjai - he is the API guru at GS, and has answered more than a few awkward questions for me.
Ralph Wessel BArch
Anonymous
Not applicable
Ok,

i send him a PM, i'm waiting for his aswer.
I continue to search and I'll let you know what i find.


thank you
Anonymous
Not applicable
hello,

I succeeded to solve my error, i just had to do this :
myAPI_HotlinkNode.refFloorInd = -2;
instead of this
myAPI_HotlinkNode.refFloorInd = 1;

Now my module is saved in archicad, i now have to place it.

i will succeed , i don't lose hope.
Learn and get certified!