ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

AcGsView::getSnapShot with off screen device issue

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
loic.jourdan
1614 Views, 2 Replies

AcGsView::getSnapShot with off screen device issue

Hi all,

I try to implement a "per-entity" png creation feature using AcGsView::getSnapShot.

 

This feature is inteded to create image files from one or several entities without changing the current autocad view. To achieve this, I've used some code found on ADN (from Fenton Webb) which created a snapshot of the current view. I've modified this code to create a view (instead of using the current one) and an off-screen device (this to setup correct camera position and target to match my needs on the created view).

 

It seems that in this case, AcGsView::getSnapShot doesn't work (black image is created).

 

I've attached a sample project that reproduce the issue (please do not pay too much attention to the coding style since it has been hugely modified for test purpose), here are some remarks on this project:

  • targets Acad 2014 (VS 2012 project)
  • the project only builds in debug/x64
  • object arx search paths have to be changed in project properties
  • the main command is called "SNAPSHOT" and requires to select some entities
  • the view position and target are hard-coded for test purpose, however, a big-enough solid drawn @(0,0,0) should appear in the snapshot
  • the interesting code is in ent_snapshot.cpp -> ent_snapshot::snapshot_to_file
  • Note that when using AcGsView::RenderToImage on the same view, it works correctly (but I would need wireframe snapshots as well)
  • as a brief summary the code process the following:

      1 - Create an AcGsModel (AcGsClassFactory::createAutoCADModel), an AcGsView (AcGsClassFactory::createView) and an off screen AcGsDevice (AcGsClassFactory::createOffScreenDevice)

      2 - setting some device properties (palette, bk color, renderer type)

      3 - setting view properties (AcGsView::setView) - with hard coded values

      4 - adding the view to the device

      5 - adding entities to the view 

      6 - building atil image

      7 - processing snapshot

      8 - freeing all the stuff

 

 

Thank you for your help

 

loic

----
20-20 CAD / 20-20 Technologies
2 REPLIES 2
Message 2 of 3
Balaji_Ram
in reply to: loic.jourdan

Hi Loic,

 

Sorry for the delay.

 

I have attached a C++ and a .Net sample project that demonstrates creating a snapshot from selected entities.

Some of the helper methods in those samples are from the BlockView sample from the 2009 SDK.

 

Hope this helps.

 

Regards,

Balaji



Balaji
Developer Technical Services
Autodesk Developer Network

Message 3 of 3
loic.jourdan
in reply to: Balaji_Ram

Hi Balaji,

Thank you very much for this update. It works well.

 

I would however remark that it's not required to build an annonymous block (cloning entities into it), adding entities to the created AcGsView works as well.

 

Thanks a lot

 

loic

----
20-20 CAD / 20-20 Technologies

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost