Hi all,
I'm using acedSetCurrentColors() to change AutoCADs background color like that:
DWORD rgb=RGB(255,255,255); AcColorSettings colors; acedGetCurrentColors(&colors); colors.dwGfxModelBkColor = rgb; colors.dwParallelBkColor = rgb; colors.dwGfxLayoutBkColor = rgb; BOOL bStat = acedSetCurrentColors(&colors);
This works well for the paperspace background and for the visual style "2D wireframe" (dwGfxModelBkColor).
But it fails for 3D visual styles like "realistic", "hidden" and so on (dwParallelBkColor).
If I call acedSetCurrentColors() before any 3D-viewport exists and than switch to "realistic" - than the "realistic" view will have "my" backgroundcolor.
But as soon as a 3D-viewport exists it just keeps its background-color.
If I look at the background color using the UI (preferences->Drawing->Colors->3D-parallel projection) the dialog shows "my" color! But it's not updated in the view.
Any ideas?
I want to create images with PNGOUT, JPGOUT or BMPOUT with a special background color (usually white).
Does anyone know a way to create PNG, JPG and BMP with "my" backgroundcolor just like the commands would do?
This would help me out as well.
I also tried:
Using COM - no success:
CWinApp *pApp = acedGetAcadWinApp(); IAcadApplication *pIAcad = (IAcadApplication*)pApp->GetIDispatch(TRUE); IAcadPreferences *pIAcadPreferences=NULL; pIAcad->get_Preferences(&pIAcadPreferences); IAcadPreferencesDisplay *pIAcadPreferencesDisplay=NULL; pIAcadPreferences->get_Display(&pIAcadPreferencesDisplay); OLE_COLOR oleColorNew = RGB(255,255,255); pIAcadPreferencesDisplay->put_GraphicsWinLayoutBackgrndColor(oleColorNew); pIAcadPreferencesDisplay->put_GraphicsWinModelBackgrndColor(oleColorNew);
Using some AcGs* stuff:
void update3dViewports(DWORD rgb) { AcAxDocLock myLock; AcGsManager *pGsManager = acgsGetGsManager(NULL); //Manager for current MDI window AcGsModel *pGsModel = pGsManager->getDBModel(); if (pGsModel) pGsModel->onPaletteModified(); struct resbuf *pRs=NULL, *r=NULL; AcGsView *pView=NULL; int nCVPort=0; bool bDevice=false; if (acedVports(&pRs) != RTNORM) return; for (r=pRs->rbnext; r; r=r->rbnext) { for (; r && r->restype!=RTSHORT; r=r->rbnext) ; if (!r) break; nCVPort = r->resval.rint; if (pView = acgsGetGsView(nCVPort, false)) { AcGsDevice *pDevice = pView->getDevice(); if (pDevice) { AcGsColor color; color.m_red = GetRValue(rgb); color.m_green = GetGValue(rgb); color.m_blue = GetBValue(rgb); bDevice = pDevice->setBackgroundColor(color); } pView->invalidate(); // mark the AcGsView as invalid so that it knows it has to update pView->update(); // update the view } } acutRelRb(pRs); }
Please help!
--Thomas
Thomas Brammer ● Software Developer ● imos AG ● LinkedIn ●
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.
Solved! Go to Solution.
Solved by moogalm. Go to Solution.
Hi ,
You need to call acedColorSettingsChanged to take changes effective , and sorry this is not an public API , I will request a wishlist with our Engineering to make this API public and provide neccessary documentation.
extern BOOL acedColorSettingsChanged(BOOL bUpdateView,
BOOL bUpdateParallelBg,
BOOL
bUpdatePerspectiveBg);
static void ASDkMyGroupBGColorTest(void) { // Add your code for command asdkArxProject.Test here AcColorSettings pColorSettings; acedGetCurrentColors(&pColorSettings); // Get the current colors pColorSettings.dwGfxModelBkColor=RGB(255,0,0);// Set the background to red pColorSettings.dwModelCrossHairColor=RGB(255,255,0);// set the cursor to yellow pColorSettings.dwParallelBkColor = RGB(255,0,0);// set the 3dParallel projection to red acedSetCurrentColors(&pColorSettings); acedColorSettingsChanged(false, true, true); // apply the changes. //... }