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.

[SOLVED] ACAPI_KeepInMemory problem

Anonymous
Not applicable
Hi

I have a dialog which inherits from DG::Palette class.

Here is my dialog's header class

class IssuesDialog : public DG::Palette, public DG::ButtonItemObserver, public DG::ListViewObserver	
{

private:
	DG::LeftText			m_textViewGuid;
	DG::LeftText			m_textViewId;
	DG::TextEdit			m_textEditTitle;
	DG::TextEdit			m_textEditDesc;
	DG::PopUp				m_cbStatus;
	DG::Button				m_btnFindObject;
	DG::Button				m_btnSaveData;
	DG::SingleSelListView	m_listIssues;
	DG::Button				m_btnClose;

public:
	IssuesDialog();
	~IssuesDialog();
	void setInstance(IssuesDialog *instance);
private:
	bool	validate();	
	void	fillListView();
protected:
	void	ButtonClicked (const DG::ButtonClickEvent& e);
	void	ListViewSelectionChanged ( const DG::ListViewSelectionEvent& ev);
private:
	IssuesDialog(const IssuesDialog&);
	const	IssuesDialog& operator=(const IssuesDialog&); //Disabled
private:
	IssuesDialog *current_dialog;
	IssueDataObject *issueDataObject;
	
};

And here is the code when I open the dialog from other .cpp file

IssuesDialog *issuesDialog = new IssuesDialog();
issuesDialog->setInstance(issuesDialog);
issuesDialog->Activate();
issuesDialog->BeginEventProcessing();
issuesDialog->BringToFront();
issuesDialog->Show();
ACAPI_KeepInMemory(true);
When I close the dialog I call the following code

SendCloseRequest();
this->current_dialog->EndEventProcessing();
delete this->current_dialog;
ACAPI_KeepInMemory(false);
Everything goes correct and dialod closes withouth any errors but when I want to change something in my add-on code and rebuild again I'm getting the following error

warning : Access to the path 'BuildingCloud.apx' is denied
error LNK1104: cannot open file 'BuildingCloud.apx'

I believe above error mean there is a something which not removed from memory.

By the way this error also appears in archicad add-on examples which provided in ApiDevKit Examples folder.

Is there a way to solve this issue ?

Thanks in advace.
6 REPLIES 6
Ralph Wessel
Mentor
ggiloyan wrote:
Everything goes correct and dialod closes withouth any errors but when I want to change something in my add-on code and rebuild again I'm getting the following error

warning : Access to the path 'BuildingCloud.apx' is denied
error LNK1104: cannot open file 'BuildingCloud.apx'
That's a build problem rather than a runtime error. Do you quit from ArchiCAD when you want to make changes and rebuild?
Ralph Wessel BArch
Anonymous
Not applicable
Ralph wrote:
ggiloyan wrote:
Everything goes correct and dialod closes withouth any errors but when I want to change something in my add-on code and rebuild again I'm getting the following error

warning : Access to the path 'BuildingCloud.apx' is denied
error LNK1104: cannot open file 'BuildingCloud.apx'
That's a build problem rather than a runtime error. Do you quit from ArchiCAD when you want to make changes and rebuild?
No I don't quit ArchiCad when I do rebuild. When I don't use ACAPI_KeepInMemory without closing ArchiCad rebuild works fine . So it's related with ACAPI_KeepInMemory. I think something is not removed from memory.
Ralph Wessel
Mentor
ggiloyan wrote:
No I don't quit ArchiCad when I do rebuild. When I don't use ACAPI_KeepInMemory without closing ArchiCad rebuild works fine . So it's related with ACAPI_KeepInMemory. I think something is not removed from memory.
Yes, you're right in saying that something is not removed from memory; it's the add-on itself. The documentation states that the following about ACAPI_KeepInMemory:
Instructs the host application to keep the add-on in the memory
But when you rebuild, you are effectively attempting to unload and reload the add-on. Those actions aren't compatible, and I wouldn't do it even if no errors were reported. I highly recommend always quitting from ArchiCAD whenever you want to rebuild.
Ralph Wessel BArch
Anonymous
Not applicable
Ralph wrote:
ggiloyan wrote:
No I don't quit ArchiCad when I do rebuild. When I don't use ACAPI_KeepInMemory without closing ArchiCad rebuild works fine . So it's related with ACAPI_KeepInMemory. I think something is not removed from memory.
Yes, you're right in saying that something is not removed from memory; it's the add-on itself. The documentation states that the following about ACAPI_KeepInMemory:
Instructs the host application to keep the add-on in the memory
But when you rebuild, you are effectively attempting to unload and reload the add-on. Those actions aren't compatible, and I wouldn't do it even if no errors were reported. I highly recommend always quitting from ArchiCAD whenever you want to rebuild.
Ok. But it's take time to close ArchiCad and open. We can pass false to ACAPI_KeepInMemory function but it doesn't work even in that case.
Ralph Wessel
Mentor
ggiloyan wrote:
Ok. But it's take time to close ArchiCad and open.
You have to accept some unique constraints for plugin development. It isn't the same as developing a stand-alone application.
Ralph Wessel BArch
Anonymous
Not applicable
Ralph wrote:
ggiloyan wrote:
Ok. But it's take time to close ArchiCad and open.
You have to accept some unique constraints for plugin development. It isn't the same as developing a stand-alone application.
Thanks for reply!
Learn and get certified!