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

get orientation from active Raster Image

10 REPLIES 10
Reply
Message 1 of 11
con-pnd
750 Views, 10 Replies

get orientation from active Raster Image

Dear ObjectArx Programmers,

 

It's me again and this time would ask you, why my function getRasterImageInfo is failing getting the Orientation from my active Raster Image (After pRastImg->getOrientation(origin, u, v) all values are still empty).

I also found some intressting top on the Autodesk Dev Blog (http://adndevblog.typepad.com/autocad/2012/05/finding-all-the-visible-raster-images-in-the-drawing.h... but can't do it like this.
One of the problems: Where are datatype Document,Database and Editor coming from? Could i use AcApDocument and AcDbDatabase instead? Thx a lot guys!

 

void getRasterImageInfo(AcGePoint3d& origin, AcGeVector3d& u, AcGeVector3d& v)
{
  AcDbBlockTable *pBT = NULL;
  AcDbBlockTableRecord *pBTR =NULL;
  AcDbBlockTableRecordIterator *pBTIter;
  Acad:: ErrorStatus es;

  AcApDocument *pDoc=acDocManager->curDocument(); // Lock Document
  acDocManager->lockDocument(pDoc,AcAp::kWrite);

  //acdbHostApplicationServices()->workingDatabase()->getBlockTable(pBT,AcDb::kForRead);
  AcDbDatabase* pDB = acdbHostApplicationServices()->workingDatabase();
  es = pDB->getSymbolTable(pBT, AcDb::kForRead);
  pBT->getAt(ACDB_MODEL_SPACE,pBTR,AcDb::kForRead);
  pBTR->newIterator(pBTIter);
  pBT->close();
  pBTR->close();

  AcDbEntity *pEnt;

  AcDbRasterImage *pRastImg;
  bool rasterFound = false;

  while (!(pBTIter->done()))
  {
    pBTIter->getEntity(pEnt,AcDb::kForRead);
    pRastImg = AcDbRasterImage::cast(pEnt);

    if(NULL != pRastImg)
    {
      rasterFound = true;
    
      AcGeVector3d u;
      AcGeVector3d v;
      pRastImg->getOrientation(origin, u, v);

    }
    pEnt->close();
    pBTIter->step();
  }
  delete pBTIter;
  acDocManager->unlockDocument(pDoc); // Unlock Document
}

 

Greetings

 

10 REPLIES 10
Message 2 of 11
owenwengerd
in reply to: con-pnd

You don't say what the return value is from pRastImg->getOrientation(). That should be the first clue as to the reason for the failure.

 

It sounds like the blog post you refer to is demonstrating .NET (managed) code, probably in the C# language.

--
Owen Wengerd
ManuSoft
Message 3 of 11
con-pnd
in reply to: owenwengerd

Hi,

 

getOrientation should return 1 origin AcGePoint3d and 2 AcGeVector3ds  (u & v) see:

http://docs.autodesk.com/ACDMAC/2011/ENU/ObjectARX%20Reference/index.html?frmname=topic&frmfile=AcDb...

It will give me all placement information of that Raster Image.

 

Yes, that Blogpost is C# but what's the equivalent? For example i dont have any clue which "editor" class to use.

 

Thx!

 

Message 4 of 11
owenwengerd
in reply to: con-pnd

I meant the error return value of getOrientation(), but I just checked and it is a void return, so no error code is returned. In C#, the Editor class wraps AcEditor. Document wraps AcApDocument, Database wraps AcDbDatabase, etc., but there is no direct translation from C# to C++.

--
Owen Wengerd
ManuSoft
Message 5 of 11
con-pnd
in reply to: owenwengerd

Hi,

 

i was hoping to find an similar solution for my c++ Code..

But to my code again:

 

My code is not running into the line:while (!(pBTIter->done()))


For your information, this code is a few years old and programmed by an other programmer.

Trying to use

 

  pBTIter->getEntity(pEnt,AcDb::kForRead);
  pRastImg = AcDbRasterImage::cast(pEnt);

 

is not possible, bacause   pBTIter->getEntity(pEnt,AcDb::kForRead); won't work and would give an exception.


How would you guys manage to get the active Raster Image?

Thanks a lot!

 

Message 6 of 11
owenwengerd
in reply to: con-pnd

There is no such thing as "active" raster image. It sounds like you have not done any basic debugging of your code and don't really know where it fails. You should start by checking the return values of every function call and determining where the results are first different than expected.

--
Owen Wengerd
ManuSoft
Message 7 of 11
con-pnd
in reply to: owenwengerd

Hi, after some vacation i tried to fix that problem by checking the return values of every function call, like you said.


Everything went well and returned Acad:: eOk so far.
But he wont go in that iteration:

while (!(pBTIter->done())) because the Iterator is already "done()" from begining.

In my active Workspace there is one Raster Image.

 

I just need that orientation vector informations, but i dont know how to do this.

 

Hope you can help or at least give me an alternative way to do this.

Thanks a lot!


 

Message 8 of 11
owenwengerd
in reply to: con-pnd

I think the most likely explanation is that you are confused about which space your image is in; or possibly you are mistaken about which database is the active document when this code executes.

--
Owen Wengerd
ManuSoft
Message 9 of 11
con-pnd
in reply to: owenwengerd


@owenwengerd wrote:

I think the most likely explanation is that you are confused about which space your image is in; or possibly you are mistaken about which database is the active document when this code executes.


Hi,

 

first thank you for answering me that quick.

Just attached a picture, where you can see that 1 AcDbRasterImag is in that active dwg.

I just couldn't figure out some other way to get these orientations datas.

Most of the examples i found get Informations over workingDatabase, getBlockTable and an Iterator.

There must be some changes in API, which broke that way or i am missing something important.

I would be so thankful to have a solution for this problem.

 

Greetings

 

 

Message 10 of 11
owenwengerd
in reply to: con-pnd

I'm not familiar with Raster Design. I doubt that it uses AcDbRasterImage.

--
Owen Wengerd
ManuSoft
Message 11 of 11
con-pnd
in reply to: owenwengerd

Normally it should be the same way, as if you would read orientations from a line or something.

And it must be AcDbRasterImage, because I have created that Raster Image before. 

But in this second fuction I dont have that Image ID, so I have to read its information another way.

Thanks for your efforts anyways.

Greetings

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

Post to forums  

Autodesk Design & Make Report

”Boost