Retrieving path of attached images in AutoCAD using APIs (insert>reference>attach>image)

Retrieving path of attached images in AutoCAD using APIs (insert>reference>attach>image)

Nikita_RAUTELA
Participant Participant
541 Views
4 Replies
Message 1 of 5

Retrieving path of attached images in AutoCAD using APIs (insert>reference>attach>image)

Nikita_RAUTELA
Participant
Participant

 

Problem Statement: I am trying to retrieve the path of the attached reference images.

The use case is insert>>reference>>attach>>image file.
I have Identified that this is a AcDbRasterImage and I tried to cast it to AcDbRasterImagedef object  to find the path by using the apis ,  AcDbRaterImageDef::activeFileName() and AcDbRaterImageDef::sourceFileName() of AcDbRasterImageDef but the values retrieved are ambiguous.

 

In second method, I used AcDbRasterImageDef::imageDictionary(acdbCurDwg()) and tried to iterate through the dictionary to get objectId and the database but this method gives  me the path of the parent drawing and not the path of the image source, although I think I have written this incorrectly, pardon me I am using AutoCAD API foe the first time :).
If someone knows how to get the path of attached reference, it would be great!

 

AcDbObjectId dicoId;

AcDbDictionary* pDict;

 

dicoId = AcDbRasterImageDef::imageDictionary(acdbCurDwg());

eErrStatus = acdbOpenObject((AcDbObject*&)pDict, dicoId, AcDb::kForRead);

 

AcDbDictionaryIterator* dictItr = NULL;

dictItr = pDict->newIterator();

 

for(; dictItr != NULL && !dictItr->done(); dictItr->next())

{

AcDbObject* currentEntObj;

 

eErrStatus = dictItr->getObject(currentEntObj, AcDb::kForRead);

AcDbObjectId objId = currentEntObj->objectId();

AcDbDatabase* db = dicoId.originalDatabase();

 

const ACHAR* pcFilename = NULL;

db->getFilename(pcFilename); 

 

}

Thanks!

0 Likes
Accepted solutions (1)
542 Views
4 Replies
Replies (4)
Message 2 of 5

daniel_cadext
Advisor
Advisor

maybe AcDbHostApplicationServices::findFile?

Python for AutoCAD, Python wrappers for ARX https://github.com/CEXT-Dan/PyRx
0 Likes
Message 3 of 5

Nikita_RAUTELA
Participant
Participant

I believe the filename is  a prerequisite for this API, which is not known here. Do you have any idea of using RatserImageDef to get the path or getting the saved path list of external References?

0 Likes
Message 4 of 5

Alexander.Rivilis
Mentor
Mentor
Accepted solution

@Nikita_RAUTELA wrote:

...I have Identified that this is a AcDbRasterImage and I tried to cast it to AcDbRasterImagedef object  to find the path by using the apis ,  AcDbRaterImageDef::activeFileName() and AcDbRaterImageDef::sourceFileName() of AcDbRasterImageDef but the values retrieved are ambiguous.

 


You try to cast AcDbRasterImage to AcDbRasterImagedef??? You have to use AcDbRasterImage::imageDefId to get AcDbObjectId of AcDbRasterImagedef, open it and get AcDbRaterImageDef::activeFileName() 

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | 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 5 of 5

Nikita_RAUTELA
Participant
Participant

thanks for clearing that, it worked!