cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

The 2025 Technology Preview Program is now live. Join today!

Archicad C++ API
About Archicad add-on development using the C++ API.

ACAPI_Window_GetGridSettings() gives 3D grid even if switched to floor plan DB

PetteriHeiskari
Booster

Hi all,

 

I need to use floor plan grid even if user has 3D window active. So I am using this scenario:

 

// To 2D

API_DatabaseInfo rDb;
GSErrCode err;

memset( &rDb, 0, sizeof(rDb) );
rDb.typeID = APIWind_FloorPlanID;
err = ACAPI_Database_ChangeCurrentDatabase(&rDb);    // err is 0

// Query the grid - still gives what is set in 3D window
API_GridType grid;

ACAPI_Window_GetGridSettings( &grid);

 

I have a customer report that this used to work in all earlier Archicads and in AC28 before update 5000.

 

Any tips how to get the floor plan grid? Or is this a bug to be fixed in AC29 and coming updates to AC28?

 

Thank you!

 

Petteri

6 REPLIES 6
Hiromichi Shinkawa
Graphisoft
Graphisoft

Hi, the grid setting depends on current window in current AC versions, so if you need to get floor plan grid values, you can try switch to floor plan using ACAPI_Window_ChangeWindow() at once and get it, then call again back to 3D window.

HTH.

PetteriHeiskari
Booster

Thank you Chen,

 

actually something like this is already used but after AC28/5000 it started to report the active window's grid:

 

API_DatabaseInfo rDb;
GSErrCode err;

memset( &rDb, 0, sizeof(rDb) );
rDb.typeID = APIWind_FloorPlanID;

err = ACAPI_Database_ChangeCurrentDatabase(&rDb);
assert( !err );

API_GridType m_grid;

ACAPI_Window_GetGridSettings( &m_grid ); // Still gives 3D grid
 
Petteri

Ah sorry, you meant ACAPI_Window_ChangeWindow(). That is something I would not like to do since it really puts the 2D window to front and may cause delay/updating problems afterwards. So any chance to get it work just by changing the active DB like earlier?

 

Petteri

Hi @PetteriHeiskari,

 

One (very rough) workaround idea would be to store the grid information whenever you are in the floorplan and then use the stored value when you are not in the floorplan. Not sure if it even works, because I'd have to first try to see if updating grid information even gives you some project event to listen to with the notification manager.

Maybe you can also hook into the change window notification, might be worth checking out if the grid returned is still the floorplan grid during the switch form 2D -> 3D windows.

 

Just a few ideas in case it may help.

Bernd

Automating Archicad with Add-Ons, GDL-Objects & Python Archi-XT.com

Thank you Bernd,

 

tried in the project event handler and the call fails with err code APIERR_BADDATABASE when switching to 3D-window:

 

case APINotify_ChangeWindow:
{
  CAcadGrid grid;
  grFrameSettings.AddMessageFormat(NULL, "grid x=%f", grid.m_grid.spaceMainX);
}

 

Then another workaround would be to use DG's PanelIdle-event and save the 2D grid there. However, it is unreliable. For example, if a pln-file is opened 3D window being active, the 2D grid cannot be retrieved at all before needing it.

 

Petteri

OK. Too bad that doesn't work....

I tried a bit myself and I even get an error when requesting the grid in a 3D window. When switching to the 2D database, then the grid request works. But then I get the 3D grid as you've also reported. (AC28 INT 5200).

Automating Archicad with Add-Ons, GDL-Objects & Python Archi-XT.com

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!