setVisualStyle make no effect

setVisualStyle make no effect

Anonymous
Not applicable
1,550 Views
11 Replies
Message 1 of 12

setVisualStyle make no effect

Anonymous
Not applicable

hi, community,

I want to set "Conceptual" visual style to one viewpot, but it makes no effect.

On Autocad, I find that the label on viewport change to "Conceptual", but the entities make no change, still the default style "2D wireframe".

here is my code:

void AdjustViewport(const CString& strLayout, int nIndex, const std::vector<AcDbObjectId>& vecEnt, const AcGePoint3d& modelCenter)
{
	AcDbViewport* pViewport = GetViewport(strLayout, nIndex);

	if (pViewport == nullptr)
	{
		ASSERT(pViewport != nullptr);
		return;
	}

	int nRetActiveLayout = acedCommand(RTSTR, _T("layout"), RTSTR, _T(""), RTSTR, _T("testCopy"), 0);
	ASSERT(nRetActiveLayout == RTNORM);

	acedMspace();

	Acad::ErrorStatus es = acedSetCurrentVPort(pViewport);
	ASSERT(es == Acad::eOk);

	int nSetSWISO = acedCommand(RTSTR, _T("-view"), RTSTR, _T("_swiso"), 0);
	ASSERT(nSetSWISO == RTNORM);

	ads_name ssname;
	acedSSAdd( NULL, NULL, ssname );
	GroupSelect(vecEnt, ssname);
	acedSSSetFirst( ssname, NULL );
	int nZOOM = acedCommand(
		RTSTR, _T("_ZOOM"),
		RTSTR, _T("_OBJECT"),
		RTPICKS, ssname, 
		RTSTR, _T(""),
		RTNONE);
	ASSERT(nZOOM == RTNORM);
	acedSSFree(ssname);
	acedSSSetFirst( NULL, NULL );

	AcDbObjectId vsId = AcDbObjectId::kNull;
	AcDbDictionaryPointer pNOD(acdbHostApplicationServices()->workingDatabase()->visualStyleDictionaryId(), AcDb::kForRead);
	pNOD->getAt(ACRX_T("Conceptual"), vsId);

	Acad::ErrorStatus esSetVS = pViewport->setVisualStyle(vsId);
	ASSERT(esSetVS == Acad::eOk);

	//SetVisualStyle(vecEnt);

	pViewport->updateDisplay();

	pNOD->close();
	pViewport->close();
}

pls help, thx!

0 Likes
1,551 Views
11 Replies
Replies (11)
Message 2 of 12

tbrammer
Advisor
Advisor

Please try to call   pNOD->close();
before            pViewport->setVisualStyle(vsId);


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

0 Likes
Message 3 of 12

Anonymous
Not applicable

hi, tbrammer

I try your suggestion, but it still not work.

Anyway, I set visual style directly in my template dwg file.

 

thx,

nolan

0 Likes
Message 4 of 12

tbrammer
Advisor
Advisor

I try your suggestion, but it still not work.

Do you mean that the viewport doesn't show up with the new visual style?

Maybe some graphics refresh is required.

 

You could try  ads_regen() and/or

 

AcTransactionManager *pAcTransactionManager=actrTransactionManager;
if (pAcTransactionManager)
{
   pAcTransactionManager->queueForGraphicsFlush();
   pAcTransactionManager->flushGraphics();
}
acedUpdateDisplay();

Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

0 Likes
Message 5 of 12

Anonymous
Not applicable

I don't know whether is vs2010 can't find  ads_regen(), so I can't try this.

And I try actrTransactionManager, but it alse makes no effect, somewhat disappointed.

but, thanks all the same.

 

0 Likes
Message 6 of 12

Alexander.Rivilis
Mentor
Mentor

You can use ads_regen in all AutoCAD versions since 2000.

With AutoCAD 2014 you have to add next definition (as far as this function is not documented and is not defined in any of .h-files):

 

void ads_regen(void);

Also you have to link with accore.lib

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

0 Likes
Message 7 of 12

tbrammer
Advisor
Advisor

@Alexander.Rivilis: Could you suggest the ARX Dev team to add ads_regen() to the ARX headers and docs? Or are there any reasons to "hide" this quite important function?


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

0 Likes
Message 8 of 12

Alexander.Rivilis
Mentor
Mentor

@tbrammer wrote:

@Alexander.Rivilis: Could you suggest the ARX Dev team to add ads_regen() to the ARX headers and docs? Or are there any reasons to "hide" this quite important function?


Dear @artc2 !

I hope you can explain why ads_regen is not documented and not added in any of .h-file within ObjectARX SDK since AutoCAD 2000.

Please!

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 9 of 12

tbrammer
Advisor
Advisor

The same topic is dicussed here.

Here 's the solution I just found and postet there:

 

If you switch from "2D wireframe" to a 3D visual style, an AcGsView needs to be created. This code works for AutoCAD 2018:

 

//Need AcDrawBridge.lib for AcGsKernelDescriptor::k3DDrawing
#pragma comment(lib, "AcDrawBridge.lib")

void SetVisualStyle(AcDbObjectId idVP) { Acad::ErrorStatus es; AcDbObjectId vsId = AcDbObjectId::kNull; AcDbDictionaryPointer pNOD(acdbHostApplicationServices()->workingDatabase()->visualStyleDictionaryId(), AcDb::kForRead); pNOD->getAt(ACRX_T("Conceptual"), vsId); int vpNum = -1; AcDbViewport *pViewport; if ((es = acdbOpenObject(pViewport, idVP, AcDb::kForWrite)) == Acad::eOk) { vpNum = pViewport->number(); pViewport->setVisualStyle(vsId); pViewport->close(); } AcGsView *pView = acgsGetCurrent3dAcGsView(vpNum); if (!pView) { AcGsKernelDescriptor gsKernel; gsKernel.addSupport(AcGsKernelDescriptor::k3DDrawing); pView = acgsObtainAcGsView(vpNum, gsKernel); // create if necessary. } if (pView) pView->show(); void ads_regen(); ads_regen(); }

Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

0 Likes
Message 10 of 12

artc2
Autodesk
Autodesk
It's not documented nor in any public header file because it was never intended for anything other than very specific purposes in AutoCAD internal code and has not been tested for general use.
Message 11 of 12

Alexander.Rivilis
Mentor
Mentor

@artc2 wrote:
It's not documented nor in any public header file because it was never intended for anything other than very specific purposes in AutoCAD internal code and has not been tested for general use.

Thank for explanation! So this function internal is very different with _REGEN command? I've used this function many years instead of _REGEN in order to prevent using command methods.

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

0 Likes
Message 12 of 12

artc2
Autodesk
Autodesk
No, ads_regen() and the REGEN command are fairly similar, but they are not exactly the same. The primary difference is that the code path for the REGEN command will only work in a command context whereas ads_regen() does not have that requirement.