Hi Guys,
In my application i have three block symbols contains some attributes. the current task i'm working on
is converting an old version of these blocks (the new version also are dynamic blocks)
let's say i have a host database that has a xref in and the xref contains the old blocks.
i scan the current database (AcDbBlockTableRecord) for that xref, open it and scan the xref database (AcDbBlockTableRecord) for those blocks it turn i find each block make an update insert (insert= from outside database) and replace each AcDbBlockReference. this all process work fine except the attributes at first are places
on the 0,0 position. after audit the xref and regen it, the attributes are restores in place were they should be.
would like to mention that i did not encounter this problem when i insert the blocks in the current database
or even replacing the symbols inside a standard block.
Any one knows what is my problem?
thanks in advance
moshe
Solved! Go to Solution.
Solved by Moshe-A. Go to Solution.
Have you tried setting the database current before adding the attributes?
Hi Owen,
NO
What do you mean by that? to set the Xref database current?
can i do that without closing the host database?
thanx
Moshe
tried it and it still doesn't work, hope i use it good (cause i have never used AcApDocumentManager)
here's what i did
ACHAR XrefFile[32= = _T("xref.dwg"); AcDbDatabase *pXref = NULL; // allocating memory pXref = new AcDbDatabase(Adesk::kFalse); pXref->readDwgFile(XrefFile); { // switch databases acDocManager->setCurDocument(acDocManager->document(pXref)); replace_old_symbols(pXref); // real work // restore current database acDocManager->setCurDocument(acDocManager->document(pCurDwg)); pXref->saveAs(XrefFile); delete pXref; // dispose memory
i would like to understand why is this happends - do you have explanation?
Moshe
Owen,
here's a simple test is did:
i draw a rectangle on the current database (with RECTANGLE command)
disable the call to restore the current database
// acDocManager->setCurDocument(acDocManager->document(pCurDwg));
then build & load & run my application again
then i tried to select the rectangle and i did successed
i thought if the xref database is current i won't be able to select objects in pCurDwg
is this means that the call
acDocManager->setCurDocument(acDocManager->document(pXref))
is not acutally done?
Try instead AcDbHostApplicationServices::setWorkingDatabase().
Hallelujah!
it's working fine
thank you very much owen
i'm sure you have explanation to this and i understand it's related to display and graphics
but why does this happends only to attributes?
Moshe
I can only speculate that calculating text position after an alignment change requires information from the working database, and that the process is intentionally skipped or fails for some reason when the working database is different from the database of the target text object.
Can't find what you're looking for? Ask the community or share your knowledge.