ObjectARX

Reply
Active Member
con-pnd
Posts: 8
Registered: ‎08-01-2012
Message 1 of 11 (291 Views)

get orientation from active Raster Image

291 Views, 10 Replies
08-09-2012 06:02 AM

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

 

Distinguished Mentor
owenwengerd
Posts: 607
Registered: ‎08-06-2002
Message 2 of 11 (287 Views)

Re: get orientation from active Raster Image

08-09-2012 07:29 AM 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
Active Member
con-pnd
Posts: 8
Registered: ‎08-01-2012
Message 3 of 11 (285 Views)

Re: get orientation from active Raster Image

08-09-2012 07:33 AM 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!

 

Distinguished Mentor
owenwengerd
Posts: 607
Registered: ‎08-06-2002
Message 4 of 11 (282 Views)

Re: get orientation from active Raster Image

08-09-2012 07:57 AM 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
Active Member
con-pnd
Posts: 8
Registered: ‎08-01-2012
Message 5 of 11 (263 Views)

Re: get orientation from active Raster Image

08-14-2012 01:47 AM 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!

 

Distinguished Mentor
owenwengerd
Posts: 607
Registered: ‎08-06-2002
Message 6 of 11 (252 Views)

Re: get orientation from active Raster Image

08-14-2012 07:26 AM 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
Active Member
con-pnd
Posts: 8
Registered: ‎08-01-2012
Message 7 of 11 (228 Views)

Re: get orientation from active Raster Image

08-30-2012 04:24 AM 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!


 

Distinguished Mentor
owenwengerd
Posts: 607
Registered: ‎08-06-2002
Message 8 of 11 (223 Views)

Re: get orientation from active Raster Image

08-30-2012 06:11 PM 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
Active Member
con-pnd
Posts: 8
Registered: ‎08-01-2012
Message 9 of 11 (208 Views)

Re: get orientation from active Raster Image

09-04-2012 05:30 AM 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

 

 

Distinguished Mentor
owenwengerd
Posts: 607
Registered: ‎08-06-2002
Message 10 of 11 (205 Views)

Re: get orientation from active Raster Image

09-04-2012 05:35 AM in reply to: con-pnd

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

--
Owen Wengerd
ManuSoft

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community