The Global ARCHICAD Community

Stay informed. Get help. Share your knowledge.

Discussions about using GRAPHISOFT's tools (API DevKit) for independent software developers

Moderators: Karl Ottenstein, LaszloNagy, ejrolon, Barry Kelly, gkmethy, MOREH Tamas, Akos Somorjai, Ed Brown, Mihály Palenik, Tibor Lorántfy

User avatar
By kzaremba
#287836
I have some troubles with overwriting data. I assumed that the easiest way would be to delete user data and set a new one. Here is my attempt. But as always the easiest way doesn't work at all. As pointed in docs I used nullptr to delete data. I assume that some treatment od memorychannel is necessary, but all my attempts just crashed AC. Please help.
Code: Select all GS::ErrCode MyUserData::DelToAttrib(const API_Attribute& attrib) const { API_AttributeUserData userData = {}; userData.dataHdl = nullptr; API_Attr_Head attHead = {}; attHead.index = attrib.header.index; attHead.typeID = attrib.header.typeID; GSErrCode err = ACAPI_Attribute_SetUserData(&attHead, &userData); BMKillHandle(&userData.dataHdl); return err; }
User avatar
By Tibor Lorántfy
#288630
Do you think there is a possibility to start GitRepository (or similar solution) to create the library of classes working with actual API (like the example above)? So if someone is interested in developing such an approach could collaborate and build upon some examples like this? This might be an even better way to share this knowledge than the forum where some topics are covered by the others.
Yes, it's possible, but could be very hard to maintain.
There should be an attached continous integration system which builds the code after anybody pushed some modification to make sure it builds successfully and it runs tests to make sure it still works correctly.
Without this system I think that repository can be a big mess after few years (or it would take too many effort for somebody to maintain).
User avatar
By kzaremba
#288633
Ok. I thought its easier since you have version control and branching. Anyway, I understand that there are no plans for reorganizing API?
I did some prototypes of polymorphic classes based on API and it seems much easier to build up commands and much less code to maintain.
User avatar
By Tibor Lorántfy
#288636
I have some troubles with overwriting data. I assumed that the easiest way would be to delete user data and set a new one.
You don't have to delete the userdata, because if you call ACAPI_Attribute_SetUserData to the attribute for the second time then it will automatically overwrite the existing userdata.
I assume that some treatment od memorychannel is necessary, but all my attempts just crashed AC. Please help.
Code: Select all... userData.dataHdl = nullptr; ... BMKillHandle(&userData.dataHdl); ...
Your code is ok, except the BMKillHandle call, I think that line caused the crash, because the userData.dataHdl is nullptr there.